sis-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From desruisse...@apache.org
Subject [sis] 03/03: Rename the netCDF internal GridGeometry class as "Grid" for avoiding confusion with the public GridGeometry class.
Date Sat, 17 Nov 2018 17:22:18 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 f4a9e49c1ab0daefb1e1403efeb355f430bc227e
Author: Martin Desruisseaux <martin.desruisseaux@geomatys.com>
AuthorDate: Sat Nov 17 17:59:12 2018 +0100

    Rename the netCDF internal GridGeometry class as "Grid" for avoiding confusion with the
public GridGeometry class.
---
 .../org/apache/sis/coverage/grid/GridExtent.java   |   6 +-
 .../java/org/apache/sis/internal/netcdf/Axis.java  |   6 +-
 .../org/apache/sis/internal/netcdf/Decoder.java    |   2 +-
 .../netcdf/{GridGeometry.java => Grid.java}        | 148 +++++++++++++--------
 .../apache/sis/internal/netcdf/NamedElement.java   |   1 +
 .../org/apache/sis/internal/netcdf/Resources.java  |   5 +
 .../sis/internal/netcdf/Resources.properties       |   1 +
 .../sis/internal/netcdf/Resources_fr.properties    |   1 +
 .../sis/internal/netcdf/impl/ChannelDecoder.java   |  14 +-
 .../impl/{GridGeometryInfo.java => GridInfo.java}  |  10 +-
 .../sis/internal/netcdf/impl/VariableInfo.java     |   2 +-
 .../sis/internal/netcdf/ucar/DecoderWrapper.java   |  10 +-
 .../{GridGeometryWrapper.java => GridWrapper.java} |   6 +-
 .../apache/sis/storage/netcdf/MetadataReader.java  |   8 +-
 .../sis/internal/netcdf/GridGeometryTest.java      |  12 +-
 .../internal/netcdf/impl/GridGeometryInfoTest.java |  10 +-
 16 files changed, 141 insertions(+), 101 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 f4055a9..9c6a299 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
@@ -532,11 +532,11 @@ public class GridExtent implements Serializable {
      */
     final GeneralEnvelope toCRS(final MathTransform gridToCRS) throws TransformException
{
         final int dimension = getDimension();
-        final GeneralEnvelope envope = new GeneralEnvelope(dimension);
+        final GeneralEnvelope envelope = new GeneralEnvelope(dimension);
         for (int i=0; i<dimension; i++) {
-            envope.setRange(i, ordinates[i], ordinates[i + dimension] + 1.0);
+            envelope.setRange(i, ordinates[i], ordinates[i + dimension] + 1.0);
         }
-        return Envelopes.transform(gridToCRS, envope);
+        return Envelopes.transform(gridToCRS, envelope);
     }
 
     /**
diff --git a/storage/sis-netcdf/src/main/java/org/apache/sis/internal/netcdf/Axis.java b/storage/sis-netcdf/src/main/java/org/apache/sis/internal/netcdf/Axis.java
index 7544912..15010fc 100644
--- a/storage/sis-netcdf/src/main/java/org/apache/sis/internal/netcdf/Axis.java
+++ b/storage/sis-netcdf/src/main/java/org/apache/sis/internal/netcdf/Axis.java
@@ -47,7 +47,7 @@ import ucar.nc2.constants.CF;
  * @author  Martin Desruisseaux (Geomatys)
  * @version 1.0
  *
- * @see GridGeometry#getAxes()
+ * @see Grid#getAxes()
  *
  * @since 0.3
  * @module
@@ -124,7 +124,7 @@ public final class Axis extends NamedElement {
      * @throws DataStoreException if a logical error occurred.
      * @throws ArithmeticException if the size of an axis exceeds {@link Integer#MAX_VALUE},
or other overflow occurs.
      */
-    public Axis(final GridGeometry owner, final Variable axis, char abbreviation, final String
direction,
+    public Axis(final Grid owner, final Variable axis, char abbreviation, final String direction,
                 final int[] sourceDimensions, final int[] sourceSizes) throws IOException,
DataStoreException
     {
         /*
@@ -158,7 +158,7 @@ public final class Axis extends NamedElement {
             }
         }
         if (!isConsistent) {
-            axis.warning(GridGeometry.class, "getAxes",             // Caller of this constructor.
+            axis.warning(Grid.class, "getAxes",                 // Caller of this constructor.
                          Resources.Keys.AmbiguousAxisDirection_4, axis.getFilename(), axis.getName(),
dir, check);
             if (isSigned) {
                 if (AxisDirections.isOpposite(dir)) {
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 96ae179..0d72170 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
@@ -246,5 +246,5 @@ 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 GridGeometry[] getGridGeometries() throws IOException, DataStoreException;
+    public abstract Grid[] getGridGeometries() throws IOException, DataStoreException;
 }
diff --git a/storage/sis-netcdf/src/main/java/org/apache/sis/internal/netcdf/GridGeometry.java
b/storage/sis-netcdf/src/main/java/org/apache/sis/internal/netcdf/Grid.java
similarity index 62%
rename from storage/sis-netcdf/src/main/java/org/apache/sis/internal/netcdf/GridGeometry.java
rename to storage/sis-netcdf/src/main/java/org/apache/sis/internal/netcdf/Grid.java
index c137f27..9583249 100644
--- a/storage/sis-netcdf/src/main/java/org/apache/sis/internal/netcdf/GridGeometry.java
+++ b/storage/sis-netcdf/src/main/java/org/apache/sis/internal/netcdf/Grid.java
@@ -21,20 +21,26 @@ import java.util.ArrayList;
 import java.util.Collections;
 import java.io.IOException;
 import org.opengis.util.FactoryException;
+import org.opengis.referencing.datum.PixelInCell;
 import org.opengis.referencing.operation.Matrix;
+import org.opengis.referencing.operation.MathTransform;
+import org.opengis.referencing.operation.TransformException;
 import org.opengis.referencing.cs.CoordinateSystem;
 import org.opengis.referencing.crs.SingleCRS;
 import org.opengis.referencing.crs.CoordinateReferenceSystem;
 import org.opengis.metadata.spatial.DimensionNameType;
 import org.apache.sis.internal.metadata.AxisDirections;
-import org.apache.sis.coverage.grid.GridExtent;
 import org.apache.sis.referencing.operation.matrix.Matrices;
+import org.apache.sis.referencing.operation.transform.MathTransforms;
+import org.apache.sis.coverage.grid.GridExtent;
+import org.apache.sis.coverage.grid.GridGeometry;
 import org.apache.sis.storage.DataStoreException;
 import org.apache.sis.util.NullArgumentException;
 
 
 /**
  * Information about the grid geometry and the conversion from grid coordinates to geodetic
coordinates.
+ * More than one variable may share the same grid.
  *
  * @author  Martin Desruisseaux (Geomatys)
  * @version 1.0
@@ -44,7 +50,7 @@ import org.apache.sis.util.NullArgumentException;
  * @since 0.3
  * @module
  */
-public abstract class GridGeometry extends NamedElement {
+public abstract class Grid extends NamedElement {
     /**
      * The axes, created when first needed.
      *
@@ -66,9 +72,20 @@ public abstract class GridGeometry extends NamedElement {
     private boolean isCRSDetermined;
 
     /**
+     * The geometry of this grid (is extent, its CRS and its conversion to the CRS).
+     * May be {@code null} even after we attempted to create it.
+     */
+    private GridGeometry geometry;
+
+    /**
+     * Whether we determined the {@link #geometry} value, which may be {@code null}.
+     */
+    private boolean isGeometryDetermined;
+
+    /**
      * Constructs a new grid geometry information.
      */
-    protected GridGeometry() {
+    protected Grid() {
     }
 
     /**
@@ -154,6 +171,7 @@ public abstract class GridGeometry extends NamedElement {
      */
     public final CoordinateReferenceSystem getCoordinateReferenceSystem(final Decoder decoder)
throws IOException, DataStoreException {
         if (!isCRSDetermined) try {
+            isCRSDetermined = true;                             // Set now for avoiding new
attempts if creation fail.
             final List<CRSBuilder<?,?>> builders = new ArrayList<>();
             final Axis[] axes = getAxes();
             for (int i=axes.length; --i >= 0;) {                // NetCDF order is reverse
of "natural" order.
@@ -169,80 +187,94 @@ public abstract class GridGeometry extends NamedElement {
                 default: crs = decoder.getCRSFactory().createCompoundCRS(
                                         Collections.singletonMap(CoordinateSystem.NAME_KEY,
getName()), components);
             }
-            isCRSDetermined = true;
         } catch (FactoryException | NullArgumentException ex) {
-            // TODO: avoid reporting the full exception stack trace (maybe leverage QuietLogRecord).
-            warning(decoder.listeners, GridGeometry.class, "getCoordinateReferenceSystem",
ex, null,
-                    Resources.Keys.CanNotCreateCRS_3, decoder.getFilename(), getName(), ex.getLocalizedMessage());
+            canNotCreate(decoder, "getCoordinateReferenceSystem", Resources.Keys.CanNotCreateCRS_3,
ex);
         }
         return crs;
     }
 
     /**
      * Returns an object containing the grid size, the CRS and the conversion from grid indices
to CRS coordinates.
+     * This is the public object exposed to users.
      *
-     * @param   decoder  the decoder for which grid geometries are constructed.
+     * @param   decoder   the decoder for which grid geometries are constructed.
+     * @return  the public grid geometry (may be {@code null}).
      * @throws  IOException if an I/O operation was necessary but failed.
      * @throws  DataStoreException if the CRS can not be constructed.
      */
     @SuppressWarnings("fallthrough")
-    public final void createGridGeometry(final Decoder decoder) throws IOException, DataStoreException
{
-        final Axis[] axes = getAxes();      // In netCDF order (reverse of "natural" order).
-        /*
-         * Build the grid extent if the shape is available. The shape may not be available
-         * if a dimension has unlimited length. The dimension names are informative only.
-         */
-        final GridExtent extent;
-        final long[] high = getShape();
-        if (high != null) {
-            final DimensionNameType[] names = new DimensionNameType[high.length];
-            switch (names.length) {
-                default: names[1] = DimensionNameType.ROW;      // Fall through
-                case 1:  names[0] = DimensionNameType.COLUMN;   // Fall through
-                case 0:  break;
+    public final GridGeometry getGridGeometry(final Decoder decoder) throws IOException,
DataStoreException {
+        if (!isGeometryDetermined) try {
+            isGeometryDetermined = true;        // Set now for avoiding new attempts if creation
fail.
+            final Axis[] axes = getAxes();      // In netCDF order (reverse of "natural"
order).
+            /*
+             * Build the grid extent if the shape is available. The shape may not be available
+             * if a dimension has unlimited length. The dimension names are informative only.
+             */
+            final GridExtent extent;
+            final long[] high = getShape();
+            if (high != null) {
+                final DimensionNameType[] names = new DimensionNameType[high.length];
+                switch (names.length) {
+                    default: names[1] = DimensionNameType.ROW;      // Fall through
+                    case 1:  names[0] = DimensionNameType.COLUMN;   // Fall through
+                    case 0:  break;
+                }
+                for (final Axis axis : axes) {
+                    if (axis.sourceDimensions.length == 1) {
+                        final DimensionNameType name;
+                        if (AxisDirections.isVertical(axis.direction)) {
+                            name = DimensionNameType.VERTICAL;
+                        } else if (AxisDirections.isTemporal(axis.direction)) {
+                            name = DimensionNameType.TIME;
+                        } else {
+                            continue;
+                        }
+                        final int dim = axis.sourceDimensions[0];
+                        if (dim >= 0 && dim < names.length) {
+                            names[names.length - 1 - dim] = name;
+                        }
+                    }
+                }
+                extent = new GridExtent(names, new long[high.length], high, false);
+            } else {
+                extent = null;
             }
-            for (final Axis axis : axes) {
+            /*
+             * Creates the "grid to CRS" transform. The number of columns is the number of
dimensions in the grid
+             * (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 srcEnd = getSourceDimensions();
+            int tgtEnd = getTargetDimensions();
+            final Matrix affine = Matrices.createZero(tgtEnd + 1, srcEnd + 1);
+            affine.setElement(tgtEnd--, srcEnd--, 1);
+            for (int i=axes.length; --i >= 0;) {
+                final Axis axis = axes[i];
+                final int tgtDim = tgtEnd - i;
                 if (axis.sourceDimensions.length == 1) {
-                    final DimensionNameType name;
-                    if (AxisDirections.isVertical(axis.direction)) {
-                        name = DimensionNameType.VERTICAL;
-                    } else if (AxisDirections.isTemporal(axis.direction)) {
-                        name = DimensionNameType.TIME;
-                    } else {
+                    final int srcDim = srcEnd - axis.sourceDimensions[0];
+                    if (axis.coordinates.trySetTransform(affine, srcDim, tgtDim)) {
                         continue;
                     }
-                    final int dim = axis.sourceDimensions[0];
-                    if (dim >= 0 && dim < names.length) {
-                        names[names.length - 1 - dim] = name;
-                    }
                 }
-            }
-            extent = new GridExtent(names, new long[high.length], high, false);
-        } else {
-            extent = null;
-        }
-        /*
-         * Creates the "grid to CRS" transform. The number of columns is the number of dimensions
in the grid
-         * (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 srcEnd = getSourceDimensions();
-        int tgtEnd = getTargetDimensions();
-        final Matrix gridToCRS = Matrices.createZero(tgtEnd-- + 1, srcEnd-- + 1);
-        for (int i=axes.length; --i >= 0;) {
-            final Axis axis = axes[i];
-            final int tgtDim = tgtEnd - i;
-            if (axis.sourceDimensions.length == 1) {
-                final int srcDim = srcEnd - axis.sourceDimensions[0];
-                if (axis.coordinates.trySetTransform(gridToCRS, srcDim, tgtDim)) {
-                    continue;
+                for (int srcDim : axis.sourceDimensions) {
+                    affine.setElement(tgtDim, srcEnd - srcDim, 1);
+                    // TODO: prepare non-linear transform here for later concatenation.
                 }
             }
-            for (int srcDim : axis.sourceDimensions) {
-                gridToCRS.setElement(tgtDim, srcEnd - srcDim, 1);
-                // TODO: prepare non-linear transform here for later concatenation.
-            }
+            MathTransform gridToCRS = MathTransforms.linear(affine);
+            geometry = new GridGeometry(extent, PixelInCell.CELL_CENTER, gridToCRS, getCoordinateReferenceSystem(decoder));
+        } catch (TransformException ex) {
+            canNotCreate(decoder, "getGridGeometry", Resources.Keys.CanNotCreateGridGeometry_3,
ex);
         }
-        // TODO
+        return geometry;
+    }
+
+    /**
+     * Logs a warning about a CRS or grid geometry that can not be created.
+     */
+    private void canNotCreate(final Decoder decoder, final String caller, final short key,
final Exception ex) {
+        warning(decoder.listeners, Grid.class, caller, ex, null, key, decoder.getFilename(),
getName(), ex.getLocalizedMessage());
     }
 }
diff --git a/storage/sis-netcdf/src/main/java/org/apache/sis/internal/netcdf/NamedElement.java
b/storage/sis-netcdf/src/main/java/org/apache/sis/internal/netcdf/NamedElement.java
index bf0c9ba..65ebaad 100644
--- a/storage/sis-netcdf/src/main/java/org/apache/sis/internal/netcdf/NamedElement.java
+++ b/storage/sis-netcdf/src/main/java/org/apache/sis/internal/netcdf/NamedElement.java
@@ -101,6 +101,7 @@ public abstract class NamedElement {
         record.setSourceClassName(caller.getCanonicalName());
         record.setSourceMethodName(method);
         if (exception != null) {
+            // TODO: avoid reporting the full exception stack trace (maybe leverage QuietLogRecord).
             record.setThrown(exception);
         }
         listeners.warning(record);
diff --git a/storage/sis-netcdf/src/main/java/org/apache/sis/internal/netcdf/Resources.java
b/storage/sis-netcdf/src/main/java/org/apache/sis/internal/netcdf/Resources.java
index 98e4cc2..26a6e24 100644
--- a/storage/sis-netcdf/src/main/java/org/apache/sis/internal/netcdf/Resources.java
+++ b/storage/sis-netcdf/src/main/java/org/apache/sis/internal/netcdf/Resources.java
@@ -76,6 +76,11 @@ public final class Resources extends IndexedResourceBundle {
         public static final short CanNotCreateCRS_3 = 11;
 
         /**
+         * Can not create the grid geometry “{1}” in the “{0}” netCDF file. The reason
is: {2}
+         */
+        public static final short CanNotCreateGridGeometry_3 = 12;
+
+        /**
          * Can not use UCAR library for netCDF format. Fallback on Apache SIS implementation.
          */
         public static final short CanNotUseUCAR = 4;
diff --git a/storage/sis-netcdf/src/main/java/org/apache/sis/internal/netcdf/Resources.properties
b/storage/sis-netcdf/src/main/java/org/apache/sis/internal/netcdf/Resources.properties
index 246bccc..bec3630 100644
--- a/storage/sis-netcdf/src/main/java/org/apache/sis/internal/netcdf/Resources.properties
+++ b/storage/sis-netcdf/src/main/java/org/apache/sis/internal/netcdf/Resources.properties
@@ -22,6 +22,7 @@
 AmbiguousAxisDirection_4          = NetCDF file \u201c{0}\u201d provides an ambiguous axis
direction for variable \u201c{1}\u201d. It could be {2}\u00a0or {3}.
 CanNotComputeVariablePosition_2   = Can not compute data location for \u201c{1}\u201d variable
in the \u201c{0}\u201d netCDF file.
 CanNotCreateCRS_3                 = Can not create the Coordinate Reference System for grid
geometry \u201c{1}\u201d in the \u201c{0}\u201d netCDF file. The reason is: {2}
+CanNotCreateGridGeometry_3        = Can not create the grid geometry \u201c{1}\u201d in the
\u201c{0}\u201d netCDF file. The reason is: {2}
 CanNotUseUCAR                     = Can not use UCAR library for netCDF format. Fallback
on Apache SIS implementation.
 DimensionNotFound_3               = Dimension \u201c{2}\u201d declared by attribute \u201c{1}\u201d
is not found in the \u201c{0}\u201d file.
 DuplicatedReference_2             = Duplicated reference to \u201c{1}\u201d in netCDF file
\u201c{0}\u201d.
diff --git a/storage/sis-netcdf/src/main/java/org/apache/sis/internal/netcdf/Resources_fr.properties
b/storage/sis-netcdf/src/main/java/org/apache/sis/internal/netcdf/Resources_fr.properties
index 407e89b..6bf855a 100644
--- a/storage/sis-netcdf/src/main/java/org/apache/sis/internal/netcdf/Resources_fr.properties
+++ b/storage/sis-netcdf/src/main/java/org/apache/sis/internal/netcdf/Resources_fr.properties
@@ -27,6 +27,7 @@
 AmbiguousAxisDirection_4          = Le fichier netCDF \u00ab\u202f{0}\u202f\u00bb fournit
une direction d\u2019axe ambigu\u00eb pour la variable \u00ab\u202f{1}\u202f\u00bb. Elle pourrait
\u00eatre {2}\u00a0ou {3}.
 CanNotComputeVariablePosition_2   = Ne peut pas calculer la position des donn\u00e9es de
la variable \u00ab\u202f{1}\u202f\u00bb dans le fichier netCDF \u00ab\u202f{0}\u202f\u00bb.
 CanNotCreateCRS_3                 = Ne peut pas cr\u00e9er le syst\u00e8me de r\u00e9f\u00e9rence
des coordonn\u00e9es pour la g\u00e9om\u00e9trie de grille \u00ab\u202f{1}\u202f\u00bb dans
le fichier netCDF \u00ab\u202f{0}\u202f\u00bb. La raison est\u2008: {2}
+CanNotCreateGridGeometry_3        = Ne peut pas cr\u00e9er la g\u00e9om\u00e9trie de grille
\u00ab\u202f{1}\u202f\u00bb dans le fichier netCDF \u00ab\u202f{0}\u202f\u00bb. La raison
est\u2008: {2}
 CanNotUseUCAR                     = Ne peut pas utiliser la biblioth\u00e8que de l\u2019UCAR
pour le format netCDF. L\u2019impl\u00e9mentation de Apache SIS sera utilis\u00e9e \u00e0
la place.
 DimensionNotFound_3               = La dimension \u00ab\u202f{2}\u202f\u00bb d\u00e9clar\u00e9e
par l\u2019attribut \u00ab\u202f{1}\u202f\u00bb n\u2019a pas \u00e9t\u00e9 trouv\u00e9e dans
le fichier \u00ab\u202f{0}\u202f\u00bb.
 DuplicatedReference_2             = R\u00e9f\u00e9rence vers \u00ab\u202f{1}\u202f\u00bb
dupliqu\u00e9e dans le fichier netCDF \u00ab\u202f{0}\u202f\u00bb.
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 d8ad414..c946987 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
@@ -43,8 +43,8 @@ import javax.measure.format.ParserException;
 import org.opengis.parameter.InvalidParameterCardinalityException;
 import org.apache.sis.internal.netcdf.DataType;
 import org.apache.sis.internal.netcdf.Decoder;
+import org.apache.sis.internal.netcdf.Grid;
 import org.apache.sis.internal.netcdf.Variable;
-import org.apache.sis.internal.netcdf.GridGeometry;
 import org.apache.sis.internal.netcdf.NamedElement;
 import org.apache.sis.internal.netcdf.DiscreteSampling;
 import org.apache.sis.internal.netcdf.Resources;
@@ -208,7 +208,7 @@ public final class ChannelDecoder extends Decoder {
      *
      * @see #getGridGeometries()
      */
-    private transient GridGeometry[] gridGeometries;
+    private transient Grid[] gridGeometries;
 
     /**
      * Creates a new decoder for the given file.
@@ -845,7 +845,7 @@ public final class ChannelDecoder extends Decoder {
      */
     @Override
     @SuppressWarnings("ReturnOfCollectionOrArrayField")
-    public GridGeometry[] getGridGeometries() {
+    public Grid[] getGridGeometries() {
         if (gridGeometries == null) {
             /*
              * First, find all variables which are used as coordinate system axis. The keys
in the map are
@@ -868,13 +868,13 @@ public final class ChannelDecoder extends Decoder {
              * to share them.
              */
             final Set<VariableInfo> axes = new LinkedHashSet<>(4);
-            final Map<List<Dimension>, GridGeometryInfo> dimsToGG = new LinkedHashMap<>();
+            final Map<List<Dimension>, GridInfo> dimsToGG = new LinkedHashMap<>();
 nextVar:    for (final VariableInfo variable : variables) {
                 if (variable.isCoordinateSystemAxis() || variable.dimensions.length == 0)
{
                     continue;
                 }
                 final List<Dimension> dimensions = Arrays.asList(variable.dimensions);
-                GridGeometryInfo gridGeometry = dimsToGG.get(dimensions);
+                GridInfo gridGeometry = dimsToGG.get(dimensions);
                 if (gridGeometry == null) {
                     /*
                      * Found a new list of dimensions for which no axes have been created
yet.
@@ -889,13 +889,13 @@ nextVar:    for (final VariableInfo variable : variables) {
                         }
                         axes.addAll(axis);
                     }
-                    gridGeometry = new GridGeometryInfo(variable.dimensions, axes.toArray(new
VariableInfo[axes.size()]));
+                    gridGeometry = new GridInfo(variable.dimensions, axes.toArray(new VariableInfo[axes.size()]));
                     dimsToGG.put(dimensions, gridGeometry);
                     axes.clear();
                 }
                 variable.gridGeometry = gridGeometry;
             }
-            gridGeometries = dimsToGG.values().toArray(new GridGeometry[dimsToGG.size()]);
+            gridGeometries = dimsToGG.values().toArray(new Grid[dimsToGG.size()]);
         }
         return gridGeometries;
     }
diff --git a/storage/sis-netcdf/src/main/java/org/apache/sis/internal/netcdf/impl/GridGeometryInfo.java
b/storage/sis-netcdf/src/main/java/org/apache/sis/internal/netcdf/impl/GridInfo.java
similarity index 97%
rename from storage/sis-netcdf/src/main/java/org/apache/sis/internal/netcdf/impl/GridGeometryInfo.java
rename to storage/sis-netcdf/src/main/java/org/apache/sis/internal/netcdf/impl/GridInfo.java
index d8a5d9c..452a19a 100644
--- a/storage/sis-netcdf/src/main/java/org/apache/sis/internal/netcdf/impl/GridGeometryInfo.java
+++ b/storage/sis-netcdf/src/main/java/org/apache/sis/internal/netcdf/impl/GridInfo.java
@@ -25,7 +25,7 @@ import java.util.SortedMap;
 import org.apache.sis.util.ArraysExt;
 import org.apache.sis.internal.netcdf.Axis;
 import org.apache.sis.internal.netcdf.Variable;
-import org.apache.sis.internal.netcdf.GridGeometry;
+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;
@@ -44,7 +44,7 @@ import ucar.nc2.constants.CF;
  * @since   0.3
  * @module
  */
-final class GridGeometryInfo extends GridGeometry {
+final class GridInfo extends Grid {
     /**
      * Mapping from values of the {@code "_CoordinateAxisType"} attribute or axis name to
the abbreviation.
      * Keys are lower cases and values are controlled vocabulary documented in {@link Axis#abbreviation}.
@@ -92,7 +92,7 @@ final class GridGeometryInfo extends GridGeometry {
      * @param  domain  describes the input values of the "grid to CRS" conversion.
      * @param  range   the output values of the "grid to CRS" conversion.
      */
-    GridGeometryInfo(final Dimension[] domain, final VariableInfo[] range) {
+    GridInfo(final Dimension[] domain, final VariableInfo[] range) {
         this.domain = domain;
         this.range  = range;
     }
@@ -168,8 +168,8 @@ final class GridGeometryInfo extends GridGeometry {
 
     /**
      * Returns all axes of the netCDF coordinate system, together with the grid dimension
to which the axis
-     * is associated. See {@link org.apache.sis.internal.netcdf.ucar.GridGeometryWrapper#getAxes()}
for a
-     * closer look on the relationship between this algorithm and the UCAR library.
+     * is associated. See {@link org.apache.sis.internal.netcdf.ucar.GridWrapper#getAxes()}
for a closer look
+     * on the relationship between this algorithm and the UCAR library.
      *
      * <p>In this method, the words "domain" and "range" are used in the netCDF sense:
they are the input
      * (domain) and output (range) of the function that convert grid indices to geodetic
coordinates.</p>
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 6878d9d..8712326 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
@@ -138,7 +138,7 @@ final class VariableInfo extends Variable implements Comparable<VariableInfo>
{
      * computed by {@link ChannelDecoder#getGridGeometries()} when first needed.
      * May stay {@code null} if the variable is not a data cube.
      */
-    GridGeometryInfo gridGeometry;
+    GridInfo gridGeometry;
 
     /**
      * {@code true} if this variable seems to be a coordinate system axis, as determined
by comparing its name
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 ac55d23..edda4ff 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
@@ -42,7 +42,7 @@ import org.apache.sis.util.ArraysExt;
 import org.apache.sis.util.logging.WarningListeners;
 import org.apache.sis.internal.netcdf.Decoder;
 import org.apache.sis.internal.netcdf.Variable;
-import org.apache.sis.internal.netcdf.GridGeometry;
+import org.apache.sis.internal.netcdf.Grid;
 import org.apache.sis.internal.netcdf.DiscreteSampling;
 import org.apache.sis.setup.GeometryLibrary;
 import org.apache.sis.storage.DataStore;
@@ -94,7 +94,7 @@ public final class DecoderWrapper extends Decoder implements CancelTask
{
      *
      * @see #getGridGeometries()
      */
-    private transient GridGeometry[] geometries;
+    private transient Grid[] geometries;
 
     /**
      * Creates a new decoder for the given netCDF file. While this constructor accepts arbitrary
@@ -410,7 +410,7 @@ public final class DecoderWrapper extends Decoder implements CancelTask
{
      */
     @Override
     @SuppressWarnings({"ReturnOfCollectionOrArrayField", "null"})
-    public GridGeometry[] getGridGeometries() throws IOException {
+    public Grid[] getGridGeometries() throws IOException {
         if (geometries == null) {
             List<CoordinateSystem> systems = null;
             if (file instanceof NetcdfDataset) {
@@ -421,9 +421,9 @@ public final class DecoderWrapper extends Decoder implements CancelTask
{
                 }
                 systems = ds.getCoordinateSystems();
             }
-            geometries = new GridGeometry[(systems != null) ? systems.size() : 0];
+            geometries = new Grid[(systems != null) ? systems.size() : 0];
             for (int i=0; i<geometries.length; i++) {
-                geometries[i] = new GridGeometryWrapper(this, systems.get(i));
+                geometries[i] = new GridWrapper(this, systems.get(i));
             }
         }
         return geometries;
diff --git a/storage/sis-netcdf/src/main/java/org/apache/sis/internal/netcdf/ucar/GridGeometryWrapper.java
b/storage/sis-netcdf/src/main/java/org/apache/sis/internal/netcdf/ucar/GridWrapper.java
similarity index 97%
rename from storage/sis-netcdf/src/main/java/org/apache/sis/internal/netcdf/ucar/GridGeometryWrapper.java
rename to storage/sis-netcdf/src/main/java/org/apache/sis/internal/netcdf/ucar/GridWrapper.java
index 2ce80dd..8e34bf5 100644
--- a/storage/sis-netcdf/src/main/java/org/apache/sis/internal/netcdf/ucar/GridGeometryWrapper.java
+++ b/storage/sis-netcdf/src/main/java/org/apache/sis/internal/netcdf/ucar/GridWrapper.java
@@ -25,7 +25,7 @@ import ucar.nc2.dataset.CoordinateAxis2D;
 import ucar.nc2.dataset.CoordinateSystem;
 import org.apache.sis.internal.netcdf.Axis;
 import org.apache.sis.internal.netcdf.Variable;
-import org.apache.sis.internal.netcdf.GridGeometry;
+import org.apache.sis.internal.netcdf.Grid;
 import org.apache.sis.storage.DataStoreException;
 import org.apache.sis.util.ArraysExt;
 import ucar.nc2.VariableIF;
@@ -42,7 +42,7 @@ import ucar.nc2.VariableIF;
  * @since   0.3
  * @module
  */
-final class GridGeometryWrapper extends GridGeometry {
+final class GridWrapper extends Grid {
     /**
      * The decoder which is creating this grid geometry.
      * Used for fetching the variables when first needed.
@@ -59,7 +59,7 @@ final class GridGeometryWrapper extends GridGeometry {
      *
      * @param  cs  the netCDF coordinate system.
      */
-    GridGeometryWrapper(final DecoderWrapper decoder, final CoordinateSystem cs) {
+    GridWrapper(final DecoderWrapper decoder, final CoordinateSystem cs) {
         this.decoder = decoder;
         netcdfCS = cs;
     }
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 b2130cc..df50a78 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
@@ -60,7 +60,7 @@ import org.apache.sis.metadata.sql.MetadataStoreException;
 import org.apache.sis.internal.netcdf.Axis;
 import org.apache.sis.internal.netcdf.Decoder;
 import org.apache.sis.internal.netcdf.Variable;
-import org.apache.sis.internal.netcdf.GridGeometry;
+import org.apache.sis.internal.netcdf.Grid;
 import org.apache.sis.internal.storage.io.IOUtilities;
 import org.apache.sis.internal.storage.MetadataBuilder;
 import org.apache.sis.internal.storage.wkt.StoreFormat;
@@ -702,7 +702,7 @@ split:  while ((start = CharSequences.skipLeadingWhitespaces(value, start,
lengt
      * @param  cs  the grid geometry (related to the netCDF coordinate system).
      * @throws ArithmeticException if the size of an axis exceeds {@link Integer#MAX_VALUE},
or other overflow occurs.
      */
-    private void addSpatialRepresentationInfo(final GridGeometry cs) throws IOException,
DataStoreException {
+    private void addSpatialRepresentationInfo(final Grid cs) throws IOException, DataStoreException
{
         final Axis[] axes = cs.getAxes();
         for (int i=axes.length; i>0;) {
             final int dim = axes.length - i;
@@ -1020,7 +1020,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 GridGeometry cs : decoder.getGridGeometries()) {
+        for (final Grid cs : decoder.getGridGeometries()) {
             final CoordinateReferenceSystem crs = cs.getCoordinateReferenceSystem(decoder);
             addReferenceSystem(crs);
             if (verticalCRS == null) {
@@ -1041,7 +1041,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 GridGeometry cs : decoder.getGridGeometries()) {
+        for (final Grid cs : decoder.getGridGeometries()) {
             if (cs.getSourceDimensions() >= Variable.MIN_DIMENSION &&
                 cs.getTargetDimensions() >= Variable.MIN_DIMENSION)
             {
diff --git a/storage/sis-netcdf/src/test/java/org/apache/sis/internal/netcdf/GridGeometryTest.java
b/storage/sis-netcdf/src/test/java/org/apache/sis/internal/netcdf/GridGeometryTest.java
index 674e69b..0173898 100644
--- a/storage/sis-netcdf/src/test/java/org/apache/sis/internal/netcdf/GridGeometryTest.java
+++ b/storage/sis-netcdf/src/test/java/org/apache/sis/internal/netcdf/GridGeometryTest.java
@@ -28,7 +28,7 @@ import static org.apache.sis.test.TestUtilities.getSingleton;
 
 
 /**
- * Tests the {@link GridGeometry} implementation. The default implementation tests
+ * Tests the {@link Grid} implementation. The default implementation tests
  * {@code org.apache.sis.internal.netcdf.ucar.GridGeometryWrapper} since the UCAR
  * library is our reference implementation. However subclasses can override the
  * {@link #createDecoder(TestData)} method in order to test a different implementation.
@@ -49,19 +49,19 @@ public strictfp class GridGeometryTest extends TestCase {
      * @param  geometries  the grid geometries created by {@link Decoder}.
      * @return the grid geometries to test.
      */
-    protected GridGeometry[] filter(final GridGeometry[] geometries) {
+    protected Grid[] filter(final Grid[] geometries) {
         return geometries;
     }
 
     /**
-     * Tests {@link GridGeometry#getSourceDimensions()} and {@link GridGeometry#getTargetDimensions()}.
+     * Tests {@link Grid#getSourceDimensions()} and {@link Grid#getTargetDimensions()}.
      *
      * @throws IOException if an I/O error occurred while opening the file.
      * @throws DataStoreException if a logical error occurred.
      */
     @Test
     public void testDimensions() throws IOException, DataStoreException {
-        GridGeometry geometry = getSingleton(filter(selectDataset(TestData.NETCDF_2D_GEOGRAPHIC).getGridGeometries()));
+        Grid geometry = getSingleton(filter(selectDataset(TestData.NETCDF_2D_GEOGRAPHIC).getGridGeometries()));
         assertEquals("getSourceDimensions()", 2, geometry.getSourceDimensions());
         assertEquals("getTargetDimensions()", 2, geometry.getTargetDimensions());
 
@@ -71,7 +71,7 @@ public strictfp class GridGeometryTest extends TestCase {
     }
 
     /**
-     * Tests {@link GridGeometry#getAxes()} on a two-dimensional dataset.
+     * Tests {@link Grid#getAxes()} on a two-dimensional dataset.
      *
      * @throws IOException if an I/O error occurred while opening the file.
      * @throws DataStoreException if a logical error occurred.
@@ -95,7 +95,7 @@ public strictfp class GridGeometryTest extends TestCase {
     }
 
     /**
-     * Tests {@link GridGeometry#getAxes()} on a four-dimensional dataset.
+     * Tests {@link Grid#getAxes()} on a four-dimensional dataset.
      *
      * @throws IOException if an I/O error occurred while opening the file.
      * @throws DataStoreException if a logical error occurred.
diff --git a/storage/sis-netcdf/src/test/java/org/apache/sis/internal/netcdf/impl/GridGeometryInfoTest.java
b/storage/sis-netcdf/src/test/java/org/apache/sis/internal/netcdf/impl/GridGeometryInfoTest.java
index f4f9b03..237a950 100644
--- a/storage/sis-netcdf/src/test/java/org/apache/sis/internal/netcdf/impl/GridGeometryInfoTest.java
+++ b/storage/sis-netcdf/src/test/java/org/apache/sis/internal/netcdf/impl/GridGeometryInfoTest.java
@@ -18,7 +18,7 @@ package org.apache.sis.internal.netcdf.impl;
 
 import java.io.IOException;
 import org.apache.sis.internal.netcdf.Decoder;
-import org.apache.sis.internal.netcdf.GridGeometry;
+import org.apache.sis.internal.netcdf.Grid;
 import org.apache.sis.internal.netcdf.GridGeometryTest;
 import org.apache.sis.storage.DataStoreException;
 import org.apache.sis.util.ArraysExt;
@@ -27,7 +27,7 @@ import org.opengis.test.dataset.TestData;
 
 
 /**
- * Tests the {@link GridGeometry} implementation. This test shall be executed only if the
+ * Tests the {@link Grid} implementation. This test shall be executed only if the
  * {@link GridGeometryTest} tests, which use the UCAR library has a reference implementation,
  * passed.
  *
@@ -57,10 +57,10 @@ public final strictfp class GridGeometryInfoTest extends GridGeometryTest
{
      * @return the filtered grid geometries to test.
      */
     @Override
-    protected GridGeometry[] filter(final GridGeometry[] geometries) {
-        final GridGeometry[] copy = new GridGeometry[geometries.length];
+    protected Grid[] filter(final Grid[] geometries) {
+        final Grid[] copy = new Grid[geometries.length];
         int count = 0;
-        for (final GridGeometry geometry : geometries) {
+        for (final Grid geometry : geometries) {
             if (geometry.getSourceDimensions() != 1 || geometry.getTargetDimensions() !=
1) {
                 copy[count++] = geometry;
             }


Mime
View raw message