Bug fix: isoline lost when the values at both extremities is NaN.
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 698fc1b..2392046 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 @@
/**
* 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 @@
// 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 @@
* 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 8eaa48f..9f3e797 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 @@
/**
* 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();
}
}