[sis] branch geoapi-4.0 updated: Requested resolution needs to be converted to coverage resolution in a multi-resolution grid resource.

2022-02-24 Thread desruisseaux
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 e1d1015  Requested resolution needs to be converted to coverage 
resolution in a multi-resolution grid resource.
e1d1015 is described below

commit e1d10154dd29d87140c5372083884a2625733483
Author: Martin Desruisseaux 
AuthorDate: Thu Feb 24 16:36:02 2022 +0100

Requested resolution needs to be converted to coverage resolution in a 
multi-resolution grid resource.
---
 .../org/apache/sis/coverage/grid/GridGeometry.java |  2 +-
 .../sis/storage/geotiff/MultiResolutionImage.java  | 62 ++
 2 files changed, 54 insertions(+), 10 deletions(-)

diff --git 
a/core/sis-feature/src/main/java/org/apache/sis/coverage/grid/GridGeometry.java 
b/core/sis-feature/src/main/java/org/apache/sis/coverage/grid/GridGeometry.java
index 0ef45e2..1987d8a 100644
--- 
a/core/sis-feature/src/main/java/org/apache/sis/coverage/grid/GridGeometry.java
+++ 
b/core/sis-feature/src/main/java/org/apache/sis/coverage/grid/GridGeometry.java
@@ -1260,7 +1260,7 @@ public class GridGeometry implements LenientComparable, 
Serializable {
 }
 
 /**
- * Returns {@code true} if all the parameters specified by the argument 
are set.
+ * Returns {@code true} if all the properties specified by the argument 
are set.
  * If this method returns {@code true}, then invoking the corresponding 
getter
  * methods will not throw {@link IncompleteGridGeometryException}.
  *
diff --git 
a/storage/sis-geotiff/src/main/java/org/apache/sis/storage/geotiff/MultiResolutionImage.java
 
b/storage/sis-geotiff/src/main/java/org/apache/sis/storage/geotiff/MultiResolutionImage.java
index 2c35a2d..6247dec 100644
--- 
a/storage/sis-geotiff/src/main/java/org/apache/sis/storage/geotiff/MultiResolutionImage.java
+++ 
b/storage/sis-geotiff/src/main/java/org/apache/sis/storage/geotiff/MultiResolutionImage.java
@@ -19,8 +19,13 @@ package org.apache.sis.storage.geotiff;
 import java.util.List;
 import java.util.Arrays;
 import java.io.IOException;
+import org.opengis.util.FactoryException;
+import org.opengis.geometry.DirectPosition;
 import org.opengis.referencing.datum.PixelInCell;
+import org.opengis.referencing.operation.MathTransform;
 import org.opengis.referencing.operation.TransformException;
+import org.opengis.referencing.operation.CoordinateOperation;
+import org.opengis.referencing.crs.CoordinateReferenceSystem;
 import org.apache.sis.coverage.grid.GridExtent;
 import org.apache.sis.coverage.grid.GridGeometry;
 import org.apache.sis.coverage.grid.GridCoverage;
@@ -30,6 +35,7 @@ import org.apache.sis.storage.DataStoreReferencingException;
 import org.apache.sis.internal.storage.GridResourceWrapper;
 import org.apache.sis.internal.referencing.DirectPositionView;
 import org.apache.sis.referencing.operation.matrix.MatrixSIS;
+import org.apache.sis.referencing.CRS;
 
 
 /**
@@ -57,6 +63,12 @@ final class MultiResolutionImage extends GridResourceWrapper 
{
 private final double[][] resolutions;
 
 /**
+ * The last coordinate operation returned by {@link 
#getTransformFrom(CoordinateReferenceSystem)}.
+ * Used as an optimization in the common case where the same CRS is used 
for many requests.
+ */
+private volatile CoordinateOperation lastOperation;
+
+/**
  * Creates a multi-resolution images with all the given reduced-resolution 
(overview) images,
  * from finest resolution to coarsest resolution. The full-resolution 
image shall be at index 0.
  */
@@ -155,6 +167,45 @@ final class MultiResolutionImage extends 
GridResourceWrapper {
 }
 
 /**
+ * Converts a resolution from units in the given CRS to units of this 
coverage CRS.
+ *
+ * @param  domain  the geometry from which to get the resolution.
+ * @return resolution from the given grid geometry in units of this 
coverage CRS, or {@code null}.
+ */
+private double[] getResolution(final GridGeometry domain) throws 
DataStoreException {
+if (domain == null || !domain.isDefined(GridGeometry.RESOLUTION)) {
+return null;
+}
+double[] resolution = domain.getResolution(true);
+if (domain.isDefined(GridGeometry.CRS | GridGeometry.ENVELOPE)) try {
+final CoordinateReferenceSystem crs = 
domain.getCoordinateReferenceSystem();
+CoordinateOperation op = lastOperation;
+if (op == null || !crs.equals(op.getTargetCRS())) {
+final GridGeometry gg = getGridGeometry();
+op = CRS.findOperation(crs, gg.getCoordinateReferenceSystem(), 
gg.getGeographicExtent().orElse(null));
+lastOperation = op;
+}
+final MathTransform sourceToCoverage = op.getMathTransform();
+if (!sourceToCoverage.isIdentity()) {
+   

[sis] 01/01: Merge branch 'geoapi-3.1'. Those commits add support for ESRI "GeogTran" WKT element.

2022-02-24 Thread desruisseaux
This is an automated email from the ASF dual-hosted git repository.

desruisseaux pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/sis.git

commit 0d6fead43e856e023f31d2bb9cc28b59e3460dc1
Merge: 01af141 83156f2
Author: Martin Desruisseaux 
AuthorDate: Thu Feb 24 11:36:33 2022 +0100

Merge branch 'geoapi-3.1'.
Those commits add support for ESRI "GeogTran" WKT element.

 .../sis/internal/referencing/WKTKeywords.java  |  5 +-
 .../provider/CoordinateFrameRotation2D.java|  4 +-
 .../provider/GeocentricTranslation2D.java  |  4 +-
 .../provider/PositionVector7Param2D.java   |  4 +-
 .../apache/sis/io/wkt/GeodeticObjectParser.java| 79 ++
 .../operation/AbstractCoordinateOperation.java | 53 +--
 .../sis/io/wkt/GeodeticObjectParserTest.java   | 41 ++-
 .../java/org/apache/sis/io/wkt/WKTFormatTest.java  | 55 +--
 .../apache/sis/storage/geotiff/GeoTiffStore.java   |  3 +
 .../sis/storage/geotiff/GeoTiffStoreProvider.java  |  2 +-
 .../org/apache/sis/storage/netcdf/NetcdfStore.java | 40 ---
 11 files changed, 247 insertions(+), 43 deletions(-)



[sis] branch master updated (01af141 -> 0d6fead)

2022-02-24 Thread desruisseaux
This is an automated email from the ASF dual-hosted git repository.

desruisseaux pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/sis.git.


from 01af141  Merge branch 'geoapi-3.1'
 add 27b60b2  Parse GEOGTRAN element from ESRI WKT.
 add 31beb1f  Add formatting support for ESRI WKT "GeogTran" element.
 add 59c2142  Release more resources when NetCDF or GeoTIFF data store is 
closed.
 add 83156f2  Merge branch 'geoapi-4.0' into geoapi-3.1
 new 0d6fead  Merge branch 'geoapi-3.1'. Those commits add support for ESRI 
"GeogTran" WKT element.

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .../sis/internal/referencing/WKTKeywords.java  |  5 +-
 .../provider/CoordinateFrameRotation2D.java|  4 +-
 .../provider/GeocentricTranslation2D.java  |  4 +-
 .../provider/PositionVector7Param2D.java   |  4 +-
 .../apache/sis/io/wkt/GeodeticObjectParser.java| 79 ++
 .../operation/AbstractCoordinateOperation.java | 53 +--
 .../sis/io/wkt/GeodeticObjectParserTest.java   | 41 ++-
 .../java/org/apache/sis/io/wkt/WKTFormatTest.java  | 55 +--
 .../apache/sis/storage/geotiff/GeoTiffStore.java   |  3 +
 .../sis/storage/geotiff/GeoTiffStoreProvider.java  |  2 +-
 .../org/apache/sis/storage/netcdf/NetcdfStore.java | 40 ---
 11 files changed, 247 insertions(+), 43 deletions(-)


[sis] 01/01: Merge branch 'geoapi-4.0' into geoapi-3.1

2022-02-24 Thread desruisseaux
This is an automated email from the ASF dual-hosted git repository.

desruisseaux pushed a commit to branch geoapi-3.1
in repository https://gitbox.apache.org/repos/asf/sis.git

commit 83156f2cc164fd158eb4537501bdf476c3a1fb55
Merge: 4f07986 59c2142
Author: Martin Desruisseaux 
AuthorDate: Thu Feb 24 11:31:16 2022 +0100

Merge branch 'geoapi-4.0' into geoapi-3.1

 .../sis/internal/referencing/WKTKeywords.java  |  5 +-
 .../provider/CoordinateFrameRotation2D.java|  4 +-
 .../provider/GeocentricTranslation2D.java  |  4 +-
 .../provider/PositionVector7Param2D.java   |  4 +-
 .../apache/sis/io/wkt/GeodeticObjectParser.java| 79 ++
 .../operation/AbstractCoordinateOperation.java | 53 +--
 .../sis/io/wkt/GeodeticObjectParserTest.java   | 41 ++-
 .../java/org/apache/sis/io/wkt/WKTFormatTest.java  | 55 +--
 .../apache/sis/storage/geotiff/GeoTiffStore.java   |  3 +
 .../sis/storage/geotiff/GeoTiffStoreProvider.java  |  2 +-
 .../org/apache/sis/storage/netcdf/NetcdfStore.java | 40 ---
 11 files changed, 247 insertions(+), 43 deletions(-)


[sis] branch geoapi-3.1 updated (4f07986 -> 83156f2)

2022-02-24 Thread desruisseaux
This is an automated email from the ASF dual-hosted git repository.

desruisseaux pushed a change to branch geoapi-3.1
in repository https://gitbox.apache.org/repos/asf/sis.git.


from 4f07986  Merge branch 'geoapi-4.0' into geoapi-3.1
 add 27b60b2  Parse GEOGTRAN element from ESRI WKT.
 add 31beb1f  Add formatting support for ESRI WKT "GeogTran" element.
 add 59c2142  Release more resources when NetCDF or GeoTIFF data store is 
closed.
 new 83156f2  Merge branch 'geoapi-4.0' into geoapi-3.1

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .../sis/internal/referencing/WKTKeywords.java  |  5 +-
 .../provider/CoordinateFrameRotation2D.java|  4 +-
 .../provider/GeocentricTranslation2D.java  |  4 +-
 .../provider/PositionVector7Param2D.java   |  4 +-
 .../apache/sis/io/wkt/GeodeticObjectParser.java| 79 ++
 .../operation/AbstractCoordinateOperation.java | 53 +--
 .../sis/io/wkt/GeodeticObjectParserTest.java   | 41 ++-
 .../java/org/apache/sis/io/wkt/WKTFormatTest.java  | 55 +--
 .../apache/sis/storage/geotiff/GeoTiffStore.java   |  3 +
 .../sis/storage/geotiff/GeoTiffStoreProvider.java  |  2 +-
 .../org/apache/sis/storage/netcdf/NetcdfStore.java | 40 ---
 11 files changed, 247 insertions(+), 43 deletions(-)


[sis] 01/02: Add formatting support for ESRI WKT "GeogTran" element.

2022-02-24 Thread desruisseaux
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 31beb1f10f7dc67b6a6ab6254b192966db3ec0a0
Author: Martin Desruisseaux 
AuthorDate: Thu Feb 24 11:02:20 2022 +0100

Add formatting support for ESRI WKT "GeogTran" element.
---
 .../apache/sis/io/wkt/GeodeticObjectParser.java|  4 +-
 .../operation/AbstractCoordinateOperation.java | 53 ++---
 .../sis/io/wkt/GeodeticObjectParserTest.java   |  3 +-
 .../java/org/apache/sis/io/wkt/WKTFormatTest.java  | 55 +++---
 4 files changed, 98 insertions(+), 17 deletions(-)

diff --git 
a/core/sis-referencing/src/main/java/org/apache/sis/io/wkt/GeodeticObjectParser.java
 
b/core/sis-referencing/src/main/java/org/apache/sis/io/wkt/GeodeticObjectParser.java
index 3ed1bf7..e47ebdf 100644
--- 
a/core/sis-referencing/src/main/java/org/apache/sis/io/wkt/GeodeticObjectParser.java
+++ 
b/core/sis-referencing/src/main/java/org/apache/sis/io/wkt/GeodeticObjectParser.java
@@ -2264,8 +2264,8 @@ class GeodeticObjectParser extends MathTransformParser 
implements Comparatorproperties = 
parseParametersAndClose(element, name, method);
 try {
diff --git 
a/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/AbstractCoordinateOperation.java
 
b/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/AbstractCoordinateOperation.java
index 80eaa44..334951d 100644
--- 
a/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/AbstractCoordinateOperation.java
+++ 
b/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/AbstractCoordinateOperation.java
@@ -34,6 +34,7 @@ import org.opengis.metadata.Identifier;
 import org.opengis.metadata.extent.Extent;
 import org.opengis.metadata.quality.PositionalAccuracy;
 import org.opengis.referencing.IdentifiedObject;
+import org.opengis.referencing.crs.GeographicCRS;
 import org.opengis.referencing.crs.GeneralDerivedCRS;
 import org.opengis.referencing.crs.CoordinateReferenceSystem;
 import org.opengis.referencing.operation.ConcatenatedOperation;
@@ -71,6 +72,7 @@ import org.apache.sis.internal.util.CollectionsExt;
 import org.apache.sis.internal.util.UnmodifiableArrayList;
 import org.apache.sis.internal.system.Semaphores;
 import org.apache.sis.internal.system.Loggers;
+import org.apache.sis.io.wkt.Convention;
 
 import static org.apache.sis.util.Utilities.deepEquals;
 
@@ -103,7 +105,7 @@ import static org.apache.sis.util.Utilities.deepEquals;
  * synchronization.
  *
  * @author  Martin Desruisseaux (IRD, Geomatys)
- * @version 0.8
+ * @version 1.2
  * @since   0.6
  * @module
  */
@@ -934,6 +936,17 @@ check:  for (int isTarget=0; ; isTarget++) {// 
0 == source check; 1
 /**
  * Formats this coordinate operation in Well Known Text (WKT) version 2 
format.
  *
+ * ESRI extension
+ * Coordinate operations can not be formatted in standard WKT 1 format, 
but an ESRI variant of WKT 1
+ * allows a subset of coordinate operations with the ESRI-specific {@code 
GEOGTRAN} keyword.
+ * To enabled this variant, {@link org.apache.sis.io.wkt.WKTFormat} can be 
configured as below:
+ *
+ * {@preformat java
+ * format = new WKTFormat(null, null);
+ * format.setConvention(Convention.WKT1_IGNORE_AXES);
+ * format.setNameAuthority(Citations.ESRI);
+ * }
+ *
  * @param  formatter  the formatter to use.
  * @return {@code "CoordinateOperation"}.
  *
@@ -943,6 +956,10 @@ check:  for (int isTarget=0; ; isTarget++) {// 
0 == source check; 1
 protected String formatTo(final Formatter formatter) {
 super.formatTo(formatter);
 formatter.newLine();
+final CoordinateReferenceSystem sourceCRS = getSourceCRS();
+final CoordinateReferenceSystem targetCRS = getTargetCRS();
+final Convention convention = formatter.getConvention();
+final boolean isWKT1 = (convention.majorVersion() == 1);
 /*
  * If the WKT is a component of a ConcatenatedOperation, do not format 
the source CRS since it is identical
  * to the target CRS of the previous step, or to the source CRS of the 
enclosing "ConcatenatedOperation" if
@@ -954,9 +971,18 @@ check:  for (int isTarget=0; ; isTarget++) {// 
0 == source check; 1
 final FormattableObject enclosing = formatter.getEnclosingElement(1);
 final boolean isSubOperation = (enclosing instanceof 
PassThroughOperation);
 final boolean isComponent= (enclosing instanceof 
ConcatenatedOperation);
+boolean isGeogTran = false;
 if (!isSubOperation && !isComponent) {
-append(formatter, getSourceCRS(), WKTKeywords.SourceCRS);
-append(formatter, getTargetCRS(), WKTKeywords.TargetCRS);
+isGeogTran = isWKT1 && (sourceCRS instanceof 

[sis] branch geoapi-4.0 updated (27b60b2 -> 59c2142)

2022-02-24 Thread desruisseaux
This is an automated email from the ASF dual-hosted git repository.

desruisseaux pushed a change to branch geoapi-4.0
in repository https://gitbox.apache.org/repos/asf/sis.git.


from 27b60b2  Parse GEOGTRAN element from ESRI WKT.
 new 31beb1f  Add formatting support for ESRI WKT "GeogTran" element.
 new 59c2142  Release more resources when NetCDF or GeoTIFF data store is 
closed.

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .../apache/sis/io/wkt/GeodeticObjectParser.java|  4 +-
 .../operation/AbstractCoordinateOperation.java | 53 ++---
 .../sis/io/wkt/GeodeticObjectParserTest.java   |  3 +-
 .../java/org/apache/sis/io/wkt/WKTFormatTest.java  | 55 +++---
 .../apache/sis/storage/geotiff/GeoTiffStore.java   |  3 ++
 .../sis/storage/geotiff/GeoTiffStoreProvider.java  |  2 +-
 .../org/apache/sis/storage/netcdf/NetcdfStore.java | 40 
 7 files changed, 133 insertions(+), 27 deletions(-)


[sis] 02/02: Release more resources when NetCDF or GeoTIFF data store is closed.

2022-02-24 Thread desruisseaux
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 59c2142957f052400ae237bb15a1b63aa9001e42
Author: Martin Desruisseaux 
AuthorDate: Thu Feb 24 11:23:22 2022 +0100

Release more resources when NetCDF or GeoTIFF data store is closed.
---
 .../apache/sis/storage/geotiff/GeoTiffStore.java   |  3 ++
 .../sis/storage/geotiff/GeoTiffStoreProvider.java  |  2 +-
 .../org/apache/sis/storage/netcdf/NetcdfStore.java | 40 +-
 3 files changed, 35 insertions(+), 10 deletions(-)

diff --git 
a/storage/sis-geotiff/src/main/java/org/apache/sis/storage/geotiff/GeoTiffStore.java
 
b/storage/sis-geotiff/src/main/java/org/apache/sis/storage/geotiff/GeoTiffStore.java
index 0ef534a..779c92d 100644
--- 
a/storage/sis-geotiff/src/main/java/org/apache/sis/storage/geotiff/GeoTiffStore.java
+++ 
b/storage/sis-geotiff/src/main/java/org/apache/sis/storage/geotiff/GeoTiffStore.java
@@ -372,6 +372,8 @@ public class GeoTiffStore extends DataStore implements 
Aggregate {
 
 /**
  * Returns the reader if it is not closed, or thrown an exception 
otherwise.
+ *
+ * @see #close()
  */
 private Reader reader() throws DataStoreException {
 final Reader r = reader;
@@ -499,6 +501,7 @@ public class GeoTiffStore extends DataStore implements 
Aggregate {
 public synchronized void close() throws DataStoreException {
 final Reader r = reader;
 reader = null;
+components = null;
 if (r != null) try {
 r.close();
 } catch (IOException e) {
diff --git 
a/storage/sis-geotiff/src/main/java/org/apache/sis/storage/geotiff/GeoTiffStoreProvider.java
 
b/storage/sis-geotiff/src/main/java/org/apache/sis/storage/geotiff/GeoTiffStoreProvider.java
index a150790..f59ec4d 100644
--- 
a/storage/sis-geotiff/src/main/java/org/apache/sis/storage/geotiff/GeoTiffStoreProvider.java
+++ 
b/storage/sis-geotiff/src/main/java/org/apache/sis/storage/geotiff/GeoTiffStoreProvider.java
@@ -47,7 +47,7 @@ import org.apache.sis.internal.util.Constants;
  * @since 0.8
  * @module
  */
-@StoreMetadata(formatName   = "GeoTIFF",
+@StoreMetadata(formatName   = Constants.GEOTIFF,
fileSuffixes = {"tiff", "tif"},
capabilities = Capability.READ)
 public class GeoTiffStoreProvider extends DataStoreProvider {
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 3f6f801..921315c 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
@@ -18,6 +18,7 @@ package org.apache.sis.storage.netcdf;
 
 import java.io.IOException;
 import java.nio.file.Path;
+import java.nio.file.StandardOpenOption;
 import java.net.URI;
 import java.util.List;
 import java.util.Collection;
@@ -38,6 +39,7 @@ import org.apache.sis.internal.storage.URIDataStore;
 import org.apache.sis.internal.util.UnmodifiableArrayList;
 import org.apache.sis.internal.util.Strings;
 import org.apache.sis.setup.OptionKey;
+import org.apache.sis.storage.DataStoreClosedException;
 import org.apache.sis.storage.Resource;
 import org.apache.sis.storage.event.StoreEvent;
 import org.apache.sis.storage.event.StoreListener;
@@ -56,7 +58,7 @@ import ucar.nc2.constants.CDM;
  * Instances of this data store are created by {@link 
NetcdfStoreProvider#open(StorageConnector)}.
  *
  * @author  Martin Desruisseaux (Geomatys)
- * @version 1.1
+ * @version 1.2
  *
  * @see NetcdfStoreProvider
  *
@@ -67,8 +69,11 @@ public class NetcdfStore extends DataStore implements 
Aggregate {
 /**
  * The object to use for decoding the netCDF file content. There is two 
different implementations,
  * depending on whether we are using the embedded SIS decoder or a wrapper 
around the UCAR library.
+ * This is set to {@code null} when the data store is closed.
+ *
+ * @see #decoder()
  */
-private final Decoder decoder;
+private Decoder decoder;
 
 /**
  * The {@link NetcdfStoreProvider#LOCATION} parameter value, or {@code 
null} if none.
@@ -152,7 +157,7 @@ public class NetcdfStore extends DataStore implements 
Aggregate {
  * @since 0.8
  */
 public synchronized Version getConventionVersion() throws 
DataStoreException {
-for (final CharSequence value : 
CharSequences.split(decoder.stringValue(CDM.CONVENTIONS), ',')) {
+for (final CharSequence value : 
CharSequences.split(decoder().stringValue(CDM.CONVENTIONS), ',')) {
 if (CharSequences.regionMatches(value, 0, "CF-", true)) {
 return new Version(value.subSequence(3, 
value.length()).toString());
 }
@@ -170,7 +175,7 @@ public class NetcdfStore extends DataStore implements 
Aggregate {