Skip to content

Commit

Permalink
fix(isochrones): avoid reducing speed on roads tagged with `access=de…
Browse files Browse the repository at this point in the history
…stination`
  • Loading branch information
aoles committed Feb 7, 2024
1 parent 2917d8b commit bcfac6e
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 13 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ RELEASING:
- log summary stats on traffic mapmatching and use progress bar only in debug mode ([#1647](https://github.com/GIScience/openrouteservice/pull/1647))
- move APIEnums into API module ([#1634](https://github.com/GIScience/openrouteservice/issues/1634))
- performance improvements to isochrone calculations ([#1607](https://github.com/GIScience/openrouteservice/pull/1607))
- do not apply speed penalty to roads tagged with "access=destination" when computing isochrones ([#1682](https://github.com/GIScience/openrouteservice/pull/1682))

### Deprecated
- JSON configuration and related classes ([#1506](https://github.com/GIScience/openrouteservice/pull/1506))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,7 @@
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.util.*;
import com.graphhopper.routing.weighting.FastestWeighting;
import com.graphhopper.routing.weighting.ShortestWeighting;
import com.graphhopper.routing.weighting.Weighting;
Expand All @@ -35,6 +32,7 @@
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.ORSWeightingFactory;
import org.heigit.ors.routing.traffic.TrafficSpeedCalculator;
import org.heigit.ors.util.ProfileTools;
import org.locationtech.jts.geom.Coordinate;
Expand All @@ -50,10 +48,11 @@ 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)));
EncodingManager encodingManager = gh.getEncodingManager();
Weighting weighting = new ORSWeightingFactory(graph, encodingManager).createIsochroneWeighting(searchCntx, parameters.getRangeType());
String profileName = ProfileTools.makeProfileName(encoder.toString(), weighting.getName(), false);
EdgeFilter defaultSnapFilter = new DefaultSnapFilter(weighting, encodingManager.getBooleanEncodedValue(Subnetwork.key(profileName)));
ORSEdgeFilterFactory edgeFilterFactory = new ORSEdgeFilterFactory();
EdgeFilter edgeFilter = edgeFilterFactory.createEdgeFilter(searchCntx.getProperties(), encoder, graph, defaultSnapFilter);

Expand Down Expand Up @@ -115,9 +114,4 @@ private static AccessibilityMap calculateTimeDependentAccessibilityMap(Isochrone
IntObjectMap<SPTEntry> edgeMap = tdDijkstraCostCondition.getMap();
return new AccessibilityMap(edgeMap, tdDijkstraCostCondition.getCurrentEdge(), snappedPosition);
}

private static Weighting createWeighting(IsochroneSearchParameters parameters, FlagEncoder encoder) {
return parameters.getRangeType() == TravelRangeType.TIME ? new FastestWeighting(encoder)
: new ShortestWeighting(encoder);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ public Weighting createIsochroneWeighting(Profile profile, PMap requestHints) {

public static Weighting createIsochroneWeighting(RouteSearchContext searchContext, TravelRangeType travelRangeType) {
if (travelRangeType == TravelRangeType.TIME) {
return new FastestWeighting(searchContext.getEncoder());
return new ORSFastestWeighting(searchContext.getEncoder());
} else {
return new ShortestWeighting(searchContext.getEncoder());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@
public class ORSFastestWeighting extends FastestWeighting {
private final double headingPenalty;

public ORSFastestWeighting(FlagEncoder encoder) {
this(encoder, new PMap(0), TurnCostProvider.NO_TURN_COST_PROVIDER);
}

public ORSFastestWeighting(FlagEncoder encoder, PMap map, TurnCostProvider turnCostProvider) {
super(encoder, map, turnCostProvider);
headingPenalty = map.getDouble(Parameters.Routing.HEADING_PENALTY, Parameters.Routing.DEFAULT_HEADING_PENALTY);
Expand Down

0 comments on commit bcfac6e

Please sign in to comment.