Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,24 @@

public class MultiplePointsNotFoundException extends RuntimeException {

public enum IssueLocation{
ORIGIN,DESTINATION, SIMPLE_ROUTE
}

private final IntArrayList pointsNotFound;

MultiplePointsNotFoundException(IntArrayList pointsNotFound) {
private final IssueLocation issueLocation;

MultiplePointsNotFoundException(IssueLocation issueLocation, IntArrayList pointsNotFound) {
this.issueLocation = issueLocation;
this.pointsNotFound = pointsNotFound;
}

public IntArrayList getPointsNotFound() {
return pointsNotFound;
}

public IssueLocation getIssueLocation() {
return issueLocation;
}
}
9 changes: 6 additions & 3 deletions core/src/main/java/com/graphhopper/routing/ViaRouting.java
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public class ViaRouting {

public static MatrixSnapResult lookupMatrix(boolean failFast, EncodedValueLookup lookup, List<GHPoint> points, EdgeFilter snapFilter,
LocationIndex locationIndex, List<String> snapPreventions, List<String> pointHints,
DirectedEdgeFilter directedSnapFilter, List<Double> headings) {
DirectedEdgeFilter directedSnapFilter, List<Double> headings, boolean isOrigins) {
if (points.size() < 1)
throw new IllegalArgumentException("At least 1 point have to be specified, but was:" + points.size());

Expand Down Expand Up @@ -93,7 +93,9 @@ public static MatrixSnapResult lookupMatrix(boolean failFast, EncodedValueLookup
}

if (!pointsNotFound.isEmpty() && failFast)
throw new MultiplePointsNotFoundException(pointsNotFound);
throw new MultiplePointsNotFoundException(isOrigins?
MultiplePointsNotFoundException.IssueLocation.ORIGIN:
MultiplePointsNotFoundException.IssueLocation.DESTINATION, pointsNotFound);

return new MatrixSnapResult(snaps,snapIndexes,pointsNotFound);

Expand Down Expand Up @@ -139,7 +141,8 @@ public static List<Snap> lookup(EncodedValueLookup lookup, List<GHPoint> points,
}

if (!pointsNotFound.isEmpty())
throw new MultiplePointsNotFoundException(pointsNotFound);
throw new MultiplePointsNotFoundException(
MultiplePointsNotFoundException.IssueLocation.SIMPLE_ROUTE, pointsNotFound);

return snaps;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,9 @@ public GHMatrixResponse matrix(GHMatrixRequest request) {
List<String> snapPreventions = new ArrayList<>();

MatrixSnapResult originsResult = ViaRouting.lookupMatrix(request.isFailFast(), encodingManager, request.getOrigins(), solver.createSnapFilter(), locationIndex,
snapPreventions, pointHints, directedEdgeFilter, headings);
snapPreventions, pointHints, directedEdgeFilter, headings, true);
MatrixSnapResult destinationsResult = ViaRouting.lookupMatrix(request.isFailFast(), encodingManager, request.getDestinations(), solver.createSnapFilter(), locationIndex,
snapPreventions, pointHints, directedEdgeFilter, headings);
snapPreventions, pointHints, directedEdgeFilter, headings, false);

List<Snap> allCorrectSnaps = new ArrayList<>(originsResult.snaps);
allCorrectSnaps.addAll(destinationsResult.snaps);
Expand Down