Example of edge filter for road snapping

I am wondering if there are examples for using custom edge filters for road snapping. Currently I am using ALL_EDGES:

QueryResult queryResult = hopper.getLocationIndex().findClosest(latitude, longitude, EdgeFilter.ALL_EDGES);

Examples for custom edge filters would be snaps based on OSM tags or edges of certain lengths / max velocities.

1 Like

At least filtering by edge distance is very simple:

index.findClosest(latitude, longitude, edgeState -> edgeState.getDistance() > 1000);

For OSM tags, velocity etc. you need to read the edge properties using FlagEncoder and/or EncodedValue. For example speed:

double speedFwd = edgeState.get(encoder.getAverageSpeedEnc());
double speedBwd = edgeState.getReverse(encoder.getAverageSpeedEnc());
1 Like

See also https://github.com/graphhopper/graphhopper/pull/1644

2 Likes

Looks very useful. I guess this will be released with the next GH version? Is there a release cycle? When do you plan to make the next release?

Yes. You can already use a pre version or wait until 0.13 is released in ~2 months

1 Like

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