sis-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From desruisse...@apache.org
Subject [sis] 01/03: Add a GridGeometry.UNDEFINED constant and clarify some javadoc.
Date Sat, 05 Jan 2019 17:11:40 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

commit d41541250125cfb65fbec1fb1b7f924da0dce027
Author: Martin Desruisseaux <martin.desruisseaux@geomatys.com>
AuthorDate: Sat Jan 5 11:20:37 2019 +0100

    Add a GridGeometry.UNDEFINED constant and clarify some javadoc.
---
 .../org/apache/sis/coverage/grid/GridExtent.java   |  2 +-
 .../org/apache/sis/coverage/grid/GridGeometry.java | 27 +++++++++++++++++++---
 .../sis/internal/storage/AbstractGridResource.java |  7 +++---
 3 files changed, 29 insertions(+), 7 deletions(-)

diff --git a/core/sis-raster/src/main/java/org/apache/sis/coverage/grid/GridExtent.java b/core/sis-raster/src/main/java/org/apache/sis/coverage/grid/GridExtent.java
index 89b89d1..c0b130d 100644
--- a/core/sis-raster/src/main/java/org/apache/sis/coverage/grid/GridExtent.java
+++ b/core/sis-raster/src/main/java/org/apache/sis/coverage/grid/GridExtent.java
@@ -783,7 +783,7 @@ public class GridExtent implements Serializable {
      * Returns a grid envelope that encompass only some dimensions of this grid envelope.
      * This method copies the specified dimensions of this grid envelope into a new grid
envelope.
      * The given dimensions must be in strictly ascending order without duplicated values.
-     * The dimension of the sub grid envelope will be {@code dimensions.length}.
+     * The number of dimensions of the sub grid envelope will be {@code dimensions.length}.
      *
      * <p>This method performs a <cite>dimensionality reduction</cite>
and can be used as the
      * converse of {@link #append(DimensionNameType, long, long, boolean)}.
diff --git a/core/sis-raster/src/main/java/org/apache/sis/coverage/grid/GridGeometry.java
b/core/sis-raster/src/main/java/org/apache/sis/coverage/grid/GridGeometry.java
index 9a66bc0..c93cb85 100644
--- a/core/sis-raster/src/main/java/org/apache/sis/coverage/grid/GridGeometry.java
+++ b/core/sis-raster/src/main/java/org/apache/sis/coverage/grid/GridGeometry.java
@@ -203,6 +203,25 @@ public class GridGeometry implements Serializable {
     private final long nonLinears;
 
     /**
+     * An "empty" grid geometry with no value defined. All getter methods invoked on this
instance will cause
+     * {@link IncompleteGridGeometryException} to be thrown. This instance can be used as
a place-holder when
+     * the grid geometry can not be obtained.
+     */
+    public static final GridGeometry UNDEFINED = new GridGeometry();
+
+    /**
+     * Constructor for {@link #UNDEFINED} singleton only.
+     */
+    private GridGeometry() {
+        extent      = null;
+        gridToCRS   = null;
+        cornerToCRS = null;
+        envelope    = null;
+        resolution  = null;
+        nonLinears  = 0;
+    }
+
+    /**
      * Creates a new grid geometry with the same values than the given grid geometry.
      * This is a copy constructor for subclasses.
      *
@@ -1097,10 +1116,12 @@ public class GridGeometry implements Serializable {
     }
 
     /**
-     * Returns a grid geometry that encompass only some dimensions of this grid geometry.
-     * This method copies the specified dimensions of this grid geometry into a new grid
geometry.
+     * Returns a grid geometry that encompass only some dimensions of the grid extent.
+     * This method copies the specified dimensions into a new grid geometry.
+     * The selection is applied on {@linkplain #getExtent() grid extent} dimensions;
+     * they are not necessarily the same than the {@linkplain #getEnvelope() envelope} dimensions.
      * The given dimensions must be in strictly ascending order without duplicated values.
-     * The dimension of the sub grid grid geometry will be {@code dimensions.length}.
+     * The number of dimensions of the sub grid geometry will be {@code dimensions.length}.
      *
      * <p>This method performs a <cite>dimensionality reduction</cite>.
      * This method can not be used for changing dimension order.</p>
diff --git a/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/AbstractGridResource.java
b/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/AbstractGridResource.java
index a74ad5d..5813803 100644
--- a/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/AbstractGridResource.java
+++ b/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/AbstractGridResource.java
@@ -95,15 +95,16 @@ public abstract class AbstractGridResource extends AbstractResource implements
G
      * but does not verify if there is duplicated indices since such duplication is allowed.
      *
      * @param  numSampleDimensions  number of sample dimensions.
-     * @param  range                the {@code range} argument given by the user.
-     * @return the 0-based indices of ranges to use. May be the given {@code range} argument,
or a sequence
+     * @param  range  the {@code range} argument given by the user. May be null or empty.
+     * @return the 0-based indices of ranges to use. May be a copy of the given {@code range}
argument or a sequence
      *         from 0 to {@code numSampleDimensions} exclusive if {@code range} was {@code
null} or empty.
      */
-    protected final int[] validateRangeArgument(final int numSampleDimensions, final int[]
range) {
+    protected final int[] validateRangeArgument(final int numSampleDimensions, int[] range)
{
         ArgumentChecks.ensureStrictlyPositive("numSampleDimensions", numSampleDimensions);
         if (range == null || range.length == 0) {
             return ArraysExt.sequence(0, numSampleDimensions);
         }
+        range = range.clone();
         for (int i=0; i<range.length; i++) {
             final int r = range[i];
             if (r < 0 || r >= numSampleDimensions) {


Mime
View raw message