diff --git a/CHANGELOG.md b/CHANGELOG.md index 628d6c5f97..91347d4894 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -40,6 +40,7 @@ RELEASING: ### Fixed - do not enforce a time-dependent routing algorithm unless the weighting requires it ([#1865](https://github.com/GIScience/openrouteservice/pull/1865)) - failing queries that combined departure/arrival parameters with avoid polygons ([#1871](https://github.com/GIScience/openrouteservice/pull/1871)) +- matrix limit ignored for explicit 'all' value in sources or destinations([#1875](https://github.com/GIScience/openrouteservice/pull/1875)) ## [8.2.0] - 2024-10-09 ### Added diff --git a/ors-api/src/main/java/org/heigit/ors/api/services/MatrixService.java b/ors-api/src/main/java/org/heigit/ors/api/services/MatrixService.java index 3b5f6dde84..9f059d6741 100644 --- a/ors-api/src/main/java/org/heigit/ors/api/services/MatrixService.java +++ b/ors-api/src/main/java/org/heigit/ors/api/services/MatrixService.java @@ -23,6 +23,7 @@ import java.util.ArrayList; import java.util.List; +import java.util.Objects; import static org.heigit.ors.api.requests.matrix.MatrixRequest.isFlexibleMode; @@ -55,8 +56,10 @@ public org.heigit.ors.matrix.MatrixRequest convertMatrixRequest(MatrixRequest ma endpointsProperties.getMatrix().getMaximumVisitedNodes(), endpointsProperties.getMatrix().getUTurnCost()); - int numberOfSources = matrixRequest.getSources() == null ? matrixRequest.getLocations().size() : matrixRequest.getSources().length; - int numberODestinations = matrixRequest.getDestinations() == null ? matrixRequest.getLocations().size() : matrixRequest.getDestinations().length; + String[] sources = matrixRequest.getSources(); + int numberOfSources = sources == null || Objects.equals(sources[0], "all") ? matrixRequest.getLocations().size() : sources.length; + String[] destinations = matrixRequest.getDestinations(); + int numberODestinations = destinations == null || Objects.equals(destinations[0], "all") ? matrixRequest.getLocations().size() : destinations.length; Coordinate[] locations = convertLocations(matrixRequest.getLocations(), numberOfSources * numberODestinations, endpointsProperties); coreRequest.setProfileType(convertToMatrixProfileType(matrixRequest.getProfile())); diff --git a/ors-api/src/test/java/org/heigit/ors/apitests/matrix/ParamsTest.java b/ors-api/src/test/java/org/heigit/ors/apitests/matrix/ParamsTest.java index ea2ca3104d..e780cb9fcd 100644 --- a/ors-api/src/test/java/org/heigit/ors/apitests/matrix/ParamsTest.java +++ b/ors-api/src/test/java/org/heigit/ors/apitests/matrix/ParamsTest.java @@ -320,6 +320,26 @@ void expect4006004() { .statusCode(400); } + @Test + void expect4006004AllAll() { + + JSONObject body = new JSONObject(); + body.put("locations", getParameter("maximumLocations")); + body.put("sources", getParameter("sourcesAll")); + body.put("destinations", getParameter("destinationsAll")); + + given() + .headers(jsonContent) + .pathParam("profile", getParameter("carProfile")) + .body(body.toString()) + .when() + .post(getEndPointPath() + "/{profile}/json") + .then() + .assertThat() + .body("error.code", Matchers.is(MatrixErrorCodes.PARAMETER_VALUE_EXCEEDS_MAXIMUM)) + .statusCode(400); + } + @Test void expectResolveLocations() { JSONObject body = new JSONObject();