diff --git a/src/main/java/edu/ie3/datamodel/io/source/IdCoordinateSource.java b/src/main/java/edu/ie3/datamodel/io/source/IdCoordinateSource.java index c50c834ab..e74b1a725 100644 --- a/src/main/java/edu/ie3/datamodel/io/source/IdCoordinateSource.java +++ b/src/main/java/edu/ie3/datamodel/io/source/IdCoordinateSource.java @@ -57,26 +57,24 @@ public interface IdCoordinateSource extends DataSource { * @return the n nearest coordinates to the given point */ default List getNearestCoordinates(Point coordinate, int n) { - return getNearestCoordinates(coordinate, n, Collections.emptySet()); + return getNearestCoordinates(coordinate, n, getAllCoordinates()); } /** * Returns the nearest n coordinate points to the given coordinate from a given collection of - * points + * points. If the set is empty or null we look through all coordinates. * * @param coordinate the coordinate to look up the nearest neighbours for * @param n how many neighbours to look up - * @param allCoordinates the collection of points, ideally containing all available coordinates + * @param coordinates the collection of points * @return the n nearest coordinates to the given point */ default List getNearestCoordinates( - Point coordinate, int n, Collection allCoordinates) { + Point coordinate, int n, Collection coordinates) { SortedSet sortedDistances = GeoUtils.getCoordinateDistances( coordinate, - (allCoordinates == null || allCoordinates.isEmpty()) - ? getAllCoordinates() - : allCoordinates); + (coordinates != null && !coordinates.isEmpty()) ? coordinates : getAllCoordinates()); return sortedDistances.stream().limit(n).toList(); } }