Skip to content

Commit

Permalink
fix(isochrones): use the same default smoothing length across builders
Browse files Browse the repository at this point in the history
  • Loading branch information
aoles committed Mar 3, 2024
1 parent e9c98bd commit 22b0a5c
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ void testLocationType() {
.when()
.post(getEndPointPath() + "/{profile}/geojson")
.then().log().ifValidationFails()
.body("features[0].properties.area", is(closeTo(1114937.0f, 10000f)))
.body("features[0].properties.area", is(closeTo(1069855.2f, 10000f)))
.statusCode(200);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ void testPolygon() {
.then()
.body("any { it.key == 'type' }", is(true))
.body("any { it.key == 'features' }", is(true))
.body("features[0].geometry.coordinates[0].size()", is(both(greaterThan(40)).and(lessThan(50))))
.body("features[0].geometry.coordinates[0].size()", is(both(greaterThan(45)).and(lessThan(55))))
.body("features[0].properties.center.size()", is(2))
.body("bbox", hasItems(closeTo(8.652489f, 0.02f), closeTo(49.40263f, 0.02f), closeTo(8.708881f, 0.02f), closeTo(49.447865f, 0.02f)))
.body("features[0].type", is("Feature"))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@
import static org.locationtech.jts.algorithm.hull.ConcaveHull.concaveHullByLength;

public abstract class AbstractIsochroneMapBuilder implements IsochroneMapBuilder {
private static final double MAX_SPLIT_LENGTH = 0.18;// corresponds to 20000 m
private static final double MAX_SEGMENT_LENGTH = 0.18;// corresponds to 20000 m
protected static final DistanceCalc dcFast = new DistancePlaneProjection();
protected GeometryFactory geometryFactory;
protected RouteSearchContext searchContext;
protected double defaultSmoothingDistance = 0.012;// Use a default length of ~1333m
private static final double DEFAULT_SMOOTHING_DISTANCE = 0.009;// Use a default length of ~1000m
protected Polygon previousIsochronePolygon = null;

public abstract Logger getLogger();
Expand Down Expand Up @@ -55,7 +55,7 @@ protected double convertSmoothingFactorToDistance(float smoothingFactor, double
if (maxRadius < 5000)
return MINIMUM_DISTANCE;

return defaultSmoothingDistance;
return DEFAULT_SMOOTHING_DISTANCE;
}

double intervalDegrees = GeomUtility.metresToDegrees(maxRadius);
Expand Down Expand Up @@ -170,7 +170,7 @@ protected List<Coordinate> edgeToPoints(EdgeIteratorState iter, double minSplitL
lat1 = pl.getLat(i);
lon1 = pl.getLon(i);
addPoint(points, lon0, lat0);
splitLineSegment(lat0, lon0, lat1, lon1, points, minSplitLength, MAX_SPLIT_LENGTH);
splitLineSegment(lat0, lon0, lat1, lon1, points, minSplitLength, MAX_SEGMENT_LENGTH);
lon0 = lon1;
lat0 = lat1;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public class FastIsochroneMapBuilder extends AbstractIsochroneMapBuilder {
private CellStorage cellStorage;
private IsochroneNodeStorage isochroneNodeStorage;
private QueryGraph queryGraph;
private static final int MAX_EDGE_LENGTH_LIMIT = Integer.MAX_VALUE;
private static final int MAX_SEGMENT_LENGTH = Integer.MAX_VALUE;
private static final double ACTIVE_CELL_APPROXIMATION_FACTOR = 0.99;
private static final Logger LOGGER = Logger.getLogger(FastIsochroneMapBuilder.class.getName());

Expand All @@ -78,7 +78,6 @@ public Logger getLogger() {
@Override
public void initialize(RouteSearchContext searchContext) {
super.initialize(searchContext);
defaultSmoothingDistance = 0.010;// Use a default length of ~1000m
var fastIsochroneFactory = ((ORSGraphHopper) searchContext.getGraphHopper()).getFastIsochroneFactory();
this.cellStorage = fastIsochroneFactory.getCellStorage();
this.isochroneNodeStorage = fastIsochroneFactory.getIsochroneNodeStorage();
Expand Down Expand Up @@ -283,7 +282,7 @@ private List<Coordinate> createCoordinateListFromGeometry(Geometry preprocessedG
for (int i = 0; i < ringCoords.size(); i++) {
lat1 = ringCoords.get(i).y;
lon1 = ringCoords.get(i).x;
splitLineSegment(lat0, lon0, lat1, lon1, contourCoords, minSplitLength, MAX_EDGE_LENGTH_LIMIT);
splitLineSegment(lat0, lon0, lat1, lon1, contourCoords, minSplitLength, MAX_SEGMENT_LENGTH);
lon0 = lon1;
lat0 = lat1;
}
Expand Down

0 comments on commit 22b0a5c

Please sign in to comment.