Skip to content

Commit

Permalink
Merge branch 'development' into feature#377-alternative-routes-v2
Browse files Browse the repository at this point in the history
  • Loading branch information
takb authored Mar 26, 2019
2 parents 90c3ed9 + e282075 commit b3b747a
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 11 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
### Added
- Makes docker and docker-compose deployment of openrouteservice more customizable (Issue #434)
### Fixed
-
- Enable > 2 waypoints when geometry_simplify=true (#457)
### Changed
- Updated pom to always build ors.war (Issue #432)
### Deprecated
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ public ParamsTest() {
addParameter("coordinatesShort", "8.678613,49.411721|8.687782,49.424597");
addParameter("coordinatesShortFaulty", "8.680916a,49.41b0973|8.6c87782,049gbd.424597");
addParameter("coordinatesLong", "8.678613,49.411721|4.78906,53.071752");
addParameter("coordinatesShortThree", "8.678613,49.411721|8.687782,49.424597|8.691087,49.425009");
addParameter("extra_info", "surface|suitability|steepness");
addParameter("preference", "fastest");
addParameter("profile", "cycling-regular");
Expand Down Expand Up @@ -729,7 +730,7 @@ public void expectSuppressedWarnings() {
@Test
public void expectSimplifyGeometry() {
given()
.param("coordinates", getParameter("coordinatesShort"))
.param("coordinates", getParameter("coordinatesShortThree"))
.param("profile", getParameter("carProfile"))
.param("geometry_simplify", "true")
.when()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1817,7 +1817,7 @@ public void testAccessRestrictionsWarnings() {
@Test
public void testSimplifyHasLessWayPoints() {
JSONObject body = new JSONObject();
body.put("coordinates", getParameter("coordinatesShort"));
body.put("coordinates", getParameter("coordinatesLong"));

given()
.header("Accept", "application/geo+json")
Expand All @@ -1828,7 +1828,7 @@ public void testSimplifyHasLessWayPoints() {
.post(getEndPointPath() + "/{profile}/geojson")
.then().log().all()
.assertThat()
.body("features[0].geometry.coordinates.size()", is(75))
.body("features[0].geometry.coordinates.size()", is(534))
.statusCode(200);

body.put("geometry_simplify", true);
Expand All @@ -1842,7 +1842,7 @@ public void testSimplifyHasLessWayPoints() {
.post(getEndPointPath() + "/{profile}/geojson")
.then().log().all()
.assertThat()
.body("features[0].geometry.coordinates.size()", is(34))
.body("features[0].geometry.coordinates.size()", is(299))
.statusCode(200);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,9 +97,6 @@ public RoutingRequest convertRouteRequest(RouteRequest request) throws StatusCo
if (request.hasExtraInfo() && request.getSimplifyGeometry()) {
throw new IncompatibleParameterException(RoutingErrorCodes.INCOMPATIBLE_PARAMETERS, RouteRequest.PARAM_SIMPLIFY_GEOMETRY, "true", RouteRequest.PARAM_EXTRA_INFO, "*");
}
if (request.getCoordinates().size() > 2 && request.getSimplifyGeometry()) {
throw new IncompatibleParameterException(RoutingErrorCodes.INCOMPATIBLE_PARAMETERS, RouteRequest.PARAM_SIMPLIFY_GEOMETRY, "true", RouteRequest.PARAM_COORDINATES, "count > 2");
}
}

if (request.hasSkipSegments()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,12 @@ private RouteResult createInitialRouteResult (RoutingRequest request, List<Route

result.addExtras(request, extras);

int allPointsSize = 0;
for (GHResponse resp : responses) {
allPointsSize =+ resp.getBest().getPoints().size();
};
PointList pointsToAdd = new PointList(allPointsSize, false);

if (request.getSkipSegments() != null && !request.getSkipSegments().isEmpty()) {
result.addWarning(new RouteWarning(RouteWarning.SKIPPED_SEGMENTS));
}
Expand All @@ -83,8 +89,8 @@ RouteResult createMergedRouteResultFromBestPaths(List<GHResponse> responses, Rou
throw new InternalServerException(RoutingErrorCodes.UNKNOWN, String.format("Unable to find a route between points %d (%s) and %d (%s)", ri, FormatUtility.formatCoordinate(request.getCoordinates()[ri]), ri + 1, FormatUtility.formatCoordinate(request.getCoordinates()[ri + 1])));

PathWrapper path = response.getBest();
pointsToAdd.add(path.getPoints());

result.addPointlist(path.getPoints());
if (request.getIncludeGeometry()) {
result.addPointsToGeometry(path.getPoints(), ri > 0, request.getIncludeElevation());
result.addWayPointIndex(result.getGeometry().length - 1);
Expand All @@ -93,6 +99,7 @@ RouteResult createMergedRouteResultFromBestPaths(List<GHResponse> responses, Rou
result.addSegment(createRouteSegment(path, request, getNextResponseFirstStepPoints(responses, ri)));
}

result.addPointlist(pointsToAdd);
result.calculateRouteSummary(request);
if (!request.getIncludeGeometry() || !request.getIncludeInstructions()) {
result.resetSegments();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -180,8 +180,6 @@ public static RoutingRequest parseFromRequestParams(HttpServletRequest request)

value = request.getParameter("geometry_simplify");
if (!Helper.isEmpty(value))
if (req.getCoordinates().length > 2 )
throw new IncompatibleParameterException(RoutingErrorCodes.INCOMPATIBLE_PARAMETERS, "geometry_simplify", "true", "coordinates", "count > 2");
req.setGeometrySimplify(Boolean.parseBoolean(value));

value = request.getParameter("instructions");
Expand Down

0 comments on commit b3b747a

Please sign in to comment.