Regarding the recent thread on DCC where someone asked about a way to automatically control a turnout based on the presence of a train on the track leading to it, I ran across some stuff that, even if it doesn't answer that particular question, could be of value in other applications.
_Mainline Modeler_ ran a series of articles back in 1993-5 by Rich Weyand, describing a bunch of very useful electronic modules. These are "building blocks" which can easily be interfaced to each other, and to other devices like DCC controllers, RC controllers, etc.
Turns out these are nicely archived on a page on Rich's TracTronics site:
In the case of the inquiry about controlling a switch, you might want to take a look at two of these modules: DetectTrain uses current detection in an isolated track block to sense the presence of a train within that block, and SeeTrain is an optical detector to sense the presence of a train at a particular location.
There's other kewl stuff there too.