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 c9c9d89  Moved 'GridResource' and 'Image' classes to 
org.apache.sis.internal.netcdf package. This allow us to restrict the scope of 
some Variable methods.
c9c9d89 is described below

commit c9c9d89bc859939fa3573f4f9798fd636910aefb
Author: Martin Desruisseaux <[email protected]>
AuthorDate: Mon Mar 18 12:28:28 2019 +0100

    Moved 'GridResource' and 'Image' classes to org.apache.sis.internal.netcdf 
package.
    This allow us to restrict the scope of some Variable methods.
---
 .../Image.java => internal/netcdf/Raster.java}     |  9 +++---
 .../netcdf/RasterResource.java}                    | 36 ++++++++++++----------
 .../org/apache/sis/internal/netcdf/Variable.java   | 18 +++++------
 .../sis/internal/netcdf/ucar/VariableWrapper.java  |  2 +-
 .../org/apache/sis/storage/netcdf/NetcdfStore.java |  3 +-
 5 files changed, 35 insertions(+), 33 deletions(-)

diff --git 
a/storage/sis-netcdf/src/main/java/org/apache/sis/storage/netcdf/Image.java 
b/storage/sis-netcdf/src/main/java/org/apache/sis/internal/netcdf/Raster.java
similarity index 88%
rename from 
storage/sis-netcdf/src/main/java/org/apache/sis/storage/netcdf/Image.java
rename to 
storage/sis-netcdf/src/main/java/org/apache/sis/internal/netcdf/Raster.java
index 4190b49..a916d5b 100644
--- a/storage/sis-netcdf/src/main/java/org/apache/sis/storage/netcdf/Image.java
+++ 
b/storage/sis-netcdf/src/main/java/org/apache/sis/internal/netcdf/Raster.java
@@ -14,7 +14,7 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.apache.sis.storage.netcdf;
+package org.apache.sis.internal.netcdf;
 
 import java.util.List;
 import java.awt.image.DataBuffer;
@@ -26,18 +26,17 @@ import org.apache.sis.coverage.grid.GridCoverage;
 import org.apache.sis.coverage.grid.GridGeometry;
 import org.apache.sis.coverage.grid.GridExtent;
 import org.apache.sis.coverage.grid.ImageRenderer;
-import org.apache.sis.internal.netcdf.Resources;
 
 
 /**
- * Data loaded from a {@link GridResource}.
+ * Data loaded from a {@link RasterResource}.
  *
  * @author  Martin Desruisseaux (IRD, Geomatys)
  * @version 1.0
  * @since   1.0
  * @module
  */
-final class Image extends GridCoverage {
+final class Raster extends GridCoverage {
     /**
      * The sample values.
      */
@@ -51,7 +50,7 @@ final class Image extends GridCoverage {
     /**
      * Creates a new raster from the given resource.
      */
-    Image(final GridGeometry domain, final List<SampleDimension> range, final 
DataBuffer data, final String label) {
+    Raster(final GridGeometry domain, final List<SampleDimension> range, final 
DataBuffer data, final String label) {
         super(domain, range);
         this.data  = data;
         this.label = label;
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/internal/netcdf/RasterResource.java
similarity index 94%
rename from 
storage/sis-netcdf/src/main/java/org/apache/sis/storage/netcdf/GridResource.java
rename to 
storage/sis-netcdf/src/main/java/org/apache/sis/internal/netcdf/RasterResource.java
index 9868ecc..fbbd463 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/internal/netcdf/RasterResource.java
@@ -14,7 +14,7 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.apache.sis.storage.netcdf;
+package org.apache.sis.internal.netcdf;
 
 import java.util.Map;
 import java.util.List;
@@ -26,19 +26,13 @@ import java.awt.image.DataBuffer;
 import org.opengis.util.GenericName;
 import org.opengis.referencing.operation.MathTransform1D;
 import org.opengis.referencing.operation.TransformException;
-import org.apache.sis.coverage.grid.GridGeometry;
-import org.apache.sis.internal.netcdf.Decoder;
-import org.apache.sis.internal.netcdf.DataType;
-import org.apache.sis.internal.netcdf.Variable;
-import org.apache.sis.internal.netcdf.Resources;
-import org.apache.sis.internal.netcdf.VariableRole;
 import org.apache.sis.internal.storage.AbstractGridResource;
 import org.apache.sis.internal.storage.ResourceOnFileSystem;
+import org.apache.sis.internal.raster.RasterFactory;
 import org.apache.sis.coverage.SampleDimension;
 import org.apache.sis.coverage.grid.GridCoverage;
+import org.apache.sis.coverage.grid.GridGeometry;
 import org.apache.sis.coverage.grid.GridDerivation;
-import org.apache.sis.internal.netcdf.Convention;
-import org.apache.sis.internal.raster.RasterFactory;
 import org.apache.sis.storage.DataStoreException;
 import org.apache.sis.storage.DataStoreContentException;
 import org.apache.sis.storage.DataStoreReferencingException;
@@ -64,7 +58,7 @@ import org.apache.sis.internal.util.UnmodifiableArrayList;
  * @since   1.0
  * @module
  */
-final class GridResource extends AbstractGridResource implements 
ResourceOnFileSystem {
+public final class RasterResource extends AbstractGridResource implements 
ResourceOnFileSystem {
     /**
      * Words used in standard (preferred) or long (if no standard) variable 
names which suggest
      * that the variable is a component of a vector. Those words are used in 
heuristic rules
@@ -139,7 +133,7 @@ final class GridResource extends AbstractGridResource 
implements ResourceOnFileS
      * @param  grid     the grid geometry (size, CRS…) of the {@linkplain 
#data} cube.
      * @param  bands    the variables providing actual data. Shall contain at 
least one variable.
      */
-    private GridResource(final Decoder decoder, final String name, final 
GridGeometry grid, final List<Variable> bands)
+    private RasterResource(final Decoder decoder, final String name, final 
GridGeometry grid, final List<Variable> bands)
             throws IOException, DataStoreException
     {
         super(decoder.listeners);
@@ -152,11 +146,14 @@ final class GridResource extends AbstractGridResource 
implements ResourceOnFileS
     }
 
     /**
-     * Creates all grid resources from the given decoder.
+     * Creates all grid coverage resources from the given decoder.
      *
      * @param  decoder  the implementation used for decoding the netCDF file.
+     * @return all grid coverage resources.
+     * @throws IOException if an I/O operation was required and failed.
+     * @throws DataStoreException if a logical error occurred.
      */
-    static List<Resource> create(final Decoder decoder) throws IOException, 
DataStoreException {
+    public static List<Resource> create(final Decoder decoder) throws 
IOException, DataStoreException {
         final Variable[]     variables = decoder.getVariables().clone();       
 // Needs a clone because may be modified.
         final List<Variable> siblings  = new ArrayList<>(4);
         final List<Resource> resources = new ArrayList<>();
@@ -229,7 +226,7 @@ final class GridResource extends AbstractGridResource 
implements ResourceOnFileS
                     }
                 }
             }
-            resources.add(new GridResource(decoder, name.trim(), grid, 
siblings));
+            resources.add(new RasterResource(decoder, name.trim(), grid, 
siblings));
             siblings.clear();
         }
         return resources;
@@ -245,6 +242,8 @@ final class GridResource extends AbstractGridResource 
implements ResourceOnFileS
 
     /**
      * Returns an object containing the grid size, the CRS and the conversion 
from grid indices to CRS coordinates.
+     *
+     * @return extent of grid coordinates together with their mapping to "real 
world" coordinates.
      */
     @Override
     public GridGeometry getGridGeometry() {
@@ -253,6 +252,9 @@ final class GridResource extends AbstractGridResource 
implements ResourceOnFileS
 
     /**
      * Returns the ranges of sample values together with the conversion from 
samples to real values.
+     *
+     * @return ranges of sample values together with their mapping to "real 
values".
+     * @throws DataStoreException if an error occurred while reading 
definitions from the underlying data store.
      */
     @Override
     @SuppressWarnings("ReturnOfCollectionOrArrayField")
@@ -323,7 +325,7 @@ final class GridResource extends AbstractGridResource 
implements ResourceOnFileS
              * unsigned integer with a signed one).
              */
             if (range.isEmpty()) {
-                band.warning(GridResource.class, "getSampleDimensions", 
Resources.Keys.IllegalValueRange_4,
+                band.warning(RasterResource.class, "getSampleDimensions", 
Resources.Keys.IllegalValueRange_4,
                         band.getFilename(), band.getName(), 
range.getMinValue(), range.getMaxValue());
             } else {
                 String name = band.getDescription();
@@ -446,7 +448,7 @@ final class GridResource extends AbstractGridResource 
implements ResourceOnFileS
         if (imageBuffer == null) {
             throw new 
DataStoreContentException(Errors.format(Errors.Keys.UnsupportedType_1, 
dataType.name()));
         }
-        return new Image(domain, UnmodifiableArrayList.wrap(selected), 
imageBuffer, first.getName());
+        return new Raster(domain, UnmodifiableArrayList.wrap(selected), 
imageBuffer, first.getName());
     }
 
     /**
@@ -464,7 +466,7 @@ final class GridResource extends AbstractGridResource 
implements ResourceOnFileS
      * Gets the paths to files used by this resource, or an empty array if 
unknown.
      */
     @Override
-    public Path[] getComponentFiles() throws DataStoreException {
+    public Path[] getComponentFiles() {
         return (location != null) ? new Path[] {location} : new Path[0];
     }
 }
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 fb8f387..2d328cc 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
@@ -257,13 +257,13 @@ public abstract class Variable extends NamedElement {
      * {@link #getUnit()}, except for the fill/missing values. If {@code 
true}, then replacing fill/missing values by
      * {@code NaN} is the only action needed for having converted values.
      *
-     * <p>This method is for detecting when {@link 
org.apache.sis.storage.netcdf.GridResource#getSampleDimensions()}
-     * should return sample dimensions for already converted values. But to be 
consistent with {@code SampleDimension}
-     * contract, it requires fill/missing values to be replaced by NaN. This 
is done by {@link #replaceNaN(Object)}.</p>
+     * <p>This method is for detecting when {@link 
RasterResource#getSampleDimensions()} should return sample dimensions
+     * for already converted values. But to be consistent with {@code 
SampleDimension} contract, it requires fill/missing
+     * values to be replaced by NaN. This is done by {@link 
#replaceNaN(Object)}.</p>
      *
      * @return whether this variable contains values in unit of measurement, 
ignoring fill and missing values.
      */
-    public final boolean hasRealValues() {
+    final boolean hasRealValues() {
         final int n = getDataType().number;
         if (n == Numbers.FLOAT | n == Numbers.DOUBLE) {
             final Convention convention = decoder.convention();
@@ -846,7 +846,7 @@ public abstract class Variable extends NamedElement {
      *
      * @see Convention#validRange(Variable)
      */
-    public NumberRange<?> getRangeFallback() {
+    protected NumberRange<?> getRangeFallback() {
         final DataType dataType = getDataType();
         if (dataType.isInteger) {
             final int size = dataType.size() * Byte.SIZE;
@@ -900,7 +900,7 @@ public abstract class Variable extends NamedElement {
      * @see Convention#nodataValues(Variable)
      */
     @SuppressWarnings("ReturnOfCollectionOrArrayField")
-    public final Map<Number,Object> getNodataValues() {
+    final Map<Number,Object> getNodataValues() {
         if (nodataValues == null) {
             nodataValues = 
CollectionsExt.unmodifiableOrCopy(decoder.convention().nodataValues(this));
         }
@@ -987,7 +987,7 @@ public abstract class Variable extends NamedElement {
      * Maybe replaces fill values and missing values by {@code NaN} values in 
the given array.
      * This method does nothing if {@link #hasRealValues()} returns {@code 
false}.
      * The NaN values used by this method must be consistent with the NaN 
values declared in
-     * the sample dimensions created by {@link 
org.apache.sis.storage.netcdf.GridResource}.
+     * the sample dimensions created by {@link RasterResource}.
      *
      * @param  array  the array in which to replace fill and missing values.
      */
@@ -995,7 +995,7 @@ public abstract class Variable extends NamedElement {
         if (hasRealValues()) {
             int ordinal = 0;
             for (final Number value : getNodataValues().keySet()) {
-                final float pad = MathFunctions.toNanFloat(ordinal++);      // 
Must be consistent with GridResource.createSampleDimension(…).
+                final float pad = MathFunctions.toNanFloat(ordinal++);      // 
Must be consistent with RasterResource.createSampleDimension(…).
                 if (array instanceof float[]) {
                     ArraysExt.replace((float[]) array, value.floatValue(), 
pad);
                 } else if (array instanceof double[]) {
@@ -1100,7 +1100,7 @@ public abstract class Variable extends NamedElement {
      * @param  key        one or {@link Resources.Keys} constants.
      * @param  arguments  values to be formatted in the {@link 
java.text.MessageFormat} pattern.
      */
-    public final void warning(final Class<?> caller, final String method, 
final short key, final Object... arguments) {
+    protected final void warning(final Class<?> caller, final String method, 
final short key, final Object... arguments) {
         warning(decoder.listeners, caller, method, null, null, key, arguments);
     }
 
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 7ef2cd1..0505744 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
@@ -369,7 +369,7 @@ final class VariableWrapper extends Variable {
      * if Apache SIS can not determine that range, that method is invoked.
      */
     @Override
-    public NumberRange<?> getRangeFallback() {
+    protected NumberRange<?> getRangeFallback() {
         if (variable instanceof EnhanceScaleMissing) {
             final EnhanceScaleMissing ev = (EnhanceScaleMissing) variable;
             if (ev.hasInvalidData()) {
diff --git 
a/storage/sis-netcdf/src/main/java/org/apache/sis/storage/netcdf/NetcdfStore.java
 
b/storage/sis-netcdf/src/main/java/org/apache/sis/storage/netcdf/NetcdfStore.java
index a893bb4..f67c977 100644
--- 
a/storage/sis-netcdf/src/main/java/org/apache/sis/storage/netcdf/NetcdfStore.java
+++ 
b/storage/sis-netcdf/src/main/java/org/apache/sis/storage/netcdf/NetcdfStore.java
@@ -32,6 +32,7 @@ import org.apache.sis.storage.UnsupportedStorageException;
 import org.apache.sis.storage.StorageConnector;
 import org.apache.sis.storage.Aggregate;
 import org.apache.sis.internal.netcdf.Decoder;
+import org.apache.sis.internal.netcdf.RasterResource;
 import org.apache.sis.internal.storage.URIDataStore;
 import org.apache.sis.internal.util.UnmodifiableArrayList;
 import org.apache.sis.internal.util.Strings;
@@ -200,7 +201,7 @@ public class NetcdfStore extends DataStore implements 
Aggregate {
     public synchronized Collection<Resource> components() throws 
DataStoreException {
         if (components == null) try {
             Resource[] resources = decoder.getDiscreteSampling();
-            final List<Resource> grids = GridResource.create(decoder);
+            final List<Resource> grids = RasterResource.create(decoder);
             if (!grids.isEmpty()) {
                 grids.addAll(UnmodifiableArrayList.wrap(resources));
                 resources = grids.toArray(new Resource[grids.size()]);

Reply via email to