Skip to content

Commit e8af024

Browse files
committed
Add tolerance to IsochroneResource
1 parent b3e3c99 commit e8af024

File tree

3 files changed

+6
-5
lines changed

3 files changed

+6
-5
lines changed

isochrone/src/main/java/com/graphhopper/isochrone/algorithm/JTSTriangulator.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ public JTSTriangulator(RouterConfig routerConfig) {
4646
this.routerConfig = routerConfig;
4747
}
4848

49-
public Result triangulate(Snap snap, QueryGraph queryGraph, ShortestPathTree shortestPathTree, ToDoubleFunction<ShortestPathTree.IsoLabel> fz) {
49+
public Result triangulate(Snap snap, QueryGraph queryGraph, ShortestPathTree shortestPathTree, ToDoubleFunction<ShortestPathTree.IsoLabel> fz, double tolerance) {
5050
final NodeAccess na = queryGraph.getNodeAccess();
5151
Collection<Coordinate> sites = new ArrayList<>();
5252
shortestPathTree.search(snap.getClosestNode(), label -> {
@@ -81,7 +81,7 @@ public Result triangulate(Snap snap, QueryGraph queryGraph, ShortestPathTree sho
8181
// what we want.
8282

8383
Collection<ConstraintVertex> constraintVertices = sites.stream().map(ConstraintVertex::new).collect(Collectors.toList());
84-
ConformingDelaunayTriangulator conformingDelaunayTriangulator = new ConformingDelaunayTriangulator(constraintVertices, 0.0);
84+
ConformingDelaunayTriangulator conformingDelaunayTriangulator = new ConformingDelaunayTriangulator(constraintVertices, tolerance);
8585
conformingDelaunayTriangulator.setConstraints(new ArrayList<>(), new ArrayList<>());
8686
conformingDelaunayTriangulator.formInitialDelaunay();
8787
conformingDelaunayTriangulator.enforceConstraints();

isochrone/src/main/java/com/graphhopper/isochrone/algorithm/Triangulator.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,6 @@ public Result(ReadableTriangulation triangulation, Collection<ReadableQuadEdge>
3838

3939
}
4040

41-
Result triangulate(Snap snap, QueryGraph queryGraph, ShortestPathTree shortestPathTree, ToDoubleFunction<ShortestPathTree.IsoLabel> fz);
41+
Result triangulate(Snap snap, QueryGraph queryGraph, ShortestPathTree shortestPathTree, ToDoubleFunction<ShortestPathTree.IsoLabel> fz, double tolerance);
4242

4343
}

web-bundle/src/main/java/com/graphhopper/resources/IsochroneResource.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,8 @@ public Response doGet(
8080
@QueryParam("distance_limit") @DefaultValue("-1") LongParam distanceLimitInMeter,
8181
@QueryParam("weight_limit") @DefaultValue("-1") LongParam weightLimit,
8282
@QueryParam("type") @DefaultValue("json") ResponseType respType,
83-
@QueryParam("full_geometry") @DefaultValue("false") boolean fullGeometry) {
83+
@QueryParam("full_geometry") @DefaultValue("false") boolean fullGeometry,
84+
@QueryParam("tolerance") @DefaultValue("0") double tolerance) {
8485
StopWatch sw = new StopWatch().start();
8586

8687
PMap hintsMap = new PMap();
@@ -140,7 +141,7 @@ public Response doGet(
140141
fz = l -> l.time;
141142
}
142143

143-
Triangulator.Result result = triangulator.triangulate(snap, queryGraph, shortestPathTree, fz);
144+
Triangulator.Result result = triangulator.triangulate(snap, queryGraph, shortestPathTree, fz, tolerance);
144145

145146
ContourBuilder contourBuilder = new ContourBuilder(result.triangulation);
146147
ArrayList<Geometry> isochrones = new ArrayList<>();

0 commit comments

Comments
 (0)