This is an automated email from the ASF dual-hosted git repository.

asf-gitbox-commits pushed a commit to branch geoapi-4.0
in repository https://gitbox.apache.org/repos/asf/sis.git

commit 0dc9b2d9745c03b14061a6fa41c563cc38d74690
Author: jsorel <[email protected]>
AuthorDate: Fri Nov 20 16:09:56 2026 +0100

    fix(DGGRS): fix iterator int cast for double values, several javadoc typo
---
 .../sis/referencing/dggs/GridConstraints.java      |  9 ++-
 .../sis/referencing/dggs/RefinementStrategy.java   |  4 +-
 .../main/org/apache/sis/referencing/dggs/Zone.java |  2 +-
 .../apache/sis/referencing/rs/CodeOperation.java   |  2 -
 .../org/apache/sis/referencing/rs/CompoundRS.java  | 11 ++--
 .../org/apache/sis/storage/rs/CodeIterator.java    | 17 ++++--
 .../org/apache/sis/storage/rs/CodedCoverage.java   |  4 --
 .../org/apache/sis/storage/rs/CodedGeometry.java   | 17 ++----
 .../apache/sis/storage/rs/CodeIteratorTest.java    | 68 ++++++++++++++++++++++
 9 files changed, 97 insertions(+), 37 deletions(-)

diff --git 
a/incubator/src/org.apache.sis.referencing.dggs/main/org/apache/sis/referencing/dggs/GridConstraints.java
 
b/incubator/src/org.apache.sis.referencing.dggs/main/org/apache/sis/referencing/dggs/GridConstraints.java
index 845702ed17..27c5a2a30e 100644
--- 
a/incubator/src/org.apache.sis.referencing.dggs/main/org/apache/sis/referencing/dggs/GridConstraints.java
+++ 
b/incubator/src/org.apache.sis.referencing.dggs/main/org/apache/sis/referencing/dggs/GridConstraints.java
@@ -50,14 +50,13 @@ public final class GridConstraints extends 
CodeList<GridConstraints> {
     public static final GridConstraints cellEquiAngular;
 
     /**
-     * ariation in distance from a cell’s representative position to all of 
it’s neighboring cell’s representative
+     * Variation in distance from a cell’s representative position to all of 
it’s neighboring cell’s representative
      * positions in each DiscreteGlobalGrid is minimized.
      */
     public static final GridConstraints cellEquiDistant;
 
     /**
-     * Each parent cell of dimension greater than 2 has a child cell for which 
the cell⇐zone.representativePosition
-     * lies on each of the parent’s faces (two-Dimensional topological 
boundary element)
+     * Variation in interior size between all cells in each DiscreteGlobalGrid 
is minimized.
      */
     public static final GridConstraints cellEquiSized;
 
@@ -103,7 +102,7 @@ public final class GridConstraints extends 
CodeList<GridConstraints> {
     }
 
     /**
-     * Returns the sub zone order type that matches the given string, or 
returns a new one if none match it.
+     * Returns the grid constraint that matches the given string, or returns a 
new one if none match it.
      *
      * @param code the name of the code to fetch or to create.
      * @return a code matching the given name.
@@ -113,7 +112,7 @@ public final class GridConstraints extends 
CodeList<GridConstraints> {
     }
 
     /**
-     * Returns the sub zone order type that matches the given string, or 
returns a new one if none match it.
+     * Returns the grid constraint that matches the given string, or returns a 
new one if none match it.
      *
      * @param code the name of the code to fetch or to create.
      * @param description if not found set this description to the newly 
created instance
diff --git 
a/incubator/src/org.apache.sis.referencing.dggs/main/org/apache/sis/referencing/dggs/RefinementStrategy.java
 
b/incubator/src/org.apache.sis.referencing.dggs/main/org/apache/sis/referencing/dggs/RefinementStrategy.java
index 1496fd224d..3dd3b10e60 100644
--- 
a/incubator/src/org.apache.sis.referencing.dggs/main/org/apache/sis/referencing/dggs/RefinementStrategy.java
+++ 
b/incubator/src/org.apache.sis.referencing.dggs/main/org/apache/sis/referencing/dggs/RefinementStrategy.java
@@ -112,7 +112,7 @@ public final class RefinementStrategy extends 
CodeList<RefinementStrategy> {
     }
 
     /**
-     * Returns the sub zone order type that matches the given string, or 
returns a new one if none match it.
+     * Returns the refinement strategy that matches the given string, or 
returns a new one if none match it.
      *
      * @param code the name of the code to fetch or to create.
      * @return a code matching the given name.
@@ -122,7 +122,7 @@ public final class RefinementStrategy extends 
CodeList<RefinementStrategy> {
     }
 
     /**
-     * Returns the sub zone order type that matches the given string, or 
returns a new one if none match it.
+     * Returns the refinement strategy that matches the given string, or 
returns a new one if none match it.
      *
      * @param code the name of the code to fetch or to create.
      * @param description if not found set this description to the newly 
created instance
diff --git 
a/incubator/src/org.apache.sis.referencing.dggs/main/org/apache/sis/referencing/dggs/Zone.java
 
b/incubator/src/org.apache.sis.referencing.dggs/main/org/apache/sis/referencing/dggs/Zone.java
index ccfedd76e6..1568d0b22b 100644
--- 
a/incubator/src/org.apache.sis.referencing.dggs/main/org/apache/sis/referencing/dggs/Zone.java
+++ 
b/incubator/src/org.apache.sis.referencing.dggs/main/org/apache/sis/referencing/dggs/Zone.java
@@ -186,7 +186,7 @@ public interface Zone extends Location, Comparable<Zone> {
      * They must be of different level and one must be a child of the other.
      *
      * @param zone not null
-     * @return true if zones are siblings
+     * @return true if one zone is an ancestor of the other
      */
     boolean overlaps(Object zone);
 
diff --git 
a/incubator/src/org.apache.sis.referencing.dggs/main/org/apache/sis/referencing/rs/CodeOperation.java
 
b/incubator/src/org.apache.sis.referencing.dggs/main/org/apache/sis/referencing/rs/CodeOperation.java
index 6578ac62a6..be57378d33 100644
--- 
a/incubator/src/org.apache.sis.referencing.dggs/main/org/apache/sis/referencing/rs/CodeOperation.java
+++ 
b/incubator/src/org.apache.sis.referencing.dggs/main/org/apache/sis/referencing/rs/CodeOperation.java
@@ -51,8 +51,6 @@ public interface CodeOperation extends IdentifiedObject {
      * Returns the <abbr>RS</abbr> to which codes are changed.
      *
      * @return the <abbr>RS</abbr> to which codes are changed.
-     *
-     * @see #getTargetEpoch()
      */
     ReferenceSystem getTargetRS();
 
diff --git 
a/incubator/src/org.apache.sis.referencing.dggs/main/org/apache/sis/referencing/rs/CompoundRS.java
 
b/incubator/src/org.apache.sis.referencing.dggs/main/org/apache/sis/referencing/rs/CompoundRS.java
index 31575624bb..fa2855768b 100644
--- 
a/incubator/src/org.apache.sis.referencing.dggs/main/org/apache/sis/referencing/rs/CompoundRS.java
+++ 
b/incubator/src/org.apache.sis.referencing.dggs/main/org/apache/sis/referencing/rs/CompoundRS.java
@@ -57,7 +57,7 @@ public final class CompoundRS implements ReferenceSystem {
         }
 
         if (name == null) {
-            final StringBuilder sb = new StringBuilder("CompundLS [");
+            final StringBuilder sb = new StringBuilder("CompoundRS [");
             for (int i = 0, n = rss.size(); i < n; i++) {
                 final ReferenceSystem cdt = rss.get(i);
                 if (i != 0) sb.append(',');
@@ -109,13 +109,10 @@ public final class CompoundRS implements ReferenceSystem {
     }
 
     /**
-     * Returns the ordered list of <abbr>CRS</abbr> components, none of which 
itself compound.
-     * If this compound <abbr>CRS</abbr> contains nested compound 
<abbr>CRS</abbr> components,
-     * then those components are flattened recursively in a sequence of {@link 
SingleCRS} objects.
+     * Returns the ordered list of <abbr>RS</abbr> components, none of which 
itself compound.
+     * Nested compound <abbr>RS</abbr> and compound <abbr>CRS</abbr> 
components are flattened recursively.
      *
-     * @return the ordered list of components of this compound 
<abbr>CRS</abbr>, none of which itself compound.
-     *
-     * @since SIS 3.1
+     * @return the ordered list of components of this compound 
<abbr>RS</abbr>, none of which itself compound.
      */
     public List<ReferenceSystem> getSingleComponents() {
         var singles = new ArrayList<ReferenceSystem>(5);
diff --git 
a/incubator/src/org.apache.sis.referencing.dggs/main/org/apache/sis/storage/rs/CodeIterator.java
 
b/incubator/src/org.apache.sis.referencing.dggs/main/org/apache/sis/storage/rs/CodeIterator.java
index 11f7e359e6..965bdafce9 100644
--- 
a/incubator/src/org.apache.sis.referencing.dggs/main/org/apache/sis/storage/rs/CodeIterator.java
+++ 
b/incubator/src/org.apache.sis.referencing.dggs/main/org/apache/sis/storage/rs/CodeIterator.java
@@ -85,8 +85,10 @@ public interface CodeIterator {
     public abstract double getSampleDouble(int band);
 
     /**
-     * Get cell values..
+     * Get cell values.
      *
+     * @param dest array where to store the values, or {@code null} for a new 
array.
+     *        Its length must be at least {@link #getNumBands()}.
      * @return all band values
      */
     default int[] getCell(int[] dest) {
@@ -97,25 +99,30 @@ public interface CodeIterator {
     }
 
     /**
-     * Get cell values..
+     * Get cell values.
      *
+     * @param dest array where to store the values, or {@code null} for a new 
array.
+     *        Its length must be at least {@link #getNumBands()}.
      * @return all band values
      */
     default float[] getCell(float[] dest) {
         final double[] cell = getCell((double[]) null);
         if (dest == null) dest = new float[cell.length];
-        for (int i = 0; i < cell.length; i++) dest[i] = (int) cell[i];
+        for (int i = 0; i < cell.length; i++) dest[i] = (float) cell[i];
         return dest;
     }
 
     /**
      * Get cell values.
      *
+     * @param dest array where to store the values, or {@code null} for a new 
array.
+     *        Its length must be at least {@link #getNumBands()}.
      * @return all band values
      */
     default double[] getCell(double[] dest) {
-        if (dest == null) dest = new double[getNumBands()];
-        for (int i = 0; i < dest.length; i++) dest[i] = getSampleDouble(i);
+        final int numBands = getNumBands();
+        if (dest == null) dest = new double[numBands];
+        for (int i = 0; i < numBands; i++) dest[i] = getSampleDouble(i);
         return dest;
     }
 
diff --git 
a/incubator/src/org.apache.sis.referencing.dggs/main/org/apache/sis/storage/rs/CodedCoverage.java
 
b/incubator/src/org.apache.sis.referencing.dggs/main/org/apache/sis/storage/rs/CodedCoverage.java
index 7067e6e733..5b5fa16fb3 100644
--- 
a/incubator/src/org.apache.sis.referencing.dggs/main/org/apache/sis/storage/rs/CodedCoverage.java
+++ 
b/incubator/src/org.apache.sis.referencing.dggs/main/org/apache/sis/storage/rs/CodedCoverage.java
@@ -118,8 +118,6 @@ public abstract class CodedCoverage extends 
BandedCoverageExt {
          * or if automatic wraparound is not supported.
          *
          * @return {@code true} if this evaluator may wraparound coordinates 
that are outside the coverage.
-         *
-         * @since SIS 1.3
          */
         boolean isWraparoundEnabled();
 
@@ -131,8 +129,6 @@ public abstract class CodedCoverage extends 
BandedCoverageExt {
          * multiple of 360°.
          *
          * @param  allow  whether to allow wraparound of coordinates that are 
outside the coverage.
-         *
-         * @since SIS 1.3
          */
         void setWraparoundEnabled(final boolean allow);
 
diff --git 
a/incubator/src/org.apache.sis.referencing.dggs/main/org/apache/sis/storage/rs/CodedGeometry.java
 
b/incubator/src/org.apache.sis.referencing.dggs/main/org/apache/sis/storage/rs/CodedGeometry.java
index 221cd7d88f..1cb85fab52 100644
--- 
a/incubator/src/org.apache.sis.referencing.dggs/main/org/apache/sis/storage/rs/CodedGeometry.java
+++ 
b/incubator/src/org.apache.sis.referencing.dggs/main/org/apache/sis/storage/rs/CodedGeometry.java
@@ -29,8 +29,6 @@ import org.opengis.referencing.operation.TransformException;
 import org.opengis.util.FactoryException;
 import org.apache.sis.coverage.grid.GridExtent;
 import org.apache.sis.coverage.grid.GridGeometry;
-import org.apache.sis.coverage.grid.IncompleteGridGeometryException;
-import org.apache.sis.coverage.grid.PixelInCell;
 import org.apache.sis.geometry.Envelopes;
 import org.apache.sis.referencing.dggs.DiscreteGlobalGridReferenceSystem;
 import org.apache.sis.referencing.rs.ReferenceSystems;
@@ -66,7 +64,7 @@ public class CodedGeometry {
      * A bitmask to specify the validity of the <q>grid to RS</q> transform.
      *
      * @see #isDefined(int)
-     * @see #getGridToRS(PixelInCell)
+     * @see #getGridToRS()
      */
     public static final int GRID_TO_RS = 4;
 
@@ -108,7 +106,7 @@ public class CodedGeometry {
     /**
      * Returns the ReferenceSystem.
      *
-     * @return ReferenceSystem, never null
+     * @return ReferenceSystem, or {@code null} if undefined
      */
     public ReferenceSystem getReferenceSystem() {
         return rs;
@@ -255,19 +253,16 @@ public class CodedGeometry {
 
     /**
      * Returns {@code true} if all the properties specified by the argument 
are set.
-     * If this method returns {@code true}, then invoking the corresponding 
getter
-     * methods will not throw {@link IncompleteGridGeometryException}.
+     * If this method returns {@code true}, then the corresponding getter 
methods will not return {@code null}.
      *
-     * @param  bitmask  any combination of {@link #RS}, {@link #ENVELOPE}, 
{@link #EXTENT},
-     *         {@link #GRID_TO_RS} and derived bit masks.
-     * @return {@code true} if all specified properties are defined (i.e. 
invoking the
-     *         corresponding getter methods will not throw {@link 
IncompleteGridGeometryException}).
+     * @param  bitmask  any combination of {@link #RS}, {@link #EXTENT}, 
{@link #GRID_TO_RS} and {@link #GEOGRAPHIC_EXTENT}.
+     * @return {@code true} if all specified properties are defined.
      * @throws IllegalArgumentException if the specified bitmask is not a 
combination of known masks.
      *
      * @see #getReferenceSystem()
-     * @see #getEnvelope()
      * @see #getExtent()
      * @see #getGridToRS()
+     * @see #getGeographicExtent()
      */
     public boolean isDefined(final int bitmask) {
         if ((bitmask & ~(RS | EXTENT | GRID_TO_RS | GEOGRAPHIC_EXTENT)) != 0) {
diff --git 
a/incubator/src/org.apache.sis.referencing.dggs/test/org/apache/sis/storage/rs/CodeIteratorTest.java
 
b/incubator/src/org.apache.sis.referencing.dggs/test/org/apache/sis/storage/rs/CodeIteratorTest.java
new file mode 100644
index 0000000000..cc045dd231
--- /dev/null
+++ 
b/incubator/src/org.apache.sis.referencing.dggs/test/org/apache/sis/storage/rs/CodeIteratorTest.java
@@ -0,0 +1,68 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.sis.storage.rs;
+
+// Test dependencies
+import static org.junit.jupiter.api.Assertions.*;
+import org.junit.jupiter.api.Test;
+
+
+/**
+ * Tests the default methods of {@link CodeIterator}.
+ *
+ * @author Johann Sorel (Geomatys)
+ */
+public class CodeIteratorTest {
+
+    /**
+     * Sample values of the single cell of {@link SingleCellIterator}.
+     */
+    private static final double[] SAMPLES = {1.5, -2.25, 3.75};
+
+    /**
+     * An iterator over a single cell. Band indices outside {@link #SAMPLES} 
throw an exception.
+     */
+    private static final class SingleCellIterator implements CodeIterator {
+        @Override public int[]   getPosition()             {return new int[1];}
+        @Override public void    moveTo(int[] zid)         {}
+        @Override public boolean next()                    {return false;}
+        @Override public int     getNumBands()             {return 
SAMPLES.length;}
+        @Override public double  getSampleDouble(int band) {return 
SAMPLES[band];}
+        @Override public void    rewind()                  {}
+    }
+
+    /**
+     * Tests that {@link CodeIterator#getCell(float[])} keeps the fraction 
digits.
+     */
+    @Test
+    public void testGetCellFloat() {
+        final float[] cell = new SingleCellIterator().getCell((float[]) null);
+        assertArrayEquals(new float[] {1.5f, -2.25f, 3.75f}, cell);
+    }
+
+    /**
+     * Tests {@link CodeIterator#getCell(double[])} with a buffer longer than 
the number of bands.
+     * The extra elements shall be left unchanged.
+     */
+    @Test
+    public void testGetCellDoubleInLargerBuffer() {
+        final double[] buffer = {Double.NaN, Double.NaN, Double.NaN, 7, 8};
+        final double[] cell = new SingleCellIterator().getCell(buffer);
+        assertSame(buffer, cell);
+        assertArrayEquals(new double[] {1.5, -2.25, 3.75, 7, 8}, cell);
+    }
+}

Reply via email to