This is an automated email from the ASF dual-hosted git repository. desruisseaux pushed a commit to branch geoapi-4.0 in repository https://gitbox.apache.org/repos/asf/sis.git
The following commit(s) were added to refs/heads/geoapi-4.0 by this push: new 8453059bf2 Bug fix: isoline lost when the values at both extremities is NaN. 8453059bf2 is described below commit 8453059bf2bd0af4cadfd76338cc423691e7886e Author: Martin Desruisseaux <martin.desruisse...@geomatys.com> AuthorDate: Mon Aug 15 16:49:05 2022 +0200 Bug fix: isoline lost when the values at both extremities is NaN. --- .../org/apache/sis/internal/processing/isoline/Fragments.java | 9 ++++++--- .../java/org/apache/sis/internal/processing/isoline/Result.java | 9 ++++++--- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/core/sis-feature/src/main/java/org/apache/sis/internal/processing/isoline/Fragments.java b/core/sis-feature/src/main/java/org/apache/sis/internal/processing/isoline/Fragments.java index 698fc1b247..2392046df1 100644 --- a/core/sis-feature/src/main/java/org/apache/sis/internal/processing/isoline/Fragments.java +++ b/core/sis-feature/src/main/java/org/apache/sis/internal/processing/isoline/Fragments.java @@ -178,8 +178,9 @@ final class Fragments extends ArrayList<double[]> { /** * Associates this polyline to its two extremities in the given map. If other polylines already exist * for one or both extremities, then this polyline will be merged with previously existing polylines. - * This method returns {@code true} if the polyline has been closed, in which case caller should store - * the coordinates in {@link Tracer.Level#path} immediately. + * This method returns {@code true} if caller should store the coordinates in {@link Tracer.Level#path} + * immediately. It may be either because the polyline has been closed as a polygon, or because the two + * extremities contains NaN values in which case the polylines are not anymore in {@code partialPaths}. * * @param partialPaths where to add or merge polylines. * @return {@code true} if this polyline became a closed polygon as a result of merge operation. @@ -197,7 +198,7 @@ final class Fragments extends ArrayList<double[]> { // Intentionally replace previous values. if (firstPoint != null) partialPaths.put(firstPoint, this); if (lastPoint != null) partialPaths.put(lastPoint, this); - return false; + return firstPoint == null && lastPoint == null; } } @@ -256,6 +257,8 @@ final class Fragments extends ArrayList<double[]> { * Returns the content of this list as an array of {@link PolylineBuffer} instances. * {@code PolylineBuffer} instances at even index should be written with their points in reverse order. * + * @return elements of this array as polylines. May contain null elements. + * * @see #writeTo(Joiner, PolylineBuffer[], boolean) */ final PolylineBuffer[] toPolylines() { diff --git a/core/sis-feature/src/main/java/org/apache/sis/internal/processing/isoline/Result.java b/core/sis-feature/src/main/java/org/apache/sis/internal/processing/isoline/Result.java index 8eaa48ffb4..9f3e797a36 100644 --- a/core/sis-feature/src/main/java/org/apache/sis/internal/processing/isoline/Result.java +++ b/core/sis-feature/src/main/java/org/apache/sis/internal/processing/isoline/Result.java @@ -78,21 +78,24 @@ final class Result extends AbstractList<NavigableMap<Double,Shape>> { /** * Returns the list length, which is the number of bands. */ - @Override public int size() { + @Override + public int size() { return isolines().length; } /** * Returns the isolines in the given band. */ - @Override public NavigableMap<Double,Shape> get(final int band) { + @Override + public NavigableMap<Double,Shape> get(final int band) { return isolines()[band]; } /** * Returns the list content as an array. */ - @Override public Object[] toArray() { + @Override + public Object[] toArray() { return isolines().clone(); } }