You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sis.apache.org by de...@apache.org on 2022/07/11 15:17:21 UTC

[sis] branch master updated (09d75edb69 -> 3362ae7b9b)

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 09d75edb69 Merge branch 'geoapi-3.1'
     add 4bce208f4d Replace "Proj.4" by "PROJ" when refering to the project. We keep "Proj4" as the namespace for PROJ-specific parameters because those parameters were defined before PROJ 6 provided full EPSG support.
     add 06e6987fd0 First draft of a limit applied (at visualisation time) on image reprojection. This is for preventing exceptions when rendering a world image in Mercator. For now we check only the World Mercator projection, but other cases should be added progressively in the future.
     add 7af56f6285 Replace `ProjectionLimits` by a more reliable mechanism defined directly in `MathTransform` implementations. For now only `Mercator` and `TransverseMercator` defines those limit. More will be added in the future.
     add c71a1d11dc Better implementation of `getDomain(…)` on inverse transforms. Remove infinite values in Mercator.getDomain(…).
     add 29beeb7358 Add `getDomain(…)` implementations for a few more map projections (only the easiest cases).
     add d41d7fa838 Make a better use of new `MathTransforms.getDomain(…)` API in JavaFX viewer.
     add 9be9ddb65a Add a safety against some invalid LZW compressions (missing EOI code).
     add 677f463a3a Improve by 20~30% the performance of LZW decompression by avoiding to create too many small arrays.
     add 04d4eee7a7 Documentation, renaming or minor reorganization. No significant code change in this commit.
     add 69f581c4ae Switch the position of offset and length in `entriesForCodes` bit patterns. It makes easier the use of compressed offset in next commit.
     add 35b5576064 Allocate memory for new entries by blocks of 4 bytes instead of doing an unconditional allocation for each new entry. It reduces the amount of calls to `System.arraycopy(…)` by a factor close to 4 and also reduces memory consumption. The performance improvement was not as expected; this new version is even a bit slower than the one in previous commit. It is a little bit surprising because a code block with branching, bounds checks and copies should be executed less oft [...]
     add 705de4a756 Try harder to resolve ambiguity when axis type is X, Y or Z.
     add 8c09e2f76d Finish filling the buffer before to return from LSW decompression method. Documentation fix.
     add fbbd6525a8 Add a convenience method for testing if a floating-point value is an integer.
     add 7447b8c95c Replace "resample" operation by a much more efficient "translate grid" operation when the resampling is a translation of the grid by an integer amount of cells.
     add a2b029fb19 Prevent the replacement by source coverage in a situation where it should not be done. Report the existence of a source coverage in `toString()` output. Clarifications in documentation.
     add a55b18b3b3 Transfer of pixel data from Java2D image to JavaFX image should be scheduled to occur just before a JavaFX pulse. It seems to resolve the mysterious flickering effects that happened for so long.
     add 021178f9d9 Avoid a stack overflow when `getDomain(…)` is invoked on a chain of transforms which contains a `WrapAroundTransform`.
     add edabd5aee9 Avoid a rounding error which caused the creation of unnecessary concatenated transforms.
     add 43debe04f2 Merge branch 'geoapi-4.0' into geoapi-3.1
     new 3362ae7b9b Merge branch '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:
 .../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(-)
 create mode 100644 core/sis-feature/src/main/java/org/apache/sis/coverage/grid/DerivedGridCoverage.java
 create mode 100644 core/sis-feature/src/main/java/org/apache/sis/coverage/grid/TranslatedGridCoverage.java
 create mode 100644 core/sis-feature/src/test/java/org/apache/sis/coverage/grid/TranslatedGridCoverageTest.java
 create mode 100644 core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/DomainDefinition.java
 create mode 100644 core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/transform/DomainDefinitionTest.java


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

Posted by de...@apache.org.
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 <ma...@geomatys.com>
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});