Skip to content

Commit

Permalink
fix: matrix limit not respected (#1875)
Browse files Browse the repository at this point in the history
  • Loading branch information
aoles authored Oct 29, 2024
2 parents ad35cb3 + 57c755f commit 9cccb8b
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down

0 comments on commit 9cccb8b

Please sign in to comment.