Hi! I’ve just started using GraphHopper as a library (i.e. not through the web API, so I can access the low-level API).
Short version of my question: I’d like to implement basically Google Maps’ “Search along route” functionality for OSM nodes with specific attributes (e.g. finding the nearest waste basket along a route). How would I do this with GraphHopper?
Longer version with example:
- Assume I have calculated a route for a walking profile.
- Now I want search for waste baskets “along” the route, i.e. I want to retrieve a list of n alternative routes that “come closest” to a waste basket, ordered by either added walking distance or walking time (or both).
- A waste basket should be identified by being an OSM node with either waste_basket=yes or amenity=waste_basket.
- How would I implement this with GraphHopper?
I’ve made some initial thoughts on this before posting:
-
To make waste baskets (or any other OSM node of a specific type) “known” to GraphHopper, I assume that I’ll have to enhance the importer. Despite the topic “OSM Data in GraphHopper 3.0” being about a somewhat different use case, it might give me a hint where to start adding functionality to the import process to also capture waste baskets (or other OSM nodes of interest).
-
As most likely no waste basket will be part of a way but basically always be placed next to a way, I expect some preprocessing to be required: I would either need to virtually snap the waste basket onto the respective closest way (most likely the easier option) - or I would need to add a virtual edge from the basket to its nearest way (most likely the option that captures the costs of the detour a little more accurately).
-
Now to the hard part: actually searching along the route. As a naive approach, I could simply loop through ALL waste baskets, calculate the route from start to end via the respective waste basket, and then select the n best baskets. With there currently being more than 7000 waste_basket=yes and more than 500000 amenity=waste_basket nodes, this would however be computationally way too much effort. So I was wondering: Would it somehow be possible to reduce the search area to the nearest few subnetworks or the likes? And ist there existing GraphHopper functionality that would help me here?
All the best
Hauke