Getting distance between any two points along the train track / railway?

Hi, I’m interested in using this suite of tools for a project. My full problem description:

  • provided a set of GPS coordinates [(x1, y1), … , (xn, yn)]
  • calculate the distance between (x1, y1) and (xn, yn)
  • subject to the constraints: route can only be a railway track, GPS coordinates are received in approx. 30min. intervals

Is this usecase supported? Any guidance would be appreciated.

Yes, can’t you just setup a custom profile that can only travel on railways?
Presuming GPS coordinates are within a reasonable distance from railway tracks

1 Like

You could use map matching and https://github.com/geofabrik/OpenRailRouting

Thanks for the reply,

Looking through the documentation I noticed that the supported vehicle types do not include train: https://github.com/graphhopper/graphhopper/blob/master/docs/core/profiles.md#standard-profiles

What should the profile be based on? Is it possible to setup a custom routing profile w/o a vehicle type?

Thanks for the reply,

I was looking at that tool, but there seems to be a lack of activity in github there, also created a github issue with the same question as here: https://github.com/geofabrik/OpenRailRouting/issues/28

I will test that and get back to you.
Thank you again.

Hiya, I haven’t attempted to allow only train paths but as you aren’t requiring time, you could setup a custom profile, use any base vehicle and remove all standard road access within the profile. Then assign only rail type networks.
I would imagine something like setting up a custom profile based on car that can only drive on footpaths.

There is most likely something I’m overlooking but if I was doing it, I would attempt to just get the most basic route working first.

You have to consider that our OSMReader does not include railways by default. But this can be changed. I actually did this for waterways once: https://github.com/graphhopper/graphhopper/pull/2448#issue-1038243323. Just starting from this commit: https://github.com/graphhopper/graphhopper/commit/8d331af726e6b094ce2362312241f58e178d6ad2 you should be able to start a GH server that routes on railways. Since you are only interested in distances a constant speed for all waterways will do.

One major hurdle might be that railways are rather sparse compared to roads. So if you enter GPS coordinates that aren’t close to any railways you might run into ‘point not found’ errors.

2 Likes

Thanks for the help. I will note this as a possible solution.

In the meantime, I have launched the geofabrik/OpenRailRouting as it does seem to stick to rail using GPS, however even for Berlin OSM file I have found that the rails are not well mapped - in the following screenshot I have placed the endpoint farther and the map matching seems to not work anymore (see below). I was using the berlin OSM file, found here: Geofabrik Download Server

Is this a fundamental limitation of the maps?

The railway seems to be mapped, otherwise it wouldn’t be shown on the map? What if you move the green marker further south? I wonder if this part of the railway cannot be found at all or if it is just not connected to the part North of the junction. You can also open the map layer menu and enable ‘Local MVT’ to see whether or not an edge was added to the routing graph for this railway.

Hi,

It seems like it stops routing at the intersection to that road. Additionally, I noticed that more rails are not being map-matched - which might be related, is my guess. Obviously I don’t know much about these tools, so don’t take my guess as indicative. The issue is this - I add the start / end dots and the closest map-matched track is not the one that is closest to the points. Could this be related to profile settings I’m using (see first screenshot)?

Also, adding the screenshot for what happens when the green marker is moved south - it does not register it (second screenshot).

IMO questions regarding OpenRailRouting should go to their channels or towards @Nakaner_Geofabrik. We don’t know how they implemented it in details and also they still use a pre 1.0 GraphHopper version. You could also try what @easbar proposed as it uses the most recent GraphHopper including MVT view etc.

Thanks for the continuous engagement,

  • No worries, I understand that this is a bit of an offtopic for this forum - unfortunately openrailrouting team are not responsive in github issues, so I chose the path or
    least resistance in the communication (this forum). Besides going to their github and/or tagging @Nakaner_Geofabrik do you perhaps know of other means of getting in touch with them?

  • Also, seems like I have solved the 2 issues I faced. 1. Issue with routing in the baltic region (Lithuania, Latvia, Estonia) is solved by creating a new profile (I provided the config file I use: Too many total edges were removed error problem · Issue #1 · geofabrik/OpenRailRouting · GitHub). The 2nd issue with the inability to properly calculate the distance on some berlin rails was solved by just using the entire German OSM file. There is an issue with the inability to add end/start endpoints at the edges of the maps, presumably an issue with OSM.

Yes this can be an issue. OSM ways often cover large distances (and maybe railway especially(?)). Depending on how the extracts are created some ways that are not located within the boundaries of the extract entirely might be not included at all (you can easily find out by opening your OSM file in JOSM or similar)

I’m looking to do car/truck routing, but with access allowed for runways and taxiways. Is this the branch where I should be starting?

Is this branch likely to get merged into master in the near future?

Thanks!

No. Right now I think the easiest way to do this is modify the CarTagParser in current master, or the corresponding CarFlagEncoder in 5.0, according to your needs. Another option would be using the RoadsTagParser/FlagEncoder and setup your own routing rules in a custom model.

Hi @M1ndas , did you ever settle on a good solution? I am trying to do something similar.

Hi ,
I have tried to run/launch the routing as is using the README.md provided but i keep getting errors can you assist?

Please avoid hijacking topics and instead create a new one and add more information about the error, the version and what you have tried.