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 3362ae7b9b6dd184d11e40ca207e3efb462c99e3
Merge: 09d75edb69 43debe04f2
Author: Martin Desruisseaux <[email protected]>
AuthorDate: Mon Jul 11 15:32:44 2022 +0200

    Merge branch 'geoapi-3.1'

 .../java/org/apache/sis/gui/map/MapCanvasAWT.java  |  26 +-
 .../sis/coverage/grid/ConvertedGridCoverage.java   |  62 ++--
 .../sis/coverage/grid/DerivedGridCoverage.java     | 146 +++++++++
 .../coverage/grid/FractionalGridCoordinates.java   |   4 +-
 .../sis/coverage/grid/GridCoverageProcessor.java   | 151 ++++++++-
 .../apache/sis/coverage/grid/GridEvaluator.java    |   6 +
 .../org/apache/sis/coverage/grid/GridExtent.java   |  10 +-
 .../sis/coverage/grid/ResampledGridCoverage.java   |  69 ++--
 .../sis/coverage/grid/TranslatedGridCoverage.java  | 127 ++++++++
 .../internal/processing/image/IsolineTracer.java   |   5 +-
 .../coverage/grid/ResampledGridCoverageTest.java   |  35 +-
 .../coverage/grid/TranslatedGridCoverageTest.java  |  85 +++++
 .../apache/sis/test/suite/FeatureTestSuite.java    |   3 +-
 .../sis/metadata/iso/citation/Citations.java       |   7 +-
 .../apache/sis/metadata/sql/MetadataFallback.java  |  10 +-
 .../org/apache/sis/metadata/sql/Citations.sql      |   6 +-
 .../sis/metadata/iso/citation/CitationsTest.java   |   2 +-
 .../sis/metadata/sql/MetadataSourceTest.java       |   2 +-
 .../sis/internal/map/coverage/RenderingData.java   |  14 +-
 .../java/org/apache/sis/geometry/Shapes2D.java     |  22 +-
 .../internal/referencing/WraparoundApplicator.java |  27 +-
 .../main/java/org/apache/sis/referencing/CRS.java  |   2 +-
 .../sis/referencing/operation/matrix/Matrices.java |   4 +-
 .../projection/LambertConicConformal.java          |  21 +-
 .../referencing/operation/projection/Mercator.java |  17 +
 .../operation/projection/NormalizedProjection.java |   6 +-
 .../operation/projection/PolarStereographic.java   |  19 +-
 .../operation/projection/TransverseMercator.java   |  27 +-
 .../operation/projection/ZonedGridSystem.java      |  21 +-
 .../operation/projection/package-info.java         |   3 +-
 .../operation/transform/AbstractMathTransform.java |  71 +++-
 .../operation/transform/ConcatenatedTransform.java |  22 +-
 .../operation/transform/DomainDefinition.java      | 284 ++++++++++++++++
 .../operation/transform/MathTransforms.java        |  29 +-
 .../operation/transform/WraparoundTransform.java   |  13 +-
 .../operation/projection/AlbersEqualAreaTest.java  |   4 +-
 .../projection/CylindricalEqualAreaTest.java       |   2 +-
 .../operation/projection/SinusoidalTest.java       |   4 +-
 .../operation/transform/DomainDefinitionTest.java  |  52 +++
 .../operation/transform/PseudoTransform.java       |  67 +++-
 .../sis/test/integration/ConsistencyTest.java      |   4 +-
 .../sis/test/suite/ReferencingTestSuite.java       |   3 +-
 .../org/apache/sis/internal/util/Constants.java    |   2 +
 .../org/apache/sis/internal/util/Numerics.java     |  19 +-
 .../org/apache/sis/math/LinearlyDerivedVector.java |   3 +-
 .../src/main/java/org/apache/sis/math/Vector.java  |   4 +-
 .../apache/sis/internal/storage/inflater/LZW.java  | 360 ++++++++++++++++-----
 .../org/apache/sis/internal/netcdf/AxisType.java   |  48 ++-
 .../org/apache/sis/internal/netcdf/Variable.java   |   5 +
 .../storage/io/ChannelImageInputStream.java        |   2 +-
 50 files changed, 1698 insertions(+), 239 deletions(-)

diff --cc 
core/sis-feature/src/main/java/org/apache/sis/coverage/grid/TranslatedGridCoverage.java
index 0000000000,81bb354bbe..bc4ece6a48
mode 000000,100644..100644
--- 
a/core/sis-feature/src/main/java/org/apache/sis/coverage/grid/TranslatedGridCoverage.java
+++ 
b/core/sis-feature/src/main/java/org/apache/sis/coverage/grid/TranslatedGridCoverage.java
@@@ -1,0 -1,127 +1,127 @@@
+ /*
+  * Licensed to the Apache Software Foundation (ASF) under one or more
+  * contributor license agreements.  See the NOTICE file distributed with
+  * this work for additional information regarding copyright ownership.
+  * The ASF licenses this file to You under the Apache License, Version 2.0
+  * (the "License"); you may not use this file except in compliance with
+  * the License.  You may obtain a copy of the License at
+  *
+  *     http://www.apache.org/licenses/LICENSE-2.0
+  *
+  * Unless required by applicable law or agreed to in writing, software
+  * distributed under the License is distributed on an "AS IS" BASIS,
+  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  * See the License for the specific language governing permissions and
+  * limitations under the License.
+  */
+ package org.apache.sis.coverage.grid;
+ 
+ import java.awt.image.RenderedImage;
+ 
+ // Branch-dependent imports
 -import org.opengis.coverage.CannotEvaluateException;
++import org.apache.sis.coverage.CannotEvaluateException;
+ 
+ 
+ /**
+  * A grid coverage with the same data than the source coverage,
+  * with only a translation applied on grid coordinates.
+  *
+  * @author  Martin Desruisseaux (Geomatys)
+  * @version 1.3
+  * @since   1.3
+  * @module
+  */
+ final class TranslatedGridCoverage extends DerivedGridCoverage {
+     /**
+      * The translation to apply on the argument given to {@link 
#render(GridExtent)}
+      * before to delegate to the source. This is the conversion from this 
coverage to
+      * the source coverage.
+      */
+     private final long[] translation;
+ 
+     /**
+      * Constructs a new grid coverage which will delegate the rendering 
operation to the given source.
+      * This coverage will take the same sample dimensions than the source.
+      *
+      * @param  source       the source on which to delegate rendering 
operations.
+      * @param  domain       the grid extent, CRS and conversion from cell 
indices to CRS.
+      * @param  translation  translation to apply on the argument given to 
{@link #render(GridExtent)}.
+      */
+     private TranslatedGridCoverage(final GridCoverage source, final 
GridGeometry domain, final long[] translation) {
+         super(source, domain);
+         this.translation = translation;
+     }
+ 
+     /**
+      * Returns a grid coverage which will use the {@code domain} grid 
geometry.
+      * This coverage will take the same sample dimensions than the source.
+      *
+      * @param  source       the source on which to delegate rendering 
operations.
+      * @param  domain       the geometry of the grid coverage to return, or 
{@code null} for automatic.
+      * @param  translation  translation to apply on the argument given to 
{@link #render(GridExtent)}.
+      * @return the coverage. May be the {@code source} returned as-is.
+      */
+     static GridCoverage create(GridCoverage source, GridGeometry domain, 
long[] translation,
+                                final boolean allowSourceReplacement)
+     {
+         if (allowSourceReplacement) {
+             while (source instanceof TranslatedGridCoverage) {
+                 final TranslatedGridCoverage tc = (TranslatedGridCoverage) 
source;
+                 final long[] shifted = tc.translation.clone();
+                 long tm = 0;
+                 for (int i = Math.min(shifted.length, translation.length); 
--i >= 0;) {
+                     shifted[i] = Math.addExact(shifted[i], translation[i]);
+                     tm |= translation[i];
+                 }
+                 if (tm == 0) return tc;         // All translation terms are 
zero.
+                 translation = shifted;
+                 source = tc.source;
+             }
+         }
+         final GridGeometry gridGeometry = source.getGridGeometry();
+         if (domain == null) {
+             domain = gridGeometry.translate(translation);
+         }
+         if (domain.equals(gridGeometry)) {
+             return source;                  // All (potentially updated) 
translation terms are zero.
+         }
+         return new TranslatedGridCoverage(source, domain, translation);
+     }
+ 
+     /**
+      * Returns a grid coverage that contains real values or sample values, 
depending if {@code converted}
+      * is {@code true} or {@code false} respectively. This method delegates 
to the source and wraps the
+      * result in a {@link TranslatedGridCoverage} with the same {@linkplain 
#translation}.
+      */
+     @Override
+     public final synchronized GridCoverage forConvertedValues(final boolean 
converted) {
+         GridCoverage view = getView(converted);
+         if (view == null) {
+             final GridCoverage cs = source.forConvertedValues(converted);
+             if (cs == source) {
+                 view = this;
+             } else {
+                 view = new TranslatedGridCoverage(cs, gridGeometry, 
translation);
+             }
+             setView(converted, view);
+         }
+         return view;
+     }
+ 
+     /**
+      * Returns a two-dimensional slice of grid data as a rendered image.
+      * This method translates the {@code sliceExtent} argument, then 
delegates to the {@linkplain #source source}.
+      * It is okay to use the source result as-is because image coordinates 
are relative to the request;
+      * the rendered image shall not be translated.
+      */
+     @Override
+     public RenderedImage render(GridExtent sliceExtent) throws 
CannotEvaluateException {
+         if (sliceExtent == null) {
+             sliceExtent = gridGeometry.extent;
+         }
+         if (sliceExtent != null) {
+             sliceExtent = sliceExtent.translate(translation);
+         }
+         return source.render(sliceExtent);
+     }
+ }
diff --cc 
core/sis-metadata/src/test/java/org/apache/sis/metadata/iso/citation/CitationsTest.java
index 9e31c3c184,aa1b2df284..513de3da82
--- 
a/core/sis-metadata/src/test/java/org/apache/sis/metadata/iso/citation/CitationsTest.java
+++ 
b/core/sis-metadata/src/test/java/org/apache/sis/metadata/iso/citation/CitationsTest.java
@@@ -125,17 -124,17 +125,17 @@@ public final strictfp class CitationsTe
          assertEquals("OGC",                  getIdentifier(OGC));
          assertEquals("IOGP",                 getIdentifier(IOGP));
          assertEquals("EPSG",                 getIdentifier(EPSG));
 -        assertEquals("ESRI:ArcGIS",          getIdentifier(ESRI));
 +        assertEquals("ArcGIS",               getIdentifier(ESRI));
          assertEquals("NetCDF",               getIdentifier(NETCDF));
          assertEquals("GeoTIFF",              getIdentifier(GEOTIFF));
 -        assertEquals("Pitney Bowes:MapInfo", getIdentifier(MAP_INFO));
 +        assertEquals("MapInfo",              getIdentifier(MAP_INFO));
          assertEquals("ISBN",                 getIdentifier(ISBN));
          assertEquals("ISSN",                 getIdentifier(ISSN));
-         assertEquals("Proj4",                getIdentifier(PROJ4));           
   // Not a valid Unicode identifier.
 -        assertEquals("OSGeo:PROJ",           getIdentifier(PROJ4));           
   // Not a valid Unicode identifier.
 -        assertEquals("IHO:S-57",             getIdentifier(S57));             
   // Not a valid Unicode identifier.
 -        assertEquals("ISO:19115-1",          
getIdentifier(ISO_19115.get(0)));   // The ':' separator is not usual in ISO 
references
 -        assertEquals("ISO:19115-2",          
getIdentifier(ISO_19115.get(1)));   // and could be changed in future SIS 
versions.
 -        assertEquals("OGC:WMS",              getIdentifier(WMS));
++        assertEquals("PROJ",                 getIdentifier(PROJ4));
 +        assertEquals("S-57",                 getIdentifier(S57));             
   // Not a valid Unicode identifier.
 +        assertEquals("19115-1",              
getIdentifier(ISO_19115.get(0)));   // The ':' separator is not usual in ISO 
references
 +        assertEquals("19115-2",              
getIdentifier(ISO_19115.get(1)));   // and could be changed in future SIS 
versions.
 +        assertEquals("WMS",                  getIdentifier(WMS));
      }
  
      /**
diff --cc core/sis-referencing/src/main/java/org/apache/sis/referencing/CRS.java
index 3b4882e0f1,95e57555c9..eac90c0ab7
--- a/core/sis-referencing/src/main/java/org/apache/sis/referencing/CRS.java
+++ b/core/sis-referencing/src/main/java/org/apache/sis/referencing/CRS.java
@@@ -786,9 -791,19 +786,9 @@@ public final class CRS extends Static 
  
      /**
       * Returns the domain of validity of the specified coordinate reference 
system, or {@code null} if unknown.
-      * If non-null, then the returned envelope will use the same coordinate 
reference system them the given CRS
+      * If non-null, then the returned envelope will use the same coordinate 
reference system than the given CRS
       * argument.
       *
 -     * <p>This method looks in two places:</p>
 -     * <ol>
 -     *   <li>First, it checks the {@linkplain 
org.apache.sis.referencing.crs.AbstractCRS#getDomainOfValidity()
 -     *       domain of validity} associated with the given CRS. Only 
geographic extents that are instances of
 -     *       {@link BoundingPolygon} associated to the given CRS are taken in 
account for this first step.</li>
 -     *   <li>If the above step did not found found any bounding polygon, then 
the
 -     *       {@linkplain #getGeographicBoundingBox(CoordinateReferenceSystem) 
geographic bounding boxes}
 -     *       are used as a fallback and transformed to the given CRS.</li>
 -     * </ol>
 -     *
       * @param  crs  the coordinate reference system, or {@code null}.
       * @return the envelope with coordinates in the given CRS, or {@code 
null} if none.
       *
diff --cc 
core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/projection/AlbersEqualAreaTest.java
index db87c4bb75,9c388547f9..d8f7afbf04
--- 
a/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/projection/AlbersEqualAreaTest.java
+++ 
b/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/projection/AlbersEqualAreaTest.java
@@@ -159,7 -162,8 +159,7 @@@ public final strictfp class AlbersEqual
       */
      @Test
      @DependsOnMethod("testEllipse")
-     public void compareWithProj4() throws FactoryException, 
TransformException {
+     public void compareWithPROJ() throws FactoryException, TransformException 
{
 -        toleranceModifier = ToleranceModifier.PROJECTION;
          tolerance = Formulas.LINEAR_TOLERANCE;
  
          // Spherical case
diff --cc 
core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/projection/CylindricalEqualAreaTest.java
index e5d526f8b8,9d34fc0528..f26ef6f5ca
--- 
a/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/projection/CylindricalEqualAreaTest.java
+++ 
b/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/projection/CylindricalEqualAreaTest.java
@@@ -71,9 -72,10 +71,9 @@@ public final strictfp class Cylindrical
                  0,          // False easting
                  0);         // False northing
          tolerance = Formulas.LINEAR_TOLERANCE;
 -        toleranceModifier = ToleranceModifier.PROJECTION;
          final double λ = 2;
          final double φ = 1;
-         final double x = 222638.98;             // Test point from Proj.4.
+         final double x = 222638.98;             // Test point from PROJ 
library.
          final double y = 110568.81;
          verifyTransform(new double[] {λ, φ,  -λ, φ,  λ, -φ,  -λ, -φ},
                          new double[] {x, y,  -x, y,  x, -y,  -x, -y});

Reply via email to