Crossing countries & specific tags


I am runnning my own instance of GraphHopper.

I would like to display countries that a route goes through.

Also, I need to display a list of nodes (that belong to the route) with some specific tags (like k="highway" v="traffic_signals" and many more).

How could I achieve this? Which java classes should I rewrite / modify?

Thank you very much

Displaying countries is very easy. You just need to do add country to graph.encoded_values, run a new import (!), and request the corresponding country path detail.

Displaying traffic_signals is much more involved. You need to parse this information from the OSM file and make it available in the routing response. This PR could be a good start for this: Make use of node tags like 'highway' or 'crossing' by easbar · Pull Request #2705 · graphhopper/graphhopper · GitHub


Thank you. What if I had to display train stations with a tag of railway=border?

For a railway router? These tags seem to only be located along railways, so I am not sure what you mean?

Yes, for a railway router.

Ok, then it would be the exact same as for traffic_signal. It does not matter what kind of node tag it is. Or are you wondering how to implement a railway router?

I am trying to implement railway router using GitHub - geofabrik/OpenRailRouting: routing on railway tracks using OpenStreetMap data and the GraphHopper routing engine, but I am failing to retrieve countries (even though I updated graph.encoded_values) that route goes through and I also need train stations that are at the borders (have the tag Tag:railway=border - OpenStreetMap Wiki)

Ok, I don’t know the details of OpenRailRouting. But for speaking of the GraphHopper code reading railway=border for railways should be the exact same as reading traffic_signals for highways.

1 Like

If I follow the same approach that is shown in the Pull Request, I should be able to retrieve train station names that are at the border?

Yes, you should receive all node tags whatsoever

1 Like

It seems I would need to define all train station names in the enum, no?

To store arbitrary strings you can use the EdgeKVStorage. See e.g. graphhopper/ at master · graphhopper/graphhopper · GitHub

1 Like

Thank you guys very much (@karussell and @easbar). I managed to make it work. However, I noticed that railway=border does not return the precise location of a train station. Any idea why?

You mean the location is different to the actual OSM node? Or the OSM node is not were the train station is in reality? And what exactly did you do?

In OpenStreetMap <tag k="railway" v="border"/> represents the point of where exactly the border is, but I need the location of the train station where the transition happens. Note: it gives the correct train station name but not the location. Tag:railway=border - OpenStreetMap Wiki

Ok, but I’m afraid this is out of scope for GraphHopper or what do you think can we do about this?

1 Like

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.