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 9cee4111e101b33933794af99e2adafd9a950868 Merge: 98ad705d64 f58c7f7d56 Author: Martin Desruisseaux <martin.desruisse...@geomatys.com> AuthorDate: Mon Jan 22 15:03:32 2024 +0100 Merge branch 'geoapi-3.1'. endorsed/build.gradle.kts | 3 - .../org/apache/sis/console/CommandRunnerTest.java | 4 +- .../org.apache.sis.feature/main/module-info.java | 3 +- .../apache/sis/coverage/grid/GridOrientation.java | 2 +- .../apache/sis/coverage/grid/SliceGeometry.java | 12 +- .../sis/coverage/internal/CompoundTransform.java | 54 ++-- .../apache/sis/coverage/grid/GridExtentTest.java | 12 +- .../sis/metadata/iso/citation/Citations.java | 64 +---- .../test/org/apache/sis/xml/XLinkTest.java | 6 +- .../org.apache.sis.portrayal/main/module-info.java | 4 +- .../main/org/apache/sis/portrayal/Observable.java | 14 +- .../org/apache/sis/portrayal/package-info.java | 2 +- .../main/org/apache/sis/style/Style.java | 2 + .../main/org/apache/sis/style/package-info.java | 2 + .../MultiResolutionCoverageLoaderTest.java | 2 +- .../apache/sis/style/se1/ChannelSelectionTest.java | 2 +- .../sis/style/se1/ContrastEnhancementTest.java | 2 +- .../apache/sis/style/se1/ExternalGraphicTest.java | 2 +- .../apache/sis/style/se1/FeatureTypeStyleTest.java | 2 +- .../test/org/apache/sis/style/se1/FontTest.java | 2 +- .../test/org/apache/sis/style/se1/GraphicTest.java | 2 +- .../test/org/apache/sis/style/se1/HaloTest.java | 2 +- .../apache/sis/style/se1/LineSymbolizerTest.java | 2 +- .../test/org/apache/sis/style/se1/MarkTest.java | 2 +- .../apache/sis/style/se1/PointPlacementTest.java | 2 +- .../apache/sis/style/se1/PointSymbolizerTest.java | 2 +- .../sis/style/se1/PolygonSymbolizerTest.java | 2 +- .../apache/sis/style/se1/RasterSymbolizerTest.java | 2 +- .../test/org/apache/sis/style/se1/RuleTest.java | 2 +- .../apache/sis/style/se1/SelectedChannelTest.java | 2 +- .../org/apache/sis/style/se1/ShadedReliefTest.java | 2 +- .../test/org/apache/sis/style/se1/StrokeTest.java | 2 +- .../org/apache/sis/style/se1/StyleTestCase.java | 5 +- .../org/apache/sis/style/se1/SymbolizerTest.java | 5 +- .../org/apache/sis/style/se1/SymbologyTest.java | 2 +- .../apache/sis/style/se1/TextSymbolizerTest.java | 2 +- .../main/org/apache/sis/referencing/CommonCRS.java | 13 +- .../apache/sis/referencing/crs/AbstractCRS.java | 149 ++++++----- .../sis/referencing/crs/AbstractDerivedCRS.java | 28 +- .../sis/referencing/crs/DefaultCompoundCRS.java | 129 ++++----- .../sis/referencing/crs/DefaultDerivedCRS.java | 73 ++++-- .../sis/referencing/crs/DefaultEngineeringCRS.java | 26 +- .../sis/referencing/crs/DefaultGeocentricCRS.java | 33 +-- .../sis/referencing/crs/DefaultGeodeticCRS.java | 21 +- .../sis/referencing/crs/DefaultGeographicCRS.java | 25 +- .../sis/referencing/crs/DefaultImageCRS.java | 26 +- .../sis/referencing/crs/DefaultParametricCRS.java | 25 +- .../sis/referencing/crs/DefaultProjectedCRS.java | 19 +- .../sis/referencing/crs/DefaultTemporalCRS.java | 26 +- .../sis/referencing/crs/DefaultVerticalCRS.java | 21 +- .../apache/sis/referencing/crs/package-info.java | 2 +- .../org/apache/sis/referencing/cs/AbstractCS.java | 222 +++++++++++----- .../apache/sis/referencing/cs/AxesConvention.java | 22 +- .../apache/sis/referencing/cs/DefaultAffineCS.java | 31 +-- .../sis/referencing/cs/DefaultCartesianCS.java | 69 +++-- .../sis/referencing/cs/DefaultCompoundCS.java | 57 +++- .../sis/referencing/cs/DefaultCylindricalCS.java | 34 +-- .../sis/referencing/cs/DefaultEllipsoidalCS.java | 41 ++- .../apache/sis/referencing/cs/DefaultLinearCS.java | 32 +-- .../sis/referencing/cs/DefaultParametricCS.java | 32 +-- .../apache/sis/referencing/cs/DefaultPolarCS.java | 32 +-- .../sis/referencing/cs/DefaultSphericalCS.java | 39 +-- .../apache/sis/referencing/cs/DefaultTimeCS.java | 32 +-- .../sis/referencing/cs/DefaultUserDefinedCS.java | 32 +-- .../sis/referencing/cs/DefaultVerticalCS.java | 32 +-- .../org/apache/sis/referencing/cs/Normalizer.java | 11 +- .../org/apache/sis/referencing/cs/SubTypes.java | 31 +++ .../apache/sis/referencing/cs/package-info.java | 2 +- .../factory/GeodeticAuthorityFactory.java | 8 +- .../factory/MultiAuthoritiesFactory.java | 2 +- .../sis/referencing/factory/package-info.java | 2 +- .../operation/DefaultConcatenatedOperation.java | 14 +- .../referencing/operation/matrix/MatrixSIS.java | 2 + .../referencing/operation/projection/Mercator.java | 63 +++-- .../operation/projection/NormalizedProjection.java | 116 +-------- .../transform/AbstractLinearTransform.java | 17 -- .../operation/transform/AbstractMathTransform.java | 227 ++++++++++++++-- .../operation/transform/CartesianToPolar.java | 2 +- .../operation/transform/CartesianToSpherical.java | 2 +- .../operation/transform/ConcatenatedTransform.java | 58 +++-- .../transform/CoordinateSystemTransform.java | 188 +++++++++++++- .../transform/DefaultMathTransformFactory.java | 6 +- .../transform/EllipsoidToCentricTransform.java | 81 +++--- .../transform/ExponentialTransform1D.java | 65 +++-- .../transform/LogarithmicTransform1D.java | 53 ++-- .../operation/transform/PassThroughTransform.java | 287 +++++++++++---------- .../operation/transform/PolarToCartesian.java | 2 +- .../operation/transform/PowerTransform1D.java | 30 +-- .../operation/transform/SphericalToCartesian.java | 2 +- .../operation/transform/TransformSeparator.java | 17 +- .../operation/transform/UnitConversion.java | 26 +- .../operation/transform/WraparoundTransform.java | 86 +++--- .../sis/referencing/util/CoordinateOperations.java | 2 +- .../referencing/util/ExtendedPrecisionMatrix.java | 28 ++ .../referencing/util/MathTransformsOrFactory.java | 138 ---------- .../sis/referencing/util/ReferencingUtilities.java | 42 +++ .../test/org/apache/sis/io/wkt/ColorsTest.java | 3 +- .../test/org/apache/sis/io/wkt/ElementTest.java | 6 +- .../sis/io/wkt/GeodeticObjectParserTest.java | 3 +- .../org/apache/sis/io/wkt/WKTDictionaryTest.java | 6 +- .../test/org/apache/sis/io/wkt/WKTFormatTest.java | 3 +- .../test/org/apache/sis/referencing/CRSTest.java | 149 +++++------ .../sis/referencing/cs/DefaultPolarCSTest.java | 4 +- .../operation/transform/CartesianToPolarTest.java | 12 +- .../transform/CartesianToSphericalTest.java | 49 +++- .../transform/EllipsoidToCentricTransformTest.java | 40 +-- .../transform/PassThroughTransformTest.java | 73 +++--- .../operation/transform/PolarToCartesianTest.java | 20 +- .../transform/SphericalToCartesianTest.java | 64 ++++- .../transform/TransformSeparatorTest.java | 179 ++++++------- .../transform/WraparoundTransformTest.java | 11 +- .../sis/storage/geotiff/reader/CRSBuilder.java | 10 +- .../sis/io/stream/ChannelDataOutputTest.java | 2 +- .../org/apache/sis/storage/FeatureQueryTest.java | 2 +- .../apache/sis/storage/StorageConnectorTest.java | 4 +- .../storage/internal/RewindableLineReaderTest.java | 3 +- .../main/org/apache/sis/util/CharSequences.java | 66 +++++ .../apache/sis/util/internal/DefinitionURI.java | 3 +- netbeans-project/nbproject/project.properties | 3 +- 119 files changed, 2271 insertions(+), 1611 deletions(-) diff --cc endorsed/src/org.apache.sis.feature/main/module-info.java index a8270aa1d2,0bffbda6d2..519d3be0f3 --- a/endorsed/src/org.apache.sis.feature/main/module-info.java +++ b/endorsed/src/org.apache.sis.feature/main/module-info.java @@@ -45,13 -45,8 +45,12 @@@ module org.apache.sis.feature org.apache.sis.storage, org.apache.sis.storage.sql, org.apache.sis.storage.shapefile, // In the "incubator" sub-project. - org.apache.sis.cql, // In the "incubator" sub-project. - org.apache.sis.portrayal.map; // In the "incubator" sub-project. + org.apache.sis.portrayal; + + exports org.apache.sis.filter.internal to + org.apache.sis.storage, + org.apache.sis.storage.sql, - org.apache.sis.storage.shapefile, // In the "incubator" sub-project. - org.apache.sis.portrayal; ++ org.apache.sis.storage.shapefile; // In the "incubator" sub-project. exports org.apache.sis.feature.internal to org.apache.sis.storage, diff --cc endorsed/src/org.apache.sis.portrayal/test/org/apache/sis/style/se1/HaloTest.java index 30f1e679e7,a50299e4dd..29b3ccadac --- a/endorsed/src/org.apache.sis.portrayal/test/org/apache/sis/style/se1/HaloTest.java +++ b/endorsed/src/org.apache.sis.portrayal/test/org/apache/sis/style/se1/HaloTest.java @@@ -18,10 -18,10 +18,10 @@@ package org.apache.sis.style.se1 // Test dependencies import org.junit.Test; - import static org.junit.Assert.*; + import static org.junit.jupiter.api.Assertions.*; -// Specific to the geoapi-3.1 and geoapi-4.0 branches: -import org.opengis.feature.Feature; +// Specific to the main branch: +import org.apache.sis.feature.AbstractFeature; /** diff --cc endorsed/src/org.apache.sis.portrayal/test/org/apache/sis/style/se1/LineSymbolizerTest.java index 944e8ec88b,caef95db04..88a23d0da0 --- a/endorsed/src/org.apache.sis.portrayal/test/org/apache/sis/style/se1/LineSymbolizerTest.java +++ b/endorsed/src/org.apache.sis.portrayal/test/org/apache/sis/style/se1/LineSymbolizerTest.java @@@ -20,10 -20,10 +20,10 @@@ import java.awt.Color // Test dependencies import org.junit.Test; - import static org.junit.Assert.*; + import static org.junit.jupiter.api.Assertions.*; -// Specific to the geoapi-3.1 and geoapi-4.0 branches: -import org.opengis.feature.Feature; +// Specific to the main branch: +import org.apache.sis.feature.AbstractFeature; /** diff --cc endorsed/src/org.apache.sis.portrayal/test/org/apache/sis/style/se1/PointPlacementTest.java index b444455668,28ac5ad385..58b972e948 --- a/endorsed/src/org.apache.sis.portrayal/test/org/apache/sis/style/se1/PointPlacementTest.java +++ b/endorsed/src/org.apache.sis.portrayal/test/org/apache/sis/style/se1/PointPlacementTest.java @@@ -18,10 -18,10 +18,10 @@@ package org.apache.sis.style.se1 // Test dependencies import org.junit.Test; - import static org.junit.Assert.*; + import static org.junit.jupiter.api.Assertions.*; -// Specific to the geoapi-3.1 and geoapi-4.0 branches: -import org.opengis.feature.Feature; +// Specific to the main branch: +import org.apache.sis.feature.AbstractFeature; /** diff --cc endorsed/src/org.apache.sis.portrayal/test/org/apache/sis/style/se1/PointSymbolizerTest.java index f2efa5cc84,c12273c2cf..53d8b95982 --- a/endorsed/src/org.apache.sis.portrayal/test/org/apache/sis/style/se1/PointSymbolizerTest.java +++ b/endorsed/src/org.apache.sis.portrayal/test/org/apache/sis/style/se1/PointSymbolizerTest.java @@@ -18,10 -18,10 +18,10 @@@ package org.apache.sis.style.se1 // Test dependencies import org.junit.Test; - import static org.junit.Assert.*; + import static org.junit.jupiter.api.Assertions.*; -// Specific to the geoapi-3.1 and geoapi-4.0 branches: -import org.opengis.feature.Feature; +// Specific to the main branch: +import org.apache.sis.feature.AbstractFeature; /** diff --cc endorsed/src/org.apache.sis.portrayal/test/org/apache/sis/style/se1/PolygonSymbolizerTest.java index 7536c2ab99,859b40d59e..e4b8201def --- a/endorsed/src/org.apache.sis.portrayal/test/org/apache/sis/style/se1/PolygonSymbolizerTest.java +++ b/endorsed/src/org.apache.sis.portrayal/test/org/apache/sis/style/se1/PolygonSymbolizerTest.java @@@ -20,10 -20,10 +20,10 @@@ import java.awt.Color // Test dependencies import org.junit.Test; - import static org.junit.Assert.*; + import static org.junit.jupiter.api.Assertions.*; -// Specific to the geoapi-3.1 and geoapi-4.0 branches: -import org.opengis.feature.Feature; +// Specific to the main branch: +import org.apache.sis.feature.AbstractFeature; /** diff --cc endorsed/src/org.apache.sis.portrayal/test/org/apache/sis/style/se1/RuleTest.java index 074f5dd765,bbb17c62ba..381b5842e9 --- a/endorsed/src/org.apache.sis.portrayal/test/org/apache/sis/style/se1/RuleTest.java +++ b/endorsed/src/org.apache.sis.portrayal/test/org/apache/sis/style/se1/RuleTest.java @@@ -21,10 -21,10 +21,10 @@@ import org.apache.sis.metadata.iso.cita // Test dependencies import org.junit.Test; - import static org.junit.Assert.*; + import static org.junit.jupiter.api.Assertions.*; -// Specific to the geoapi-3.1 and geoapi-4.0 branches: -import org.opengis.filter.Filter; +// Specific to the main branch: +import org.apache.sis.filter.Filter; /** diff --cc endorsed/src/org.apache.sis.portrayal/test/org/apache/sis/style/se1/StyleTestCase.java index e9bac1b1c0,26542908ca..a8113c4624 --- a/endorsed/src/org.apache.sis.portrayal/test/org/apache/sis/style/se1/StyleTestCase.java +++ b/endorsed/src/org.apache.sis.portrayal/test/org/apache/sis/style/se1/StyleTestCase.java @@@ -21,14 -21,13 +21,13 @@@ import java.util.Optional import org.apache.sis.util.SimpleInternationalString; // Test dependencies - import static org.junit.Assert.*; - import static org.opengis.test.Assert.assertInstanceOf; + 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 org.opengis.feature.Feature; -import org.opengis.filter.Literal; -import org.opengis.filter.Expression; +// Specific to the main branch: +import org.apache.sis.filter.Expression; +import org.apache.sis.feature.AbstractFeature; +import org.apache.sis.pending.geoapi.filter.Literal; /** diff --cc endorsed/src/org.apache.sis.portrayal/test/org/apache/sis/style/se1/SymbolizerTest.java index f5fa0c2f17,c2ea08ea03..a9badbfb80 --- a/endorsed/src/org.apache.sis.portrayal/test/org/apache/sis/style/se1/SymbolizerTest.java +++ b/endorsed/src/org.apache.sis.portrayal/test/org/apache/sis/style/se1/SymbolizerTest.java @@@ -20,11 -20,10 +20,10 @@@ import org.apache.sis.measure.Units // Test dependencies import org.junit.Test; - import static org.junit.Assert.*; - import static org.opengis.test.Assert.assertInstanceOf; + import static org.junit.jupiter.api.Assertions.*; -// Specific to the geoapi-3.1 and geoapi-4.0 branches: -import org.opengis.filter.ValueReference; +// Specific to the main branch: +import org.apache.sis.pending.geoapi.filter.ValueReference; /** diff --cc endorsed/src/org.apache.sis.portrayal/test/org/apache/sis/style/se1/TextSymbolizerTest.java index ec61e7d779,67341bed3b..5f6ca9e143 --- a/endorsed/src/org.apache.sis.portrayal/test/org/apache/sis/style/se1/TextSymbolizerTest.java +++ b/endorsed/src/org.apache.sis.portrayal/test/org/apache/sis/style/se1/TextSymbolizerTest.java @@@ -18,10 -18,10 +18,10 @@@ package org.apache.sis.style.se1 // Test dependencies import org.junit.Test; - import static org.junit.Assert.*; + import static org.junit.jupiter.api.Assertions.*; -// Specific to the geoapi-3.1 and geoapi-4.0 branches: -import org.opengis.feature.Feature; +// Specific to the main branch: +import org.apache.sis.feature.AbstractFeature; /** diff --cc endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/crs/AbstractCRS.java index 5765b6e32a,3343469505..47228db7ba --- a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/crs/AbstractCRS.java +++ b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/crs/AbstractCRS.java @@@ -33,21 -32,20 +32,20 @@@ import org.opengis.referencing.crs.Sing import org.opengis.referencing.crs.GeneralDerivedCRS; import org.opengis.referencing.crs.CoordinateReferenceSystem; import org.apache.sis.referencing.AbstractReferenceSystem; - import org.apache.sis.referencing.IdentifiedObjects; - import org.apache.sis.referencing.NamedIdentifier; + import org.apache.sis.referencing.cs.AbstractCS; + import org.apache.sis.referencing.cs.AxesConvention; + import org.apache.sis.referencing.util.WKTUtilities; import org.apache.sis.referencing.util.ReferencingUtilities; import org.apache.sis.metadata.internal.ImplementationHelper; - import org.apache.sis.referencing.cs.AxesConvention; - import org.apache.sis.referencing.cs.AbstractCS; - import org.apache.sis.util.ComparisonMode; import org.apache.sis.io.wkt.Convention; import org.apache.sis.io.wkt.Formatter; - import static org.apache.sis.util.Utilities.deepEquals; - import static org.apache.sis.util.ArgumentChecks.ensureNonNull; - import static org.apache.sis.referencing.util.WKTUtilities.toFormattable; + import org.apache.sis.util.Utilities; + import org.apache.sis.util.ArgumentChecks; + import org.apache.sis.util.ComparisonMode; + import org.apache.sis.util.resources.Errors; -// Specific to the geoapi-3.1 and geoapi-4.0 branches: -import org.opengis.metadata.Identifier; +// Specific to the main branch: +import org.opengis.referencing.ReferenceIdentifier; /** @@@ -164,10 -176,27 +176,27 @@@ public class AbstractCRS extends Abstra * @param properties the properties to be given to the coordinate reference system. * @param cs the coordinate system. */ + @SuppressWarnings("this-escape") public AbstractCRS(final Map<String,?> properties, final CoordinateSystem cs) { super(properties); - ensureNonNull("cs", cs); + ArgumentChecks.ensureNonNull("cs", cs); coordinateSystem = cs; + forConvention = forConvention(this); + } + + /** + * Creates a new CRS derived from the specified one, but with different axis order or unit. + * + * @param original the original coordinate system from which to derive a new one. + * @param id new identifier for this CRS, or {@code null} if none. + * @param cs coordinate system with new axis order or units of measurement. + * + * @see #createSameType(AbstractCS) + */ - AbstractCRS(final AbstractCRS original, final Identifier id, final AbstractCS cs) { ++ AbstractCRS(final AbstractCRS original, final ReferenceIdentifier id, final AbstractCS cs) { + super(ReferencingUtilities.getPropertiesWithoutIdentifiers(original, (id == null) ? null : Map.of(IDENTIFIERS_KEY, id))); + coordinateSystem = cs; + forConvention = cs.hasSameAxes(original.coordinateSystem) ? original.forConvention : forConvention(original); } /** diff --cc endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/crs/DefaultDerivedCRS.java index 7f4bfbe318,b9af037eae..a926cbfece --- a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/crs/DefaultDerivedCRS.java +++ b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/crs/DefaultDerivedCRS.java @@@ -780,8 -801,13 +800,13 @@@ public class DefaultDerivedCRS extends super(other); } + /** Creates a new CRS derived from the specified one, but with different axis order or unit. */ + private Parametric(final Parametric original, final AbstractCS derivedCS) { + super(original, derivedCS); + } + /** Creates a new parametric CRS from the given properties. */ - Parametric(Map<String,?> properties, ParametricCRS baseCRS, Conversion conversion, ParametricCS derivedCS) { + Parametric(Map<String,?> properties, ParametricCRS baseCRS, Conversion conversion, DefaultParametricCS derivedCS) { super(properties, baseCRS, conversion, derivedCS); } diff --cc endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/crs/DefaultGeodeticCRS.java index 858ebe70b4,450449f0d9..823972fa20 --- a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/crs/DefaultGeodeticCRS.java +++ b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/crs/DefaultGeodeticCRS.java @@@ -22,6 -22,6 +22,7 @@@ import jakarta.xml.bind.annotation.XmlE import jakarta.xml.bind.annotation.XmlRootElement; import javax.measure.Unit; import javax.measure.quantity.Angle; ++import org.opengis.referencing.ReferenceIdentifier; import org.opengis.referencing.cs.CartesianCS; import org.opengis.referencing.cs.SphericalCS; import org.opengis.referencing.cs.EllipsoidalCS; @@@ -104,6 -108,15 +109,15 @@@ class DefaultGeodeticCRS extends Abstra this.datum = datum; } + /** + * Creates a new CRS derived from the specified one, but with different axis order or unit. + * This is for implementing the {@link #createSameType(AbstractCS)} method only. + */ - DefaultGeodeticCRS(final DefaultGeodeticCRS original, final Identifier id, final AbstractCS cs) { ++ DefaultGeodeticCRS(final DefaultGeodeticCRS original, final ReferenceIdentifier id, final AbstractCS cs) { + super(original, id, cs); + datum = original.datum; + } + /** * Constructs a new coordinate reference system with the same values as the specified one. * This copy constructor provides a way to convert an arbitrary implementation into a SIS one diff --cc endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/crs/DefaultGeographicCRS.java index bab87d7da5,6e256f1900..8976c51e74 --- a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/crs/DefaultGeographicCRS.java +++ b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/crs/DefaultGeographicCRS.java @@@ -157,6 -157,14 +157,14 @@@ public class DefaultGeographicCRS exten super(properties, datum, cs); } + /** + * Creates a new CRS derived from the specified one, but with different axis order or unit. + * This is for implementing the {@link #createSameType(AbstractCS)} method only. + */ - private DefaultGeographicCRS(final DefaultGeographicCRS original, final Identifier id, final AbstractCS cs) { ++ private DefaultGeographicCRS(final DefaultGeographicCRS original, final ReferenceIdentifier id, final AbstractCS cs) { + super(original, id, cs); + } + /** * Constructs a new coordinate reference system with the same values as the specified one. * This copy constructor provides a way to convert an arbitrary implementation into a SIS one @@@ -242,9 -250,13 +250,13 @@@ * EPSG:4269 or EPSG:4326, then this method magically add the CRS:27, CRS:83 or CRS:84 identifier. * Without this special case, the normal behavior would be no identifier. The expected behavior is * that {@code CommonCRS.WGS84.normalizedGeographic()} returns a CRS having the "CRS:84" identifier. + * + * @param cs the coordinate system with new axes. + * @return new CRS of the same type and datum than this CRS, but with the given axes. */ @Override - final AbstractCRS createSameType(Map<String,?> properties, final CoordinateSystem cs) { + final AbstractCRS createSameType(final AbstractCS cs) { - Identifier id = null; ++ ReferenceIdentifier id = null; final CoordinateSystemAxis axis = cs.getAxis(0); if (axis.getMinimumValue() == Longitude.MIN_VALUE && axis.getMaximumValue() == Longitude.MAX_VALUE) // For excluding the AxesConvention.POSITIVE_RANGE case. diff --cc endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/crs/DefaultParametricCRS.java index 9551b9e88c,b494749046..7fe6172b7c --- a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/crs/DefaultParametricCRS.java +++ b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/crs/DefaultParametricCRS.java @@@ -23,14 -23,14 +23,13 @@@ import jakarta.xml.bind.annotation.XmlT import org.apache.sis.metadata.internal.ImplementationHelper; import org.apache.sis.referencing.util.WKTKeywords; import org.apache.sis.referencing.cs.AxesConvention; + import org.apache.sis.referencing.cs.AbstractCS; import org.apache.sis.io.wkt.Formatter; - import static org.apache.sis.util.ArgumentChecks.ensureNonNull; - import static org.apache.sis.referencing.crs.AbstractCRS.isBaseCRS; + import org.apache.sis.util.ArgumentChecks; -// Specific to the geoapi-3.1 and geoapi-4.0 branches: -import org.opengis.referencing.cs.ParametricCS; -import org.opengis.referencing.crs.ParametricCRS; -import org.opengis.referencing.datum.ParametricDatum; +// Specific to the main branch: +import org.apache.sis.referencing.cs.DefaultParametricCS; +import org.apache.sis.referencing.datum.DefaultParametricDatum; /** @@@ -121,14 -118,25 +120,23 @@@ public class DefaultParametricCRS exten * @param properties the properties to be given to the coordinate reference system. * @param datum the datum. * @param cs the coordinate system. - * - * @see org.apache.sis.referencing.factory.GeodeticObjectFactory#createParametricCRS(Map, ParametricDatum, ParametricCS) */ public DefaultParametricCRS(final Map<String,?> properties, - final ParametricDatum datum, - final ParametricCS cs) + final DefaultParametricDatum datum, + final DefaultParametricCS cs) { super(properties, cs); - ensureNonNull("datum", datum); this.datum = datum; + ArgumentChecks.ensureNonNull("datum", datum); + } + + /** + * Creates a new CRS derived from the specified one, but with different axis order or unit. + * This is for implementing the {@link #createSameType(AbstractCS)} method only. + */ + private DefaultParametricCRS(final DefaultParametricCRS original, final AbstractCS cs) { + super(original, null, cs); + datum = original.datum; } /** diff --cc endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/cs/DefaultParametricCS.java index da67e9d4cb,be8df7421c..9742a55d5d --- a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/cs/DefaultParametricCS.java +++ b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/cs/DefaultParametricCS.java @@@ -114,15 -117,45 +114,15 @@@ public class DefaultParametricCS extend * * <p>This constructor performs a shallow copy, i.e. the properties are not cloned.</p> * - * @param original the coordinate system to copy. + * <div class="warning"><b>Warning:</b> in a future SIS version, the parameter type may be changed + * to {@code org.opengis.referencing.cs.ParametricCS}. This change is pending GeoAPI revision.</div> * - * @param cs the coordinate system to copy. - * @see #castOrCopy(ParametricCS) ++ * @param original the coordinate system to copy. */ - protected DefaultParametricCS(final DefaultParametricCS cs) { - super(cs); - protected DefaultParametricCS(final ParametricCS original) { ++ protected DefaultParametricCS(final DefaultParametricCS original) { + super(original); } - /** - * Returns a SIS coordinate system implementation with the same values as the given arbitrary implementation. - * If the given object is {@code null}, then this method returns {@code null}. - * Otherwise if the given object is already a SIS implementation, then the given object is returned unchanged. - * Otherwise a new SIS implementation is created and initialized to the attribute values of the given object. - * - * @param object the object to get as a SIS implementation, or {@code null} if none. - * @return a SIS implementation containing the values of the given object (may be the - * given object itself), or {@code null} if the argument was null. - */ - public static DefaultParametricCS castOrCopy(final ParametricCS object) { - return (object == null) || (object instanceof DefaultParametricCS) - ? (DefaultParametricCS) object : new DefaultParametricCS(object); - } - - /** - * Returns the GeoAPI interface implemented by this class. - * The SIS implementation returns {@code ParametricCS.class}. - * - * <h4>Note for implementers</h4> - * Subclasses usually do not need to override this method since GeoAPI does not define {@code ParametricCS} - * sub-interface. Overriding possibility is left mostly for implementers who wish to extend GeoAPI with - * their own set of interfaces. - * - * @return {@code ParametricCS.class} or a user-defined sub-interface. - */ - @Override - public Class<? extends ParametricCS> getInterface() { - return ParametricCS.class; - } - /** * {@inheritDoc} * diff --cc endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/operation/projection/NormalizedProjection.java index 60dc212579,afb6c2f8c9..a02b57640c --- a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/operation/projection/NormalizedProjection.java +++ b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/operation/projection/NormalizedProjection.java @@@ -60,11 -55,9 +55,9 @@@ import org.apache.sis.system.Modules import org.apache.sis.util.internal.Constants; import org.apache.sis.util.internal.Numerics; import org.apache.sis.util.resources.Errors; - 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 org.opengis.referencing.ReferenceIdentifier; /** diff --cc endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/util/ExtendedPrecisionMatrix.java index d43d4dca62,dd64ab41ca..29766f1328 --- a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/util/ExtendedPrecisionMatrix.java +++ b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/util/ExtendedPrecisionMatrix.java @@@ -54,6 -54,33 +54,34 @@@ public interface ExtendedPrecisionMatri return (element == null) || element.doubleValue() == 0; } + /** + * {@return an extended-precision view of the given matrix}. + * The returned matrix should be assumed read-only. + * + * @param m the matrix to cast or wrap. + * + * @see org.apache.sis.referencing.operation.matrix.MatrixSIS#asExtendedPrecision(Matrix) + */ + @SuppressWarnings("CloneDoesntCallSuperClone") + static ExtendedPrecisionMatrix castOrWrap(final Matrix m) { + if (m == null || m instanceof ExtendedPrecisionMatrix) { + return (ExtendedPrecisionMatrix) m; + } + return new ExtendedPrecisionMatrix() { + @Override public Number getElementOrNull(int j, int i) { + final double v = m.getElement(j, i); + return (v != 0) ? v : null; + } + + @Override public double getElement(int j, int i) {return m.getElement(j, i);} + @Override public int getNumRow() {return m.getNumRow();} + @Override public int getNumCol() {return m.getNumCol();} + @Override public String toString() {return m.toString();} + @Override public Matrix clone() {return m.clone();} ++ @Override public boolean isIdentity() {return m.isIdentity();} + }; + } + /** * Returns all matrix elements in a flat, row-major (column indices vary fastest) array. * The array length is <code>{@linkplain #getNumRow()} * {@linkplain #getNumCol()}</code>. diff --cc endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/util/ReferencingUtilities.java index 4a3a1a0e36,d0bb28fc88..54e79ea9f5 --- a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/util/ReferencingUtilities.java +++ b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/util/ReferencingUtilities.java @@@ -30,6 -30,6 +30,7 @@@ import org.opengis.parameter.ParameterD import org.opengis.parameter.GeneralParameterDescriptor; import org.opengis.util.FactoryException; import org.opengis.referencing.IdentifiedObject; ++import org.opengis.referencing.ReferenceIdentifier; import org.opengis.referencing.cs.*; import org.opengis.referencing.crs.*; import org.opengis.referencing.datum.Datum; @@@ -424,6 -425,33 +426,33 @@@ public final class ReferencingUtilitie && AxisDirection.EAST .equals(cs.getAxis(1).getDirection()); } + /** + * Returns the properties (scope, domain of validity) except the identifiers and the EPSG namespace. + * The identifiers are removed because a modified CRS is no longer conform to the authoritative definition. + * If the name contains a namespace (e.g. "EPSG"), this method removes that namespace for the same reason. + * For example, "EPSG:WGS 84" will become simply "WGS 84". + * + * @param object the identified object for which to get properties map. + * @param overwrite properties overwriting the inherited ones, or {@code null} if none. + * @return the identified object properties. + */ + public static Map<String,?> getPropertiesWithoutIdentifiers(final IdentifiedObject object, final Map<String,?> overwrite) { + final Map<String,?> properties = IdentifiedObjects.getProperties(object, IdentifiedObject.IDENTIFIERS_KEY); - final Identifier name = object.getName(); ++ final ReferenceIdentifier name = object.getName(); + final boolean keepName = name.getCodeSpace() == null && name.getAuthority() == null; + if (keepName && overwrite == null) { + return properties; + } + final var copy = new HashMap<String,Object>(properties); + if (!keepName) { + copy.put(IdentifiedObject.NAME_KEY, new NamedIdentifier(null, name.getCode())); + } + if (overwrite != null) { + copy.putAll(overwrite); + } + return copy; + } + /** * Returns the properties of the given object but potentially with a modified name. * Current implement truncates the name at the first non-white character which is not diff --cc endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/transform/PassThroughTransformTest.java index 3b2056bd89,526d850976..112e6e5758 --- a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/transform/PassThroughTransformTest.java +++ b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/transform/PassThroughTransformTest.java @@@ -31,12 -31,14 +31,13 @@@ import org.apache.sis.util.ArraysExt // Test dependencies import org.junit.Test; - import static org.junit.Assert.*; + import static org.junit.jupiter.api.Assertions.*; import org.apache.sis.test.TestUtilities; import org.apache.sis.test.DependsOn; + import static org.apache.sis.test.Assertions.assertMessageContains; -// Specific to the geoapi-3.1 and geoapi-4.0 branches: -import org.opengis.test.CalculationType; -import org.opengis.test.ToleranceModifier; +// Specific to the main branch: +import static org.apache.sis.test.GeoapiAssert.assertMatrixEquals; /** @@@ -247,7 -242,17 +239,7 @@@ public final class PassThroughTransform */ final float[] sourceAsFloat = ArraysExt.copyAsFloats(passthroughData); final float[] targetAsFloat = verifyConsistency(sourceAsFloat); - assertEquals("Unexpected length of transformed array.", expectedData.length, targetAsFloat.length); + assertEquals(expectedData.length, targetAsFloat.length, "Unexpected length of transformed array."); - /* - * We use a relatively high tolerance threshold because result are - * computed using inputs stored as float values. - */ - if (transform instanceof LinearTransform) { - tolerance = 1E-4; - toleranceModifier = ToleranceModifier.RELATIVE; - assertCoordinatesEqual("PassThroughTransform.transform(…) variants produce inconsistent results.", - sourceDim, expectedData, 0, targetAsFloat, 0, numPts, CalculationType.DIRECT_TRANSFORM); - } } /** @@@ -278,7 -288,9 +275,9 @@@ 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, - 0, 0, 0, 0, 0, 0, 1}), MathTransforms.getMatrix(steps.get(0)), 0); + 0, 0, 0, 0, 0, 0, 1}); + assertMatrixEquals("Expected removal of dimensions 0 and 4 before pass-through", - m, MathTransforms.getMatrix(steps.get(0)), null); ++ m, MathTransforms.getMatrix(steps.get(0)), 0); /* * The number of pass-through dimensions have decreased from 2 to 1 on both sides of the sub-transform. */ @@@ -294,7 -306,9 +293,9 @@@ 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1, 0, - 0, 0, 0, 0, 0, 1}), MathTransforms.getMatrix(steps.get(2)), 0); + 0, 0, 0, 0, 0, 1}); + assertMatrixEquals("Expected removal of dimensions 1 and 2 after pass-through", - m, MathTransforms.getMatrix(steps.get(2)), null); ++ m, MathTransforms.getMatrix(steps.get(2)), 0); } /** diff --cc endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/transform/TransformSeparatorTest.java index ea289a1d70,134d9e995f..5e40be564a --- a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/transform/TransformSeparatorTest.java +++ b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/transform/TransformSeparatorTest.java @@@ -39,10 -38,11 +38,11 @@@ import org.apache.sis.test.TestCase import org.apache.sis.test.TestUtilities; import org.apache.sis.test.DependsOn; import org.apache.sis.test.DependsOnMethod; + import static org.apache.sis.test.Assertions.assertMessageContains; import org.apache.sis.referencing.datum.HardCodedDatum; -// Specific to the geoapi-3.1 and geoapi-4.0 branches: -import static org.opengis.test.Assert.assertMatrixEquals; +// Specific to the main branch: +import static org.apache.sis.test.GeoapiAssert.assertMatrixEquals; /** diff --cc netbeans-project/nbproject/project.properties index e918ad9a83,f2cfb2aa40..dcab64b476 --- a/netbeans-project/nbproject/project.properties +++ b/netbeans-project/nbproject/project.properties @@@ -111,8 -111,8 +111,7 @@@ test.options = --add-modules jama,Geogr --add-exports org.apache.sis.metadata/org.apache.sis.xml.bind.gcx=org.apache.sis.referencing \ --add-exports org.apache.sis.metadata/org.apache.sis.metadata.internal=org.apache.sis.referencing.gazetteer \ --add-exports org.apache.sis.feature/org.apache.sis.feature.internal=org.apache.sis.storage.sql \ - --add-exports org.apache.sis.feature/org.apache.sis.geometry.wrapper.jts=org.apache.sis.storage.sql,org.apache.sis.portrayal \ - --add-exports org.apache.sis.storage/org.apache.sis.storage.base=org.apache.sis.portrayal \ - --add-exports org.apache.sis.feature/org.apache.sis.geometry.wrapper.jts=org.apache.sis.storage.sql,org.apache.sis.portrayal.map \ - --add-exports org.apache.sis.storage/org.apache.sis.storage.base=org.apache.sis.portrayal.map \ ++ --add-exports org.apache.sis.feature/org.apache.sis.geometry.wrapper.jts=org.apache.sis.storage.sql \ --add-exports org.apache.sis.storage/org.apache.sis.storage.test=${modules.list} #