sis-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From desruisse...@apache.org
Subject [sis] 02/03: More reliable implementation of GridGeometry.getDimension().
Date Tue, 29 Jan 2019 18:52:13 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 2472183bb341ce64a9edf0229deefc11b62d50a6
Author: Martin Desruisseaux <martin.desruisseaux@geomatys.com>
AuthorDate: Tue Jan 29 12:33:57 2019 +0100

    More reliable implementation of GridGeometry.getDimension().
---
 .../java/org/apache/sis/coverage/grid/GridExtent.java |  4 +++-
 .../org/apache/sis/coverage/grid/GridGeometry.java    | 19 +++++++++++--------
 2 files changed, 14 insertions(+), 9 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 0787073..2b59b37 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
@@ -500,6 +500,8 @@ public class GridExtent implements Serializable {
      * Returns the number of dimensions.
      *
      * @return the number of dimensions.
+     *
+     * @see #reduce(int...)
      */
     public final int getDimension() {
         return coordinates.length >>> 1;
@@ -1011,7 +1013,7 @@ public class GridExtent implements Serializable {
     }
 
     /**
-     * Returns a hash value for this grid envelope. This value need not remain
+     * Returns a hash value for this grid envelope. This value needs not to remain
      * consistent between different implementations of the same class.
      *
      * @return a hash value for this grid envelope.
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 7f4241c..150499e 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
@@ -571,12 +571,15 @@ public class GridGeometry implements Serializable {
      * but not necessarily.
      *
      * @return the number of grid dimensions.
+     *
+     * @see #reduce(int...)
+     * @see GridExtent#getDimension()
      */
-    public int getDimension() {
-        if (gridToCRS != null) {
+    public final int getDimension() {
+        if (extent != null) {
+            return extent.getDimension();       // Most reliable source since that method
is final.
+        } else if (gridToCRS != null) {
             return gridToCRS.getSourceDimensions();
-        } else if (extent != null) {
-            return extent.getDimension();
         } else {
             /*
              * Last resort only since we have no guarantee that the envelope dimension is
the same
@@ -592,10 +595,10 @@ public class GridGeometry implements Serializable {
      * number of {@linkplain #getDimension() grid dimensions}, but not necessarily.
      */
     private int getTargetDimension() {
-        if (gridToCRS != null) {
+        if (envelope != null) {
+            return envelope.getDimension();     // Most reliable source since that class
is final.
+        } else if (gridToCRS != null) {
             return gridToCRS.getTargetDimensions();
-        } else if (envelope != null) {
-            return envelope.getDimension();
         } else {
             /*
              * Last resort only since we have no guarantee that the grid dimension is the
same
@@ -1031,7 +1034,7 @@ public class GridGeometry implements Serializable {
     }
 
     /**
-     * Returns a hash value for this grid geometry. This value need not remain
+     * Returns a hash value for this grid geometry. This value needs not to remain
      * consistent between different implementations of the same class.
      */
     @Override


Mime
View raw message