Routing on railway tracks
Geofabrik developed a railway routing service for the French railway company SNCF using the GraphHopper routing engine.
It uses the railway tracks from OpenStreetMap.
GraphHopper was used as a Java library and road specific parts were replaced . On a quick glance, one could
think that replacing
railway all over the code would be sufficient. This would work for a quick prototype, but is not enough. Useful railway routing must take into account several differences from road routing.
- Unlike road vehicles, trains cannot turn in arbitrary angles at any node in the graph (switches for railways,
intersections for cars). They can only turn in slight angles. The railway routing engine iterates over all nodes in the graph
and adds turn restrictions to all pairs of edges whose angle is not within a certain interval.
- Crossings of two railway tracks need special treatment.
Trains can go through them only in a straight direction, they cannot change direction
there. Crossings and switches are not distinguishable because the OSM tag
is dropped in an earlier processing step. Because GraphHopper was not designed as a library, it cannot be extended easily, hence we use a forked version.
Trains cannot go into reverse as quickly as cars. In some cases, the engineer can can walk to the other end of the train. But other
trains, such as freight trains need longer. The engine has to be decoupled from the train, driven around the train to the other end and
re-coupled. This procedure usually takes more than 15 minutes. Detours avoiding reversals are more effecient.
Different gauges and power systems are two of many reasons prohibiting the universal usage of the same trains. The railway routing engine
can be configured (using a configuration file) to provide special routing profiles for certain classes supporting only a specific power
system and gauge.
In addition to the calculation of routes, the software supports matching GPS routes to the railway network, using various file formats (GPX,
CSV, shape files).
All components of this project has been published as open source software.