I’m investigating whether Graphhopper could be used for my use case, which is to find the shortest/best path from a point to a trail; where a trail is (by geoJson terminology) a MultiLineString. This particular Multilinestring is composed of approx 200 lines and 100.000 points in total.
So I would go something like 1) start a Graphhopper instance 2) load OSM data 3) load the multiline 4) do tons of searches from different points to find the closest way from that point to anywhere on the multiline.
Is this a feature that Graphhopper supports (if so, some pointers would be highly appreciated), or is Graphhopper point-to-point only?
I do something very similar in one of my projects, but I don’t use GH for this aspect of it. I do use GH for the routing, of course.
To achieve what you’re describing, I load all of the multilinestrings into Postgres/PostGIS, and then query these from my Java app before starting the routing process. PostGIS has very good indexing of geometry data, so this works efficiently for planet-wide data for me. Specifically I use the ST_ClosestPoint function (ST_ClosestPoint) to find the nearest point on the trail to the user’s start location.
You’re correct. And yes, this can lead to some problematic scenarios, especially around rivers.
I’m not sure if what you’re describing is possible with GH, I don’t think it is out of the box. Basically you want to find the fastest path from Point A to any point on LineString B. I suspect this could be achieved, but it’d require quite some fairly deep changes.
To really pick the best path you need to map match the trail and get back the edges or nodes and then use DijkstraOneToMany or a normal Dijkstra (DijkstraBidirectionRef) with many destinations initialized (multiple calls to initTo). A bit more complicated but should be doable with the Java library