Produce a signal on a wire with a limited range
Here is some more random ideas:


Measure the inductance -- have unit "1" short the track, then have "S" run LC generator. Measure the frequency. Track inductance will be proportional to its length, but it will be in microhenries range (this page may help: http://www.eeweb.com/toolbox/wire-inductance)
Measure resistance via voltage drop:


Short one end of the track.
Apply high, but constant current (5A) to another end of the track. Make sure to limit voltage to a very low value to ensure that bad connection will not cause system meltdown.
Have trains measure the voltage between wheels (which will be in millivolts range then)
Make sure the current is only applied for a very short pulses (milliseconds), otherwise the track will overheat. This obviously requires CPUs and communtion channel at all endpoints.



for more practical methods:


Add a coil under sections of interest -- there is no need to use a full RFID system. Instead, under section 1 place a (very long) coil driven by 40kHz, under section 2 a (very long) coil driven by 42 khz, and measure the frequency at the train. Or flip the system and have the trains transmit the freqencies while the sections receive. The coil can be very simple -- in NatCar competition, the transmitter is a single 50-foot wire and a pickup is a small ferrite bobbin.
Detect when the trains cross specific points.


Put an infrared led at each train which transmits train-specific code. Put a bunch of IR receivers near entrances/exits of the track.
Use camera and recognize trains with computer vision :)