sis-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From desruisse...@apache.org
Subject [sis] 01/02: Rename some getGridGeometry() methods as getGrid() for avoiding confusion with the "real" getGridGeometry() method.
Date Wed, 30 Jan 2019 19:45:37 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 5e9b7a9f15676cf6744cad7f5199b8814a15eca7
Author: Martin Desruisseaux <martin.desruisseaux@geomatys.com>
AuthorDate: Wed Jan 30 15:31:07 2019 +0100

    Rename some getGridGeometry() methods as getGrid() for avoiding confusion with the "real"
getGridGeometry() method.
---
 .../java/org/apache/sis/internal/netcdf/Decoder.java   |  2 +-
 .../main/java/org/apache/sis/internal/netcdf/Grid.java |  4 ++--
 .../java/org/apache/sis/internal/netcdf/Variable.java  |  2 +-
 .../sis/internal/netcdf/impl/ChannelDecoder.java       | 12 ++++++------
 .../org/apache/sis/internal/netcdf/impl/GridInfo.java  |  4 ++--
 .../apache/sis/internal/netcdf/impl/VariableInfo.java  | 18 +++++++++---------
 .../sis/internal/netcdf/ucar/DecoderWrapper.java       |  4 ++--
 .../sis/internal/netcdf/ucar/VariableWrapper.java      |  8 ++++----
 .../org/apache/sis/storage/netcdf/GridResource.java    |  6 +++---
 .../org/apache/sis/storage/netcdf/MetadataReader.java  |  9 ++++-----
 .../java/org/apache/sis/internal/netcdf/GridTest.java  |  8 ++++----
 11 files changed, 38 insertions(+), 39 deletions(-)

diff --git a/storage/sis-netcdf/src/main/java/org/apache/sis/internal/netcdf/Decoder.java
b/storage/sis-netcdf/src/main/java/org/apache/sis/internal/netcdf/Decoder.java
index aca6d33..23e6f48 100644
--- a/storage/sis-netcdf/src/main/java/org/apache/sis/internal/netcdf/Decoder.java
+++ b/storage/sis-netcdf/src/main/java/org/apache/sis/internal/netcdf/Decoder.java
@@ -282,7 +282,7 @@ public abstract class Decoder extends ReferencingFactoryContainer implements
Clo
      * @throws IOException if an I/O operation was necessary but failed.
      * @throws DataStoreException if a logical error occurred.
      */
-    public abstract Grid[] getGridGeometries() throws IOException, DataStoreException;
+    public abstract Grid[] getGrids() throws IOException, DataStoreException;
 
     /**
      * Returns the role of the given variable. In particular, this method shall return
diff --git a/storage/sis-netcdf/src/main/java/org/apache/sis/internal/netcdf/Grid.java b/storage/sis-netcdf/src/main/java/org/apache/sis/internal/netcdf/Grid.java
index 28585d3..6b8b9e2 100644
--- a/storage/sis-netcdf/src/main/java/org/apache/sis/internal/netcdf/Grid.java
+++ b/storage/sis-netcdf/src/main/java/org/apache/sis/internal/netcdf/Grid.java
@@ -49,7 +49,7 @@ import org.apache.sis.util.NullArgumentException;
  * @author  Martin Desruisseaux (Geomatys)
  * @version 1.0
  *
- * @see Decoder#getGridGeometries()
+ * @see Decoder#getGrids()
  *
  * @since 0.3
  * @module
@@ -281,7 +281,7 @@ public abstract class Grid extends NamedElement {
              * (the source) +1, and the number of rows is the number of dimensions in the
CRS (the target) +1.
              * The order of dimensions in the transform is the reverse of the netCDF axis
order.
              */
-            int lastSrcDim = getSourceDimensions();                         // Will be decremented
later, then keep final.
+            int lastSrcDim = getSourceDimensions();                         // Will be decremented
later, then kept final.
             int lastTgtDim = getTargetDimensions();
             final int[] deferred = new int[axes.length];                    // Indices of
axes that have been deferred.
             final List<MathTransform> nonLinears = new ArrayList<>(axes.length);
diff --git a/storage/sis-netcdf/src/main/java/org/apache/sis/internal/netcdf/Variable.java
b/storage/sis-netcdf/src/main/java/org/apache/sis/internal/netcdf/Variable.java
index 1528a11..6928e07 100644
--- a/storage/sis-netcdf/src/main/java/org/apache/sis/internal/netcdf/Variable.java
+++ b/storage/sis-netcdf/src/main/java/org/apache/sis/internal/netcdf/Variable.java
@@ -349,7 +349,7 @@ public abstract class Variable extends NamedElement {
      * @throws IOException if an error occurred while reading the data.
      * @throws DataStoreException if a logical error occurred.
      */
-    public abstract Grid getGridGeometry(Decoder decoder) throws IOException, DataStoreException;
+    public abstract Grid getGrid(Decoder decoder) throws IOException, DataStoreException;
 
     /**
      * Returns the names of the dimensions of this variable, in the order they are declared
in the netCDF file.
diff --git a/storage/sis-netcdf/src/main/java/org/apache/sis/internal/netcdf/impl/ChannelDecoder.java
b/storage/sis-netcdf/src/main/java/org/apache/sis/internal/netcdf/impl/ChannelDecoder.java
index 5e845ed..80c78f7 100644
--- a/storage/sis-netcdf/src/main/java/org/apache/sis/internal/netcdf/impl/ChannelDecoder.java
+++ b/storage/sis-netcdf/src/main/java/org/apache/sis/internal/netcdf/impl/ChannelDecoder.java
@@ -199,7 +199,7 @@ public final class ChannelDecoder extends Decoder {
     /**
      * The grid geometries, created when first needed.
      *
-     * @see #getGridGeometries()
+     * @see #getGrids()
      */
     private transient Grid[] gridGeometries;
 
@@ -889,7 +889,7 @@ public final class ChannelDecoder extends Decoder {
      */
     @Override
     @SuppressWarnings("ReturnOfCollectionOrArrayField")
-    public Grid[] getGridGeometries() {
+    public Grid[] getGrids() {
         if (gridGeometries == null) {
             /*
              * First, find all variables which are used as coordinate system axis. The keys
in the map are
@@ -960,13 +960,13 @@ nextVar:    for (final VariableInfo variable : variables) {
                  * from the "coordinates" attribute and axes inferred from variable names
matching dimension names, we
                  * are better to sort them.
                  */
-                GridInfo gridGeometry = new GridInfo(variable.dimensions,
+                GridInfo grid = new GridInfo(variable.dimensions,
                         axes.toArray(new VariableInfo[axes.size()]), mixedFlag == 3);
-                GridInfo existing = shared.putIfAbsent(gridGeometry, gridGeometry);
+                GridInfo existing = shared.putIfAbsent(grid, grid);
                 if (existing != null) {
-                    gridGeometry = existing;
+                    grid = existing;
                 }
-                variable.gridGeometry = gridGeometry;
+                variable.grid = grid;
             }
             gridGeometries = shared.values().toArray(new Grid[shared.size()]);
         }
diff --git a/storage/sis-netcdf/src/main/java/org/apache/sis/internal/netcdf/impl/GridInfo.java
b/storage/sis-netcdf/src/main/java/org/apache/sis/internal/netcdf/impl/GridInfo.java
index 8553a30..cff7588 100644
--- a/storage/sis-netcdf/src/main/java/org/apache/sis/internal/netcdf/impl/GridInfo.java
+++ b/storage/sis-netcdf/src/main/java/org/apache/sis/internal/netcdf/impl/GridInfo.java
@@ -23,13 +23,13 @@ import java.util.Map;
 import java.util.HashMap;
 import java.util.TreeMap;
 import java.util.SortedMap;
-import org.apache.sis.util.ArraysExt;
 import org.apache.sis.internal.netcdf.Axis;
 import org.apache.sis.internal.netcdf.Grid;
 import org.apache.sis.internal.netcdf.Resources;
 import org.apache.sis.storage.DataStoreContentException;
 import org.apache.sis.storage.DataStoreException;
 import org.apache.sis.measure.Units;
+import org.apache.sis.util.ArraysExt;
 import ucar.nc2.constants.CF;
 
 
@@ -256,7 +256,7 @@ final class GridInfo extends Grid {
 
     /**
      * Returns a hash code for this grid. A map of {@code GridInfo} is used by
-     * {@link ChannelDecoder#getGridGeometries()} for sharing existing instances.
+     * {@link ChannelDecoder#getGrids()} for sharing existing instances.
      */
     @Override
     public int hashCode() {
diff --git a/storage/sis-netcdf/src/main/java/org/apache/sis/internal/netcdf/impl/VariableInfo.java
b/storage/sis-netcdf/src/main/java/org/apache/sis/internal/netcdf/impl/VariableInfo.java
index 664b990..ef33f2f 100644
--- a/storage/sis-netcdf/src/main/java/org/apache/sis/internal/netcdf/impl/VariableInfo.java
+++ b/storage/sis-netcdf/src/main/java/org/apache/sis/internal/netcdf/impl/VariableInfo.java
@@ -147,12 +147,12 @@ final class VariableInfo extends Variable implements Comparable<VariableInfo>
{
 
     /**
      * The grid geometry associated to this variable,
-     * computed by {@link ChannelDecoder#getGridGeometries()} when first needed.
+     * computed by {@link ChannelDecoder#getGrids()} when first needed.
      * May stay {@code null} if the variable is not a data cube.
      *
-     * @see #getGridGeometry(Decoder)
+     * @see #getGrid(Decoder)
      */
-    GridInfo gridGeometry;
+    GridInfo grid;
 
     /**
      * {@code true} if this variable seems to be a coordinate system axis, as determined
by comparing its name
@@ -466,17 +466,17 @@ final class VariableInfo extends Variable implements Comparable<VariableInfo>
{
     /**
      * Returns the grid geometry for this variable, or {@code null} if this variable is not
a data cube.
      * The grid geometries are opportunistically cached in {@code VariableInfo} instances
after they have
-     * been computed by {@link ChannelDecoder#getGridGeometries()}.
+     * been computed by {@link ChannelDecoder#getGrids()}.
      * The same grid geometry may be shared by many variables.
      *
-     * @see ChannelDecoder#getGridGeometries()
+     * @see ChannelDecoder#getGrids()
      */
     @Override
-    public Grid getGridGeometry(final Decoder decoder) throws IOException, DataStoreException
{
-        if (gridGeometry == null) {
-            decoder.getGridGeometries();            // Force calculation of grid geometries
if not already done.
+    public Grid getGrid(final Decoder decoder) throws IOException, DataStoreException {
+        if (grid == null) {
+            decoder.getGrids();            // Force calculation of grid geometries if not
already done.
         }
-        return gridGeometry;
+        return grid;
     }
 
     /**
diff --git a/storage/sis-netcdf/src/main/java/org/apache/sis/internal/netcdf/ucar/DecoderWrapper.java
b/storage/sis-netcdf/src/main/java/org/apache/sis/internal/netcdf/ucar/DecoderWrapper.java
index 5910b5c..5e2d659 100644
--- a/storage/sis-netcdf/src/main/java/org/apache/sis/internal/netcdf/ucar/DecoderWrapper.java
+++ b/storage/sis-netcdf/src/main/java/org/apache/sis/internal/netcdf/ucar/DecoderWrapper.java
@@ -92,7 +92,7 @@ public final class DecoderWrapper extends Decoder implements CancelTask
{
     /**
      * The grid geometries, computed when first needed.
      *
-     * @see #getGridGeometries()
+     * @see #getGrids()
      */
     private transient Grid[] geometries;
 
@@ -433,7 +433,7 @@ public final class DecoderWrapper extends Decoder implements CancelTask
{
      */
     @Override
     @SuppressWarnings({"ReturnOfCollectionOrArrayField", "null"})
-    public Grid[] getGridGeometries() throws IOException {
+    public Grid[] getGrids() throws IOException {
         if (geometries == null) {
             List<CoordinateSystem> systems = null;
             if (file instanceof NetcdfDataset) {
diff --git a/storage/sis-netcdf/src/main/java/org/apache/sis/internal/netcdf/ucar/VariableWrapper.java
b/storage/sis-netcdf/src/main/java/org/apache/sis/internal/netcdf/ucar/VariableWrapper.java
index 0723d78..8637806 100644
--- a/storage/sis-netcdf/src/main/java/org/apache/sis/internal/netcdf/ucar/VariableWrapper.java
+++ b/storage/sis-netcdf/src/main/java/org/apache/sis/internal/netcdf/ucar/VariableWrapper.java
@@ -218,17 +218,17 @@ final class VariableWrapper extends Variable {
 
     /**
      * Returns the grid geometry for this variable, or {@code null} if this variable is not
a data cube.
-     * This method searches for a grid previously computed by {@link DecoderWrapper#getGridGeometries()}.
+     * This method searches for a grid previously computed by {@link DecoderWrapper#getGrids()}.
      * The same grid geometry may be shared by many variables.
      *
-     * @see DecoderWrapper#getGridGeometries()
+     * @see DecoderWrapper#getGrids()
      */
     @Override
-    public Grid getGridGeometry(final Decoder decoder) throws IOException, DataStoreException
{
+    public Grid getGrid(final Decoder decoder) throws IOException, DataStoreException {
         if (variable instanceof Enhancements) {
             final List<CoordinateSystem> cs = ((Enhancements) variable).getCoordinateSystems();
             if (cs != null && !cs.isEmpty()) {
-                for (final Grid grid : decoder.getGridGeometries()) {
+                for (final Grid grid : decoder.getGrids()) {
                     if (cs.contains(((GridWrapper) grid).netcdfCS)) {
                         return grid;
                     }
diff --git a/storage/sis-netcdf/src/main/java/org/apache/sis/storage/netcdf/GridResource.java
b/storage/sis-netcdf/src/main/java/org/apache/sis/storage/netcdf/GridResource.java
index 28b3bf7..3a84141 100644
--- a/storage/sis-netcdf/src/main/java/org/apache/sis/storage/netcdf/GridResource.java
+++ b/storage/sis-netcdf/src/main/java/org/apache/sis/storage/netcdf/GridResource.java
@@ -128,7 +128,7 @@ final class GridResource extends AbstractGridResource implements ResourceOnFileS
     private final Path location;
 
     /**
-     * Creates a new resource.
+     * Creates a new resource. All variables in the {@code data} list shall have the same
domain and the same grid geometry.
      *
      * @param  decoder  the implementation used for decoding the netCDF file.
      * @param  name     the name for the resource.
@@ -160,7 +160,7 @@ final class GridResource extends AbstractGridResource implements ResourceOnFileS
             if (decoder.roleOf(variable) != VariableRole.COVERAGE) {
                 continue;                                                   // Skip variables
that are not grid coverages.
             }
-            final Grid grid = variable.getGridGeometry(decoder);
+            final Grid grid = variable.getGrid(decoder);
             if (grid == null) {
                 continue;                                                   // Skip variables
that are not grid coverages.
             }
@@ -192,7 +192,7 @@ final class GridResource extends AbstractGridResource implements ResourceOnFileS
                         final String cn = candidate.getStandardName();
                         if (cn.regionMatches(cn.length() - suffixLength, name, suffixStart,
suffixLength) &&
                             cn.regionMatches(0, name, 0, prefixLength) && candidate.getDataType()
== type &&
-                            candidate.getGridGeometry(decoder) == grid)
+                            candidate.getGrid(decoder) == grid)
                         {
                             /*
                              * Found another variable with the same name except for the keyword.
Verify that the
diff --git a/storage/sis-netcdf/src/main/java/org/apache/sis/storage/netcdf/MetadataReader.java
b/storage/sis-netcdf/src/main/java/org/apache/sis/storage/netcdf/MetadataReader.java
index 73d31b5..2f030d1 100644
--- a/storage/sis-netcdf/src/main/java/org/apache/sis/storage/netcdf/MetadataReader.java
+++ b/storage/sis-netcdf/src/main/java/org/apache/sis/storage/netcdf/MetadataReader.java
@@ -659,10 +659,9 @@ split:  while ((start = CharSequences.skipLeadingWhitespaces(value, start,
lengt
         }
         /*
          * Add spatial representation type only if it was not explicitly given in the metadata.
-         * The call to getGridGeometries() may be relatively costly, so we don't want to
invoke
-         * it without necessity.
+         * The call to getGrids() may be relatively costly, so we don't want to invoke it
without necessity.
          */
-        if (!hasDataType && decoder.getGridGeometries().length != 0) {
+        if (!hasDataType && decoder.getGrids().length != 0) {
             addSpatialRepresentation(SpatialRepresentationType.GRID);
         }
         /*
@@ -1027,7 +1026,7 @@ split:  while ((start = CharSequences.skipLeadingWhitespaces(value,
start, lengt
      * @throws ArithmeticException if the size of an axis exceeds {@link Integer#MAX_VALUE},
or other overflow occurs.
      */
     public Metadata read() throws IOException, DataStoreException {
-        for (final Grid cs : decoder.getGridGeometries()) {
+        for (final Grid cs : decoder.getGrids()) {
             final CoordinateReferenceSystem crs = cs.getCoordinateReferenceSystem(decoder);
             addReferenceSystem(crs);
             if (verticalCRS == null) {
@@ -1048,7 +1047,7 @@ split:  while ((start = CharSequences.skipLeadingWhitespaces(value,
start, lengt
          * Add the dimension information, if any. This metadata node
          * is built from the netCDF CoordinateSystem objects.
          */
-        for (final Grid cs : decoder.getGridGeometries()) {
+        for (final Grid cs : decoder.getGrids()) {
             if (cs.getSourceDimensions() >= Grid.MIN_DIMENSION &&
                 cs.getTargetDimensions() >= Grid.MIN_DIMENSION)
             {
diff --git a/storage/sis-netcdf/src/test/java/org/apache/sis/internal/netcdf/GridTest.java
b/storage/sis-netcdf/src/test/java/org/apache/sis/internal/netcdf/GridTest.java
index e31292e..b6c42b9 100644
--- a/storage/sis-netcdf/src/test/java/org/apache/sis/internal/netcdf/GridTest.java
+++ b/storage/sis-netcdf/src/test/java/org/apache/sis/internal/netcdf/GridTest.java
@@ -61,11 +61,11 @@ public strictfp class GridTest extends TestCase {
      */
     @Test
     public void testDimensions() throws IOException, DataStoreException {
-        Grid geometry = getSingleton(filter(selectDataset(TestData.NETCDF_2D_GEOGRAPHIC).getGridGeometries()));
+        Grid geometry = getSingleton(filter(selectDataset(TestData.NETCDF_2D_GEOGRAPHIC).getGrids()));
         assertEquals("getSourceDimensions()", 2, geometry.getSourceDimensions());
         assertEquals("getTargetDimensions()", 2, geometry.getTargetDimensions());
 
-        geometry = getSingleton(filter(selectDataset(TestData.NETCDF_4D_PROJECTED).getGridGeometries()));
+        geometry = getSingleton(filter(selectDataset(TestData.NETCDF_4D_PROJECTED).getGrids()));
         assertEquals("getSourceDimensions()", 4, geometry.getSourceDimensions());
         assertEquals("getTargetDimensions()", 4, geometry.getTargetDimensions());
     }
@@ -79,7 +79,7 @@ public strictfp class GridTest extends TestCase {
     @Test
     @DependsOnMethod("testDimensions")
     public void testAxes2D() throws IOException, DataStoreException {
-        final Axis[] axes = getSingleton(filter(selectDataset(TestData.NETCDF_2D_GEOGRAPHIC).getGridGeometries())).getAxes();
+        final Axis[] axes = getSingleton(filter(selectDataset(TestData.NETCDF_2D_GEOGRAPHIC).getGrids())).getAxes();
         assertEquals(2, axes.length);
         final Axis x = axes[0];
         final Axis y = axes[1];
@@ -103,7 +103,7 @@ public strictfp class GridTest extends TestCase {
     @Test
     @DependsOnMethod("testDimensions")
     public void testAxes4D() throws IOException, DataStoreException {
-        final Axis[] axes = getSingleton(filter(selectDataset(TestData.NETCDF_4D_PROJECTED).getGridGeometries())).getAxes();
+        final Axis[] axes = getSingleton(filter(selectDataset(TestData.NETCDF_4D_PROJECTED).getGrids())).getAxes();
         assertEquals(4, axes.length);
         final Axis x = axes[0];
         final Axis y = axes[1];


Mime
View raw message