sis-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From desruisse...@apache.org
Subject [sis] branch geoapi-4.0 updated: Minor documentation updates. Addition of a more efficient `PixelIterator.getPosition(double[])` method.
Date Fri, 13 Mar 2020 10:13:38 GMT
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 97edb07  Minor documentation updates. Addition of a more efficient `PixelIterator.getPosition(double[])`
method.
97edb07 is described below

commit 97edb072a8d1e27e84b3aa22cced4df9dabba296
Author: Martin Desruisseaux <martin.desruisseaux@geomatys.com>
AuthorDate: Fri Mar 13 10:48:36 2020 +0100

    Minor documentation updates. Addition of a more efficient `PixelIterator.getPosition(double[])`
method.
---
 .../java/org/apache/sis/image/DefaultIterator.java | 17 +++++++++++++++--
 .../java/org/apache/sis/image/PixelIterator.java   | 22 ++++++++++++++++++++++
 .../main/java/org/apache/sis/referencing/CRS.java  | 19 ++++++++++++++-----
 .../org/apache/sis/internal/netcdf/Convention.java |  2 +-
 4 files changed, 52 insertions(+), 8 deletions(-)

diff --git a/core/sis-feature/src/main/java/org/apache/sis/image/DefaultIterator.java b/core/sis-feature/src/main/java/org/apache/sis/image/DefaultIterator.java
index d4f7b79..42dea65 100644
--- a/core/sis-feature/src/main/java/org/apache/sis/image/DefaultIterator.java
+++ b/core/sis-feature/src/main/java/org/apache/sis/image/DefaultIterator.java
@@ -50,7 +50,7 @@ import org.apache.sis.util.ArgumentChecks;
  *
  * @author  Rémi Maréchal (Geomatys)
  * @author  Martin Desruisseaux (Geomatys)
- * @version 1.0
+ * @version 1.1
  * @since   1.0
  * @module
  *
@@ -160,7 +160,7 @@ class DefaultIterator extends WritablePixelIterator {
 
     /**
      * Returns the column (x) and row (y) indices of the current pixel.
-     * This implementation {@link #x} and {@link #tileY} for determining if the iteration
is valid.
+     * This implementation checks {@link #x} and {@link #tileY} for determining if the iteration
is valid.
      *
      * @return column and row indices of current iterator position.
      * @throws IllegalStateException if this method is invoked before the first call to {@link
#next()}
@@ -180,6 +180,19 @@ class DefaultIterator extends WritablePixelIterator {
     }
 
     /**
+     * Stores the column (x) and row (y) indices of the current pixel.
+     */
+    @Override
+    public void getPosition(final double[] dest, final int offset) {
+        if (x >= lowerX && tileY < tileUpperY) {
+            dest[offset    ] = x;
+            dest[offset + 1] = y;
+        } else {
+            super.getPosition(dest, offset);        // Will cause exception to be thrown.
+        }
+    }
+
+    /**
      * Moves the pixel iterator to the given column (x) and row (y) indices.
      *
      * @param  px  the column index of the pixel to make current.
diff --git a/core/sis-feature/src/main/java/org/apache/sis/image/PixelIterator.java b/core/sis-feature/src/main/java/org/apache/sis/image/PixelIterator.java
index 5923ed8..5ea9d33 100644
--- a/core/sis-feature/src/main/java/org/apache/sis/image/PixelIterator.java
+++ b/core/sis-feature/src/main/java/org/apache/sis/image/PixelIterator.java
@@ -542,6 +542,28 @@ public abstract class PixelIterator {
     public abstract Point getPosition();
 
     /**
+     * Stores in the specified array the column (x) and row (y) indices of the current pixel.
+     * This method is equivalent to invoking {@link #getPosition()} and copying the (<var>x</var>,
<var>y</var>)
+     * coordinates in {@code dest[offset]} and {@code dest[offset + 1]} respectively.
+     *
+     * <div class="note"><b>API note:</b>
+     * an array of type {@code double[]} is used for allowing the coordinates to be converted
with
+     * {@link org.opengis.referencing.operation.MathTransform#transform(double[], int, double[],
int, int)}.
+     * A typical use case is to apply a {@linkplain org.apache.sis.coverage.grid.GridGeometry#getGridToCRS
+     * grid to CRS} transform.</div>
+     *
+     * @param  dest    the array where to store the (<var>x</var>, <var>y</var>)
pixel coordinates.
+     * @param  offset  the offset where to store the coordinates in the specified array.
+     *
+     * @since 1.1
+     */
+    public void getPosition(final double[] dest, final int offset) {
+        final Point pos = getPosition();
+        dest[offset    ] = pos.x;
+        dest[offset + 1] = pos.y;
+    }
+
+    /**
      * Moves the pixel iterator to the given column (x) and row (y) indices. After this method
invocation,
      * the iterator state is as if the {@link #next()} method has been invoked just before
to reach the
      * specified position.
diff --git a/core/sis-referencing/src/main/java/org/apache/sis/referencing/CRS.java b/core/sis-referencing/src/main/java/org/apache/sis/referencing/CRS.java
index be29463..4e2380c 100644
--- a/core/sis-referencing/src/main/java/org/apache/sis/referencing/CRS.java
+++ b/core/sis-referencing/src/main/java/org/apache/sis/referencing/CRS.java
@@ -187,6 +187,7 @@ public final class CRS extends Static {
      *   <tr><td>EPSG:5714</td> <td>{@link CommonCRS.Vertical#MEAN_SEA_LEVEL
MEAN_SEA_LEVEL}</td> <td>Vertical</td> <td>Mean Sea Level height</td></tr>
      * </table></blockquote>
      *
+     * <h4>URI forms</h4>
      * This method accepts also the URN and URL syntaxes.
      * For example the following codes are considered equivalent to {@code "EPSG:4326"}:
      * <ul>
@@ -216,10 +217,12 @@ public final class CRS extends Static {
      * {@linkplain org.apache.sis.referencing.cs.DefaultCartesianCS Cartesian coordinate
system} for creating a new
      * {@linkplain org.apache.sis.referencing.crs.DefaultProjectedCRS projected coordinate
reference system}.</p>
      *
-     * Note that the {@link IdentifiedObjects#lookupURN(IdentifiedObject, Citation)}
-     * method can be seen as a converse of this method.
+     * <div class="note"><b>Note:</b>
+     * The {@link IdentifiedObjects#lookupURN(IdentifiedObject, Citation)} method can be
seen
+     * as a converse of this method: from a CRS object, it tries to find a URN that describes
it.
      * More codes may also be supported depending on which extension modules are available.
-     * See for example the {@linkplain org.apache.sis.storage.gdal bindings to Proj.4 library}.
+     * See for example the {@linkplain org.apache.sis.storage.gdal bindings to PROJ library}.
+     * </div>
      *
      * @param  code  the authority code.
      * @return the Coordinate Reference System for the given authority code.
@@ -605,10 +608,16 @@ public final class CRS extends Static {
      * </ul>
      *
      * If the source and target CRS are equivalent, then this method returns an operation
backed by an
-     * {@linkplain org.apache.sis.referencing.operation.transform.AbstractMathTransform#isIdentity()
identity}
-     * transform. If there is no known operation between the given pair of CRS, then this
method throws an
+     * {@linkplain org.opengis.referencing.operation.MathTransform#isIdentity() identity}
transform.
+     * If there is no known operation between the given pair of CRS, then this method throws
an
      * {@link OperationNotFoundException}.
      *
+     * <p>Note that <code>CRS.findOperation(<var>B</var>, <var>A</var>,
<var>aoi</var>)</code> is not necessarily
+     * the exact converse of <code>CRS.findOperation(<var>A</var>, <var>B</var>,
<var>aoi</var>)</code>.
+     * Some deviations may exist for example because of different paths explored in the geodetic
database.
+     * For the inverse of an existing {@link CoordinateOperation}, using
+     * {@link org.opengis.referencing.operation.MathTransform#inverse()} is preferable.</p>
+     *
      * @param  sourceCRS       the CRS of source coordinates.
      * @param  targetCRS       the CRS of target coordinates.
      * @param  areaOfInterest  the area of interest, or {@code null} if none.
diff --git a/storage/sis-netcdf/src/main/java/org/apache/sis/internal/netcdf/Convention.java
b/storage/sis-netcdf/src/main/java/org/apache/sis/internal/netcdf/Convention.java
index 3858191..9208d35 100644
--- a/storage/sis-netcdf/src/main/java/org/apache/sis/internal/netcdf/Convention.java
+++ b/storage/sis-netcdf/src/main/java/org/apache/sis/internal/netcdf/Convention.java
@@ -97,7 +97,7 @@ public class Convention {
      * @see #validRange(Variable)
      */
     private static final String[] RANGE_ATTRIBUTES = {
-        "valid_range",      // Expected "reasonable" range for variable.
+        CDM.VALID_RANGE,    // Expected "reasonable" range for variable.
         "actual_range",     // Actual data range for variable.
         "valid_min",        // Fallback if "valid_range" is not specified.
         "valid_max"


Mime
View raw message