Display filtered roads

TLDR

How can I display a map using a data source like OpenStreetMap (OSM) where instead of displaying route from A to B, I display all roads in a region, then apply filters on attributes like road_class, surface, and road_access? The goal is to visualize the impact of the GraphHopper custom_model on the routes that are affected when “multiply_by”: “0.0” is used. I want to see what roads disappear from road_class X or Y.

CONTEXT

When using the GraphHopper custom_model, I encountered the “max nodes 5,000,000” error. After some trial and error, I realized that the primary issue wasn’t my “multiply_by” applied on curvature, but rather the lack of filtering on attributes like surface, road_class, and road_access, which led to a high node count. Now, I’ve improved my custom_model by restricting many many nodes and now I want to be sure I don’t filter things I would actually like to keep.

You can run your own GraphHopper server instance and a separate instance of GraphHopper Maps. You can adjust this code to highlight/display/hide roads based on their attributes: https://github.com/graphhopper/graphhopper-maps/blob/56cdfc78acf88b477457f8846c8715058b5375db/src/layers/UseRoutingGraphLayer.tsx#L78-L105

So, by running my own server instance, I could have a maps app display all roads in a region, then filter them by attribute ? I don’t want to simply show route from A to B.

For example, I would want to zoom in a mountain region and filter all road_class that are UNCLASSIFIED and/or TRACK to see which ones affect my custom_model.

Yes, this is possible due to the /mvt endpoint of the open source GraphHopper server (which is not offered via the hosted Directions API)

For example, I would want to zoom in a mountain region and filter all road_class that are UNCLASSIFIED and/or TRACK to see which ones affect my custom_model.

Yes, this is possible. Strictly speaking you don’t necessarily need the GraphHopper server for this and there are many other OSM tools you could use to achieve the same.

Strictly speaking you don’t necessarily need the GraphHopper
You are right, but this would be a “debug” tool to improve my custom_model, which is a graphhopper thing.

If anyone arrives here after a web search, these are the solutions I found:

  1. Easiest: use overpass-turbo on an area and filter the roads you want. You can use the wizard, or learn the OverpassQL language.

  2. Most complete: implement a POST request towards the overpass API inside your app to display the wanted roads as a layer. You’ll want to use “osmtogeojson” lib to avoid headaches processing the answer from overpass API.