Skip to content

Commit

Permalink
fix(isochrones): use correct edge filter for snapping
Browse files Browse the repository at this point in the history
  • Loading branch information
aoles committed Oct 13, 2023
1 parent cc92a26 commit 671071c
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 63 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ RELEASING:
- schema type for parameters of type Duration ([#1504](https://github.com/GIScience/openrouteservice/pull/1504))
- Fix the max visited nodes bug for fast-isochrones ([#1538](https://github.com/GIScience/openrouteservice/pull/1538))
- adjust weighting of heat stress routing to avoid large detours
- fix isochrones snapping ([#1566](https://github.com/GIScience/openrouteservice/pull/1566))

## [7.1.0] - 2023-06-13
### Added
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,14 @@
import com.carrotsearch.hppc.IntObjectMap;
import com.graphhopper.GraphHopper;
import com.graphhopper.routing.SPTEntry;
import com.graphhopper.routing.ev.Subnetwork;
import com.graphhopper.routing.querygraph.QueryGraph;
import com.graphhopper.routing.util.DefaultSnapFilter;
import com.graphhopper.routing.util.EdgeFilter;
import com.graphhopper.routing.util.FlagEncoder;
import com.graphhopper.routing.util.TraversalMode;
import com.graphhopper.routing.weighting.FastestWeighting;
import com.graphhopper.routing.weighting.ShortestWeighting;
import com.graphhopper.routing.weighting.Weighting;
import com.graphhopper.storage.GraphHopperStorage;
import com.graphhopper.storage.index.Snap;
Expand All @@ -32,8 +35,8 @@
import org.heigit.ors.routing.algorithms.TDDijkstraCostCondition;
import org.heigit.ors.routing.graphhopper.extensions.AccessibilityMap;
import org.heigit.ors.routing.graphhopper.extensions.ORSEdgeFilterFactory;
import org.heigit.ors.routing.graphhopper.extensions.weighting.DistanceWeighting;
import org.heigit.ors.routing.traffic.TrafficSpeedCalculator;
import org.heigit.ors.util.ProfileTools;
import org.locationtech.jts.geom.Coordinate;

import java.time.ZonedDateTime;
Expand All @@ -47,10 +50,12 @@ private GraphEdgeMapFinder() {
public static AccessibilityMap findEdgeMap(RouteSearchContext searchCntx, IsochroneSearchParameters parameters) throws Exception {
GraphHopper gh = searchCntx.getGraphHopper();
FlagEncoder encoder = searchCntx.getEncoder();
Weighting weighting = createWeighting(parameters, encoder);
String profileName = ProfileTools.makeProfileName(encoder.toString(), weighting.getName(), false);
GraphHopperStorage graph = gh.getGraphHopperStorage();

EdgeFilter defaultSnapFilter = new DefaultSnapFilter(weighting, graph.getEncodingManager().getBooleanEncodedValue(Subnetwork.key(profileName)));
ORSEdgeFilterFactory edgeFilterFactory = new ORSEdgeFilterFactory();
EdgeFilter edgeFilter = edgeFilterFactory.createEdgeFilter(searchCntx.getProperties(), encoder, graph);
EdgeFilter edgeFilter = edgeFilterFactory.createEdgeFilter(searchCntx.getProperties(), encoder, graph, defaultSnapFilter);

Coordinate loc = parameters.getLocation();
Snap res = gh.getLocationIndex().findClosest(loc.y, loc.x, edgeFilter);
Expand All @@ -64,7 +69,6 @@ public static AccessibilityMap findEdgeMap(RouteSearchContext searchCntx, Isochr

if (fromId == -1)
throw new InternalServerException(IsochronesErrorCodes.UNKNOWN, "The closest node is null.");
Weighting weighting = createWeighting(parameters, encoder);

if (parameters.isTimeDependent()) {
return calculateTimeDependentAccessibilityMap(parameters, encoder, graph, edgeFilter, queryGraph, snappedPosition, fromId, weighting);
Expand Down Expand Up @@ -114,6 +118,6 @@ private static AccessibilityMap calculateTimeDependentAccessibilityMap(Isochrone

private static Weighting createWeighting(IsochroneSearchParameters parameters, FlagEncoder encoder) {
return parameters.getRangeType() == TravelRangeType.TIME ? new FastestWeighting(encoder)
: new DistanceWeighting(encoder);
: new ShortestWeighting(encoder);
}
}

This file was deleted.

0 comments on commit 671071c

Please sign in to comment.