Skip to content

GET /route endpoint does some additional checks compared to POST #1996

Closed

Description

@easbar

This stuff:

if (requestPoints.isEmpty())
throw new IllegalArgumentException("You have to pass at least one point");
if (enableElevation && !hasElevation)
throw new IllegalArgumentException("Elevation not supported!");
if (favoredHeadings.size() > 1 && favoredHeadings.size() != requestPoints.size())
throw new IllegalArgumentException("The number of 'heading' parameters must be <= 1 "
+ "or equal to the number of points (" + requestPoints.size() + ")");
// TODO these checks should be only necessary once in the core, e.g. pointHints problems are currently ignored for POST requests
if (pointHints.size() > 0 && pointHints.size() != requestPoints.size())
throw new IllegalArgumentException("If you pass " + POINT_HINT + ", you need to pass exactly one hint for every point, empty hints will be ignored");
if (curbsides.size() > 0 && curbsides.size() != requestPoints.size())
throw new IllegalArgumentException("If you pass " + CURBSIDE + ", you need to pass exactly one curbside for every point, empty curbsides will be ignored");
GHRequest request;
if (favoredHeadings.size() > 0) {
// if only one favored heading is specified take as start heading
if (favoredHeadings.size() == 1) {
List<Double> paddedHeadings = new ArrayList<>(Collections.nCopies(requestPoints.size(), Double.NaN));
paddedHeadings.set(0, favoredHeadings.get(0));
request = new GHRequest(requestPoints, paddedHeadings);
} else {
request = new GHRequest(requestPoints, favoredHeadings);
}
} else {
request = new GHRequest(requestPoints);
}

should probably also be done for POST requests, so we should rather move it into GraphHopper#calcPaths.

c.f. #1934 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions