What is a good approach to detecting distance and speed in model railroads?
If I were automating a model railroad I would put barcode labels on the bottoms of the train cars.  Then spread throughout the track I would place barcode readers, facing up from between the rails.

With this you can detect the position, speed, and identity of the cars.  Each car would have its own unique barcode, not just the locomotive.

The position sensing of this method is very course, since it relies on when a train passes over a sensor.  But it should work fine for most things.  You can always put more sensors at important points in the track and less sensors where it doesn't matter so much.

A huge advantage of this method is that the price per train car is very low, only a label that you can print up on your laser or ink-jet printer.  The complexity per train car is very low.  And the weight added to each car is super low as well.

I would implement this by using an IR LED and Phototransistor as the sensor (there are components with both of these built in), and connect these to a microcontroller.  Each sensor has its own microcontroller.  The different sensors can then be connected together using a simple network (like an RS-485 bus).  With IR LEDs, the sensor would be difficult to see with the naked eye.  Total cost per sensor+MCU could be under US$3, not including a small PCB.