From 084c82bd759cc9a3942e5dbd4cc876afaa940441 Mon Sep 17 00:00:00 2001 From: Thomas Date: Fri, 11 Feb 2022 11:53:02 +0100 Subject: [PATCH 1/3] look through all coordinates --- .../ie3/datamodel/io/source/IdCoordinateSource.java | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) 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..0d23ffcd6 100644 --- a/src/main/java/edu/ie3/datamodel/io/source/IdCoordinateSource.java +++ b/src/main/java/edu/ie3/datamodel/io/source/IdCoordinateSource.java @@ -57,7 +57,7 @@ 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()); } /** @@ -66,17 +66,17 @@ default List getNearestCoordinates(Point coordinate, int n) * * @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()) + (coordinates == null || coordinates.isEmpty()) ? getAllCoordinates() - : allCoordinates); + : coordinates); return sortedDistances.stream().limit(n).toList(); } } From 63dd533f932e70741c6a8d1c1dc4aaab1d769c9f Mon Sep 17 00:00:00 2001 From: Thomas Date: Fri, 11 Feb 2022 11:59:00 +0100 Subject: [PATCH 2/3] adjust changelog --- CHANGELOG.md | 1 + .../java/edu/ie3/datamodel/io/source/IdCoordinateSource.java | 4 +--- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5bba767da..2c7b9cf4a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -22,6 +22,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Fix JavaDoc creation - Create JavaDoc with java 17 instead of java 8 - Let JavDoc pass, if there are warnings **ATTENTION:** Should be removed, when JavaDoc is fixed! (cf. Issue [#494](https://github.com/ie3-institute/PowerSystemDataModel/issues/494)) +- - `IdCoordinateSource.getNearestCoordinates` did previously look through an empty set and now actually considers all coordinates [#529](https://github.com/ie3-institute/PowerSystemDataModel/issues/529) ### Changed - BREAKING: Transformer's no load susceptance needs to be zero or negative to pass model validation [#378](https://github.com/ie3-institute/PowerSystemDataModel/issues/378) 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 0d23ffcd6..db3d93131 100644 --- a/src/main/java/edu/ie3/datamodel/io/source/IdCoordinateSource.java +++ b/src/main/java/edu/ie3/datamodel/io/source/IdCoordinateSource.java @@ -74,9 +74,7 @@ default List getNearestCoordinates( SortedSet sortedDistances = GeoUtils.getCoordinateDistances( coordinate, - (coordinates == null || coordinates.isEmpty()) - ? getAllCoordinates() - : coordinates); + (coordinates == null || coordinates.isEmpty()) ? getAllCoordinates() : coordinates); return sortedDistances.stream().limit(n).toList(); } } From 443df9ae33c800625d56c09b8c20d93d2f13f22c Mon Sep 17 00:00:00 2001 From: Thomas Date: Fri, 11 Feb 2022 13:46:15 +0100 Subject: [PATCH 3/3] adapt documentation --- CHANGELOG.md | 1 - .../java/edu/ie3/datamodel/io/source/IdCoordinateSource.java | 4 ++-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2c7b9cf4a..5bba767da 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -22,7 +22,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Fix JavaDoc creation - Create JavaDoc with java 17 instead of java 8 - Let JavDoc pass, if there are warnings **ATTENTION:** Should be removed, when JavaDoc is fixed! (cf. Issue [#494](https://github.com/ie3-institute/PowerSystemDataModel/issues/494)) -- - `IdCoordinateSource.getNearestCoordinates` did previously look through an empty set and now actually considers all coordinates [#529](https://github.com/ie3-institute/PowerSystemDataModel/issues/529) ### Changed - BREAKING: Transformer's no load susceptance needs to be zero or negative to pass model validation [#378](https://github.com/ie3-institute/PowerSystemDataModel/issues/378) 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 db3d93131..e74b1a725 100644 --- a/src/main/java/edu/ie3/datamodel/io/source/IdCoordinateSource.java +++ b/src/main/java/edu/ie3/datamodel/io/source/IdCoordinateSource.java @@ -62,7 +62,7 @@ default List getNearestCoordinates(Point coordinate, int n) /** * 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 @@ -74,7 +74,7 @@ default List getNearestCoordinates( SortedSet sortedDistances = GeoUtils.getCoordinateDistances( coordinate, - (coordinates == null || coordinates.isEmpty()) ? getAllCoordinates() : coordinates); + (coordinates != null && !coordinates.isEmpty()) ? coordinates : getAllCoordinates()); return sortedDistances.stream().limit(n).toList(); } }