diff --git a/CHANGELOG.md b/CHANGELOG.md index 4bc28586c6..2cb1c72f81 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -65,6 +65,7 @@ RELEASING: - various style and low level code problems ([#1489](https://github.com/GIScience/openrouteservice/pull/1489)) - Fix the max visited nodes bug for fast-isochrones ([#1538](https://github.com/GIScience/openrouteservice/pull/1538)) - fix isochrones snapping ([#1568](https://github.com/GIScience/openrouteservice/pull/1568)) +- fix fast-isochrones snapping ([#1570](https://github.com/GIScience/openrouteservice/pull/1570)) ## [7.1.0] - 2023-06-13 ### Added diff --git a/ors-engine/src/main/java/org/heigit/ors/isochrones/builders/fast/FastIsochroneMapBuilder.java b/ors-engine/src/main/java/org/heigit/ors/isochrones/builders/fast/FastIsochroneMapBuilder.java index 00e2795684..05d19a2cd8 100644 --- a/ors-engine/src/main/java/org/heigit/ors/isochrones/builders/fast/FastIsochroneMapBuilder.java +++ b/ors-engine/src/main/java/org/heigit/ors/isochrones/builders/fast/FastIsochroneMapBuilder.java @@ -16,18 +16,19 @@ import com.carrotsearch.hppc.IntHashSet; import com.carrotsearch.hppc.IntObjectMap; import com.carrotsearch.hppc.cursors.IntObjectCursor; +import com.graphhopper.GraphHopper; import com.graphhopper.coll.GHIntObjectHashMap; import com.graphhopper.routing.SPTEntry; +import com.graphhopper.routing.ev.Subnetwork; import com.graphhopper.routing.querygraph.QueryGraph; -import com.graphhopper.routing.util.EdgeFilter; -import com.graphhopper.routing.util.HikeFlagEncoder; -import com.graphhopper.routing.util.TraversalMode; +import com.graphhopper.routing.util.*; import com.graphhopper.routing.weighting.Weighting; import com.graphhopper.storage.Graph; import com.graphhopper.storage.GraphHopperStorage; import com.graphhopper.storage.index.Snap; import com.graphhopper.util.*; import com.graphhopper.util.shapes.GHPoint3D; +import org.heigit.ors.util.ProfileTools; import org.locationtech.jts.geom.*; import org.locationtech.jts.index.quadtree.Quadtree; import org.locationtech.jts.operation.union.UnaryUnionOp; @@ -135,8 +136,15 @@ public IsochroneMap compute(IsochroneSearchParameters parameters) throws Excepti Weighting weighting = ORSWeightingFactory.createIsochroneWeighting(searchcontext, parameters.getRangeType()); Coordinate loc = parameters.getLocation(); + + FlagEncoder encoder = searchcontext.getEncoder(); + String profileName = ProfileTools.makeProfileName(encoder.toString(), weighting.getName(), false); + GraphHopper gh = searchcontext.getGraphHopper(); + GraphHopperStorage graphHopperStorage = gh.getGraphHopperStorage(); + EdgeFilter defaultSnapFilter = new DefaultSnapFilter(weighting, graphHopperStorage.getEncodingManager().getBooleanEncodedValue(Subnetwork.key(profileName))); + ORSEdgeFilterFactory edgeFilterFactory = new ORSEdgeFilterFactory(); - EdgeFilterSequence edgeFilterSequence = getEdgeFilterSequence(edgeFilterFactory); + EdgeFilterSequence edgeFilterSequence = getEdgeFilterSequence(edgeFilterFactory, defaultSnapFilter); Snap res = searchcontext.getGraphHopper().getLocationIndex().findClosest(loc.y, loc.x, edgeFilterSequence); List snaps = new ArrayList<>(1); snaps.add(res); @@ -255,9 +263,9 @@ public IsochroneMap compute(IsochroneSearchParameters parameters) throws Excepti return isochroneMap; } - private EdgeFilterSequence getEdgeFilterSequence(ORSEdgeFilterFactory edgeFilterFactory) throws Exception { + private EdgeFilterSequence getEdgeFilterSequence(ORSEdgeFilterFactory edgeFilterFactory, EdgeFilter prependFilter) throws Exception { EdgeFilterSequence edgeFilterSequence = new EdgeFilterSequence(); - EdgeFilter edgeFilter = edgeFilterFactory.createEdgeFilter(searchcontext.getProperties(), searchcontext.getEncoder(), searchcontext.getGraphHopper().getGraphHopperStorage()); + EdgeFilter edgeFilter = edgeFilterFactory.createEdgeFilter(searchcontext.getProperties(), searchcontext.getEncoder(), searchcontext.getGraphHopper().getGraphHopperStorage(), prependFilter); edgeFilterSequence.add(edgeFilter); edgeFilterSequence.add(new AvoidFeaturesEdgeFilter(AvoidFeatureFlags.FERRIES, searchcontext.getGraphHopper().getGraphHopperStorage())); return edgeFilterSequence;