Skip to content

Commit

Permalink
ENH: NAV-141 - Include check if source and target coordinates are ide…
Browse files Browse the repository at this point in the history
…ntical.
  • Loading branch information
clukas1 committed Aug 22, 2024
1 parent 19c55ee commit 9f4bd0d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ public List<Connection> getConnections(@RequestParam(required = false) String so
} else if (targetStop != null) {
return map(service.getConnections(sourceCoordinate, targetStop, dateTime, map(timeType), config));
} else {
RoutingRequestValidator.validateCoordinates(sourceCoordinate, targetCoordinate);
return map(service.getConnections(sourceCoordinate, targetCoordinate, dateTime, map(timeType), config));
}
} catch (ConnectionRoutingException e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,4 +100,11 @@ public static void validateStops(String sourceStopId, String targetStopId) {
}
}

public static void validateCoordinates(GeoCoordinate sourceCoordinate, GeoCoordinate targetCoordinate) {
if (sourceCoordinate.equals(targetCoordinate)) {
throw new ResponseStatusException(HttpStatus.BAD_REQUEST,
"The source and target coordinates cannot be the same. Please provide different coordinates for the source and target.");
}
}

}

0 comments on commit 9f4bd0d

Please sign in to comment.