diff --git a/core/src/main/java/com/graphhopper/routing/MultiplePointsNotFoundException.java b/core/src/main/java/com/graphhopper/routing/MultiplePointsNotFoundException.java index 22d0de99672..a453a8b1973 100644 --- a/core/src/main/java/com/graphhopper/routing/MultiplePointsNotFoundException.java +++ b/core/src/main/java/com/graphhopper/routing/MultiplePointsNotFoundException.java @@ -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; + } } diff --git a/core/src/main/java/com/graphhopper/routing/ViaRouting.java b/core/src/main/java/com/graphhopper/routing/ViaRouting.java index b4339ffa881..de81ee027d9 100644 --- a/core/src/main/java/com/graphhopper/routing/ViaRouting.java +++ b/core/src/main/java/com/graphhopper/routing/ViaRouting.java @@ -53,7 +53,7 @@ public class ViaRouting { public static MatrixSnapResult lookupMatrix(boolean failFast, EncodedValueLookup lookup, List points, EdgeFilter snapFilter, LocationIndex locationIndex, List snapPreventions, List pointHints, - DirectedEdgeFilter directedSnapFilter, List headings) { + DirectedEdgeFilter directedSnapFilter, List headings, boolean isOrigins) { if (points.size() < 1) throw new IllegalArgumentException("At least 1 point have to be specified, but was:" + points.size()); @@ -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); @@ -139,7 +141,8 @@ public static List lookup(EncodedValueLookup lookup, List points, } if (!pointsNotFound.isEmpty()) - throw new MultiplePointsNotFoundException(pointsNotFound); + throw new MultiplePointsNotFoundException( + MultiplePointsNotFoundException.IssueLocation.SIMPLE_ROUTE, pointsNotFound); return snaps; } diff --git a/core/src/main/java/com/graphhopper/routing/matrix/RouterMatrix.java b/core/src/main/java/com/graphhopper/routing/matrix/RouterMatrix.java index c5f121c0629..3451c08411f 100644 --- a/core/src/main/java/com/graphhopper/routing/matrix/RouterMatrix.java +++ b/core/src/main/java/com/graphhopper/routing/matrix/RouterMatrix.java @@ -46,9 +46,9 @@ public GHMatrixResponse matrix(GHMatrixRequest request) { List 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 allCorrectSnaps = new ArrayList<>(originsResult.snaps); allCorrectSnaps.addAll(destinationsResult.snaps);