This is an automated email from the ASF dual-hosted git repository. desruisseaux pushed a commit to branch main in repository https://gitbox.apache.org/repos/asf/sis.git
commit 9c3e588d3c073e3d1c2f4211f864e8e13c098dd4 Merge: 237edefa4c d68a898653 Author: Martin Desruisseaux <martin.desruisse...@geomatys.com> AuthorDate: Wed Jul 10 16:31:45 2024 +0200 Merge branch 'geoapi-3.1' .../main/org/apache/sis/console/CommandRunner.java | 4 +- .../metadata/iso/extent/DefaultVerticalExtent.java | 4 +- .../sis/metadata/privy/ReferencingServices.java | 12 +- .../main/org/apache/sis/portrayal/Canvas.java | 2 +- .../main/org/apache/sis/geometry/Envelopes.java | 5 +- .../main/org/apache/sis/io/wkt/Convention.java | 7 -- .../main/org/apache/sis/io/wkt/Element.java | 7 +- .../sis/referencing/MultiRegisterOperations.java | 39 ------ .../internal/ParameterizedTransformBuilder.java | 7 +- .../referencing/internal/PositionTransformer.java | 27 +++-- .../apache/sis/referencing/internal/Resources.java | 4 +- .../sis/referencing/internal/Resources.properties | 2 +- .../referencing/internal/Resources_fr.properties | 2 +- .../referencing/internal/ServicesForMetadata.java | 84 ++----------- .../DefaultCoordinateOperationFactory.java | 3 + .../transform/DefaultMathTransformFactory.java | 2 - .../referencing/privy/GeodeticObjectBuilder.java | 9 +- .../DefaultCoordinateOperationFactoryTest.java | 13 +- .../projection/AuthalicConversionTest.java | 7 +- .../operation/projection/EquirectangularTest.java | 4 +- .../projection/MapProjectionTestCase.java | 5 +- .../operation/projection/MercatorTest.java | 4 +- .../operation/projection/MeridianArcTest.java | 5 +- .../projection/PolarStereographicTest.java | 4 +- .../operation/projection/ProjectionBenchmark.java | 2 +- .../projection/SatelliteTrackingTest.java | 2 +- .../operation/projection/ZonedGridSystemTest.java | 4 +- .../provider/GeocentricTranslationTest.java | 3 +- .../operation/provider/Geographic3Dto2DTest.java | 13 +- .../transform/DefaultMathTransformFactoryTest.java | 6 +- .../transform/MolodenskyTransformTest.java | 6 +- .../test/integration/CoordinateOperationTest.java | 15 ++- .../apache/sis/storage/landsat/MetadataReader.java | 22 ++-- .../sis/storage/sql/postgis/RasterReader.java | 12 +- .../org/apache/sis/io/stream/ChannelDataInput.java | 3 - .../sis/io/stream/InputStreamArrayGetter.java | 133 --------------------- .../sis/io/stream/InputStreamArrayGetterTest.java | 67 ----------- .../src/org.apache.sis.util/main/module-info.java | 1 + .../main/org/apache/sis/pending/jdk/JDK22.java | 44 +++++++ .../main/org/apache/sis/system/Environment.java | 1 + .../sis/util/collection/FrequencySortedSet.java | 17 ++- .../apache/sis/util/collection/IntegerList.java | 50 +++++++- gradle/wrapper/gradle-wrapper.jar | Bin 63721 -> 43453 bytes gradle/wrapper/gradle-wrapper.properties | 2 +- gradlew | 2 +- gradlew.bat | 20 ++-- incubator/build.gradle.kts | 2 +- netbeans-project/nbproject/project.properties | 4 +- 48 files changed, 246 insertions(+), 447 deletions(-) diff --cc endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/MultiRegisterOperations.java index d1be8b9426,07646e2cb4..78f9ba64b6 --- a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/MultiRegisterOperations.java +++ b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/MultiRegisterOperations.java @@@ -25,10 -25,10 +25,8 @@@ import java.util.Objects import java.util.Optional; import org.opengis.util.Factory; import org.opengis.util.FactoryException; - import org.opengis.metadata.citation.Citation; import org.opengis.metadata.extent.GeographicBoundingBox; - import org.opengis.referencing.IdentifiedObject; import org.opengis.referencing.AuthorityFactory; -import org.opengis.referencing.RegisterOperations; -import org.opengis.referencing.crs.SingleCRS; import org.opengis.referencing.crs.CRSFactory; import org.opengis.referencing.crs.CRSAuthorityFactory; import org.opengis.referencing.crs.CoordinateReferenceSystem; diff --cc endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/internal/PositionTransformer.java index af0bbe82bb,a647fe9ace..6351b85d53 --- a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/internal/PositionTransformer.java +++ b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/internal/PositionTransformer.java @@@ -30,17 -30,18 +30,18 @@@ import org.apache.sis.referencing.opera import org.apache.sis.geometry.GeneralDirectPosition; import org.apache.sis.util.Utilities; -// Specific to the geoapi-3.1 and geoapi-4.0 branches: -import org.opengis.coordinate.MismatchedDimensionException; -import org.opengis.referencing.RegisterOperations; +// Specific to the main branch: +import org.opengis.geometry.MismatchedDimensionException; ++import org.apache.sis.referencing.MultiRegisterOperations; /** - * A direct position capable to {@linkplain #transform transform} another position from its arbitrary CRS to - * {@linkplain #getCoordinateReferenceSystem() the CRS of this position}. This class caches the last transform - * used in order to improve performance when {@linkplain CoordinateOperation#getSourceCRS() source} - * and {@linkplain CoordinateOperation#getTargetCRS() target} CRS do not change often. - * Using this class is faster than invoking <code>{@linkplain CoordinateOperationFactory#createOperation - * CoordinateOperationFactory.createOperation}(lastCRS, targetCRS)</code> for every points. + * A direct position capable to transform another position from its arbitrary CRS to the CRS of this position. + * This class caches the last transform used in order to improve performance when + * {@linkplain CoordinateOperation#getSourceCRS() source} and + * {@linkplain CoordinateOperation#getTargetCRS() target} CRS do not change often. - * Using this class is faster than invoking <code>{@linkplain RegisterOperations#findCoordinateOperations ++ * Using this class is faster than invoking <code>{@linkplain MultiRegisterOperations#findCoordinateOperations + * RegisterOperations.findCoordinateOperations}(lastCRS, targetCRS)</code> for every points. * * <ul class="verbose"> * <li><b>Note 1:</b> @@@ -87,7 -88,7 +88,7 @@@ public final class PositionTransformer /** * The factory to use for creating new coordinate operation. */ - private final CoordinateOperationFactory factory; - private final RegisterOperations factory; ++ private final MultiRegisterOperations factory; /** * The default CRS to assume when {@link #transform(DirectPosition)} has been invoked without associated CRS. @@@ -126,7 -127,7 +127,7 @@@ * @param factory the factory to use for creating coordinate operations, or {@code null} for the default. */ public PositionTransformer(final CoordinateReferenceSystem defaultCRS, final CoordinateReferenceSystem targetCRS, - final CoordinateOperationFactory factory) - final RegisterOperations factory) ++ final MultiRegisterOperations factory) { super(targetCRS); this.defaultCRS = (defaultCRS != null) ? defaultCRS : targetCRS; diff --cc endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/internal/ServicesForMetadata.java index e4d5b83d55,7c6eb1fd3a..0d116aa85b --- a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/internal/ServicesForMetadata.java +++ b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/internal/ServicesForMetadata.java @@@ -69,26 -68,8 +68,20 @@@ import org.apache.sis.util.privy.Consta import org.apache.sis.util.resources.Vocabulary; import org.apache.sis.util.logging.Logging; -// Specific to the geoapi-3.1 and geoapi-4.0 branches: -import org.opengis.metadata.Identifier; +// Specific to the main branch: +import java.util.Map; - import org.opengis.util.NoSuchIdentifierException; +import org.opengis.util.TypeName; +import org.opengis.referencing.ReferenceIdentifier; +import org.opengis.referencing.crs.CRSFactory; +import org.opengis.referencing.cs.CSFactory; +import org.opengis.referencing.cs.CoordinateSystemAxis; - import org.opengis.referencing.operation.MathTransformFactory; - import org.opengis.referencing.operation.OperationMethod; - import org.opengis.referencing.operation.SingleOperation; +import org.opengis.referencing.datum.Datum; +import org.opengis.referencing.datum.DatumFactory; - import org.apache.sis.metadata.privy.NameToIdentifier; - import org.apache.sis.util.Deprecable; +import org.apache.sis.referencing.cs.DefaultParametricCS; +import org.apache.sis.referencing.datum.DefaultParametricDatum; +import org.apache.sis.referencing.factory.GeodeticObjectFactory; +import org.apache.sis.referencing.factory.InvalidGeodeticParameterException; +import org.apache.sis.metadata.iso.citation.DefaultCitation; /** diff --cc endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/privy/GeodeticObjectBuilder.java index 19b8371ccd,897b375bbd..ddfb55c7c2 --- a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/privy/GeodeticObjectBuilder.java +++ b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/privy/GeodeticObjectBuilder.java @@@ -61,8 -61,9 +61,9 @@@ import org.apache.sis.referencing.cs.Ax import org.apache.sis.referencing.internal.Resources; import org.apache.sis.parameter.Parameters; -// Specific to the geoapi-3.1 and geoapi-4.0 branches: -import org.opengis.referencing.ObjectDomain; -import org.opengis.referencing.operation.MathTransform; +// Specific to the main branch: +import org.apache.sis.temporal.TemporalDate; ++import org.apache.sis.referencing.operation.transform.MathTransformBuilder; /** @@@ -259,9 -260,9 +260,9 @@@ public class GeodeticObjectBuilder exte * @return {@code this}, for method calls chaining. * @throws FactoryException if the operation method cannot be obtained. */ - public GeodeticObjectBuilder setConversion(final ParameterValueGroup parameters) throws FactoryException { - method = factories.findOperationMethod(parameters.getDescriptor().getName().getCode()); - this.parameters = parameters; // Set only if above line succeed. - public GeodeticObjectBuilder setConversion(final MathTransform.Builder builder) throws FactoryException { ++ public GeodeticObjectBuilder setConversion(final MathTransformBuilder builder) throws FactoryException { + method = builder.getMethod().orElseThrow(() -> new FactoryException()); + parameters = builder.parameters(); // Set only if above line succeed. return this; } diff --cc endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/provider/GeocentricTranslationTest.java index afcafcb970,986da2a0d2..922e97f98c --- a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/provider/GeocentricTranslationTest.java +++ b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/provider/GeocentricTranslationTest.java @@@ -37,6 -37,11 +37,7 @@@ import org.apache.sis.referencing.opera import org.junit.jupiter.api.Test; import static org.junit.jupiter.api.Assertions.*; import org.apache.sis.referencing.operation.transform.MathTransformTestCase; - -// Specific to the geoapi-3.1 and geoapi-4.0 branches: -import java.util.Arrays; -import org.opengis.test.ToleranceModifier; -import org.apache.sis.referencing.datum.HardCodedDatum; ++import static org.apache.sis.referencing.privy.CoordinateOperations.builder; /** @@@ -184,7 -189,7 +185,7 @@@ public final class GeocentricTranslatio * @throws FactoryException if an error occurred while creating a transform. */ public static MathTransform createDatumShiftForGeographic2D(final MathTransformFactory factory) throws FactoryException { - final Parameters values = Parameters.castOrWrap(factory.getDefaultParameters("Geocentric translations (geog2D domain)")); - final Parameters values = Parameters.castOrWrap(factory.builder("Geocentric translations (geog2D domain)").parameters()); ++ final Parameters values = Parameters.castOrWrap(builder(factory, "Geocentric translations (geog2D domain)").parameters()); setTranslation(values); setEllipsoids(values, CommonCRS.WGS84.ellipsoid(), CommonCRS.ED50.ellipsoid()); final MathTransform gt = new GeocentricTranslation().createMathTransform(factory, values); diff --cc endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/provider/Geographic3Dto2DTest.java index b919a8808a,c9a324b527..86898f4ce1 --- a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/provider/Geographic3Dto2DTest.java +++ b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/provider/Geographic3Dto2DTest.java @@@ -30,8 -30,8 +30,9 @@@ import org.junit.jupiter.api.Test import static org.junit.jupiter.api.Assertions.*; import org.apache.sis.test.TestCase; -// Specific to the geoapi-3.1 and geoapi-4.0 branches: -import static org.opengis.test.Assertions.assertMatrixEquals; +// Specific to the main branch: +import static org.apache.sis.test.GeoapiAssert.assertMatrixEquals; ++import static org.apache.sis.referencing.privy.CoordinateOperations.builder; /** @@@ -115,14 -115,15 +116,15 @@@ public final class Geographic3Dto2DTes * Create a "Geographic to Geocentric" conversion with ellipsoid axis length units converted to metres * (the unit implied by SRC_SEMI_MAJOR) because it is the unit of Bursa-Wolf parameters that we created above. */ - Parameters step = Parameters.castOrWrap(factory.getDefaultParameters(GeographicToGeocentric.NAME)); - var builder = factory.builder(GeographicToGeocentric.NAME); ++ var builder = builder(factory, GeographicToGeocentric.NAME); + Parameters step = Parameters.castOrWrap(builder.parameters()); step.getOrCreate(MapProjection.SEMI_MAJOR).setValue(pv.doubleValue(GeocentricAffineBetweenGeographic.SRC_SEMI_MAJOR)); step.getOrCreate(MapProjection.SEMI_MINOR).setValue(pv.doubleValue(GeocentricAffineBetweenGeographic.SRC_SEMI_MINOR)); - MathTransform toGeocentric = factory.createParameterizedTransform(step); + MathTransform toGeocentric = builder.create(); assertEquals(3, toGeocentric.getSourceDimensions()); assertEquals(3, toGeocentric.getTargetDimensions()); - final MathTransform reduce = factory.createParameterizedTransform(factory.getDefaultParameters("Geographic3D to 2D conversion")); - final MathTransform reduce = factory.builder("Geographic3D to 2D conversion").create(); ++ final MathTransform reduce = builder(factory, "Geographic3D to 2D conversion").create(); assertEquals(3, reduce.getSourceDimensions()); assertEquals(2, reduce.getTargetDimensions()); try { @@@ -136,10 -137,11 +138,11 @@@ * Create a "Geocentric to Geographic" conversion with ellipsoid axis length units converted to metres * because this is the unit of the Geocentric CRS used above. */ - step = Parameters.castOrWrap(factory.getDefaultParameters(GeocentricToGeographic.NAME)); - builder = factory.builder(GeocentricToGeographic.NAME); ++ builder = builder(factory, GeocentricToGeographic.NAME); + step = Parameters.castOrWrap(builder.parameters()); step.getOrCreate(MapProjection.SEMI_MAJOR).setValue(pv.doubleValue(GeocentricAffineBetweenGeographic.TGT_SEMI_MAJOR)); step.getOrCreate(MapProjection.SEMI_MINOR).setValue(pv.doubleValue(GeocentricAffineBetweenGeographic.TGT_SEMI_MINOR)); - MathTransform toGeographic = factory.createParameterizedTransform(step); + MathTransform toGeographic = builder.create(); assertEquals(3, toGeographic.getSourceDimensions()); assertEquals(3, toGeographic.getTargetDimensions()); diff --cc endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/transform/DefaultMathTransformFactoryTest.java index 0abbd691d4,c8fa84b027..4f5c80b158 --- a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/transform/DefaultMathTransformFactoryTest.java +++ b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/transform/DefaultMathTransformFactoryTest.java @@@ -49,8 -49,8 +49,9 @@@ import org.apache.sis.referencing.cs.Ha import org.apache.sis.referencing.crs.HardCodedCRS; import static org.apache.sis.test.Assertions.assertMessageContains; -// Specific to the geoapi-3.1 and geoapi-4.0 branches: -import static org.opengis.test.Assertions.assertMatrixEquals; +// Specific to the main branch: +import static org.apache.sis.test.GeoapiAssert.assertMatrixEquals; ++import static org.apache.sis.referencing.privy.CoordinateOperations.builder; /** @@@ -216,7 -216,8 +217,8 @@@ public final class DefaultMathTransform continue; } final String classification = method.getName().getCode(); - ParameterValueGroup pg = factory.getDefaultParameters(classification); - final var builder = factory.builder(classification); ++ final var builder = builder(factory, classification); + ParameterValueGroup pg = builder.parameters(); pg.parameter("semi_major").setValue(6377563.396); pg.parameter("semi_minor").setValue(6356256.909237285); /* diff --cc endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/transform/MolodenskyTransformTest.java index f4f27e48aa,8c44de1097..fc45bed6a7 --- a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/transform/MolodenskyTransformTest.java +++ b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/transform/MolodenskyTransformTest.java @@@ -35,6 -35,19 +35,7 @@@ import org.apache.sis.referencing.opera import org.apache.sis.referencing.operation.provider.GeocentricTranslationTest; import org.apache.sis.test.TestUtilities; import org.apache.sis.referencing.datum.HardCodedDatum; - -// Specific to the geoapi-3.1 and geoapi-4.0 branches: -import java.io.IOException; -import org.opengis.referencing.operation.MathTransform; -import org.apache.sis.referencing.operation.provider.AbridgedMolodensky; -import org.apache.sis.math.StatisticsFormat; -import org.apache.sis.math.Statistics; -import static org.apache.sis.metadata.privy.ReferencingServices.NAUTICAL_MILE; -import org.opengis.test.CalculationType; -import org.opengis.test.ToleranceModifier; -import org.opengis.test.ToleranceModifiers; -import org.opengis.test.referencing.ParameterizedTransformTest; -import org.apache.sis.test.TestCase; ++import static org.apache.sis.referencing.privy.CoordinateOperations.builder; /** @@@ -229,7 -343,8 +230,8 @@@ public final class MolodenskyTransformT @Test public void testProvider() throws FactoryException, TransformException { final MathTransformFactory factory = new MathTransformFactoryMock(new Molodensky()); - final ParameterValueGroup parameters = factory.getDefaultParameters("Molodenski"); - final var builder = factory.builder("Molodenski"); ++ final var builder = builder(factory, "Molodenski"); + final ParameterValueGroup parameters = builder.parameters(); parameters.parameter("dim").setValue(3); parameters.parameter("dx").setValue(-3.0); parameters.parameter("dy").setValue(142.0); diff --cc endorsed/src/org.apache.sis.storage.earthobservation/main/org/apache/sis/storage/landsat/MetadataReader.java index 81d0d7ff8a,4c3b7ff5d1..e1598d17ae --- a/endorsed/src/org.apache.sis.storage.earthobservation/main/org/apache/sis/storage/landsat/MetadataReader.java +++ b/endorsed/src/org.apache.sis.storage.earthobservation/main/org/apache/sis/storage/landsat/MetadataReader.java @@@ -67,6 -68,6 +67,10 @@@ import org.apache.sis.util.privy.Consta import org.apache.sis.util.privy.Strings; import static org.apache.sis.util.privy.CollectionsExt.singletonOrNull; ++// Specific to the main branch: ++import org.apache.sis.referencing.privy.CoordinateOperations; ++import org.apache.sis.referencing.operation.transform.MathTransformBuilder; ++ /** * Parses Landsat metadata as {@linkplain DefaultMetadata ISO 19115 Metadata} object. @@@ -223,7 -224,7 +227,7 @@@ final class MetadataReader extends Meta /** * The map projection parameters. This is used only for the polar stereographic case. */ - private ParameterValueGroup projection; - private MathTransform.Builder projection; ++ private MathTransformBuilder projection; /** * The referencing objects factories. @@@ -672,8 -673,8 +676,8 @@@ if ("UTM".equalsIgnoreCase(value)) { projection = null; } else if ("PS".equalsIgnoreCase(value)) try { -- projection = factories.getMathTransformFactory() - .getDefaultParameters(Constants.EPSG + ':' + PolarStereographicB.IDENTIFIER); - .builder(Constants.EPSG + ':' + PolarStereographicB.IDENTIFIER); ++ projection = CoordinateOperations.builder(factories.getMathTransformFactory(), ++ Constants.EPSG + ':' + PolarStereographicB.IDENTIFIER); utmZone = -1; } catch (NoSuchIdentifierException e) { // Should never happen with Apache SIS implementation of MathTransformFactory. diff --cc incubator/build.gradle.kts index 16547b75df,7065b931b6..8dbc812029 --- a/incubator/build.gradle.kts +++ b/incubator/build.gradle.kts @@@ -73,9 -74,12 +73,9 @@@ dependencies * replace ANTLR generated code by hand-written code in a future version. */ var srcDir = file("src") // Must be the same as the hard-coded value in `BuildHelper.java`. -tasks.generateGrammarSource { - setOutputDirectory(file("${srcDir}/org.apache.sis.cql/main")) -} tasks.compileJava { dependsOn(":endorsed:compileJava") - options.release.set(11) // The version of both Java source code and compiled byte code. + options.release.set(22) // The version of both Java source code and compiled byte code. } tasks.compileTestJava { options.compilerArgs.add("-source") // "source", not "release", because we accept any target version.