This is an automated email from the ASF dual-hosted git repository. desruisseaux pushed a commit to branch geoapi-4.0 in repository https://gitbox.apache.org/repos/asf/sis.git
The following commit(s) were added to refs/heads/geoapi-4.0 by this push: new 247d4bb78e Update for change in GeoAPI 4.0: deprecated `GeocentricCRS` interface is removed. 247d4bb78e is described below commit 247d4bb78e88c98b7e125dc7e827806d0b6637d7 Author: Martin Desruisseaux <martin.desruisse...@geomatys.com> AuthorDate: Mon Apr 15 17:46:48 2024 +0200 Update for change in GeoAPI 4.0: deprecated `GeocentricCRS` interface is removed. --- .../org/apache/sis/buildtools/book/GEOAPI.lst | 1 - .../apache/sis/io/wkt/GeodeticObjectParser.java | 9 ++-- .../main/org/apache/sis/referencing/CommonCRS.java | 17 +++--- .../sis/referencing/EPSGFactoryFallback.java | 11 ++-- .../apache/sis/referencing/crs/AbstractCRS.java | 26 ++++++++- .../sis/referencing/crs/DefaultDerivedCRS.java | 51 ++++++++++-------- .../sis/referencing/crs/DefaultGeocentricCRS.java | 62 ++++++++++++---------- .../sis/referencing/crs/DefaultGeodeticCRS.java | 15 +++++- .../sis/referencing/crs/DefaultGeographicCRS.java | 32 +++++------ .../sis/referencing/crs/DefaultParametricCRS.java | 1 + .../sis/referencing/crs/DefaultTemporalCRS.java | 2 +- .../sis/referencing/crs/DefaultVerticalCRS.java | 1 + .../sis/referencing/crs/SC_GeographicCRS.java | 5 +- .../org/apache/sis/referencing/crs/SubTypes.java | 32 ++--------- .../sis/referencing/datum/BursaWolfParameters.java | 2 +- .../referencing/factory/AuthorityFactoryProxy.java | 14 +++-- .../factory/ConcurrentAuthorityFactory.java | 16 +++--- .../factory/GeodeticAuthorityFactory.java | 8 +-- .../referencing/factory/GeodeticObjectFactory.java | 24 +++------ .../factory/MultiAuthoritiesFactory.java | 10 ++-- .../referencing/factory/sql/EPSGDataAccess.java | 4 +- .../sis/referencing/factory/sql/TableInfo.java | 3 +- .../referencing/internal/EPSGFactoryProxyCRS.java | 7 ++- .../apache/sis/referencing/internal/Legacy.java | 14 +++++ .../operation/DefaultOperationMethod.java | 1 - .../operation/provider/AbstractProvider.java | 2 +- .../referencing/privy/ReferencingUtilities.java | 2 +- .../apache/sis/referencing/privy/WKTKeywords.java | 6 +-- .../apache/sis/xml/bind/referencing/SC_CRS.java | 4 +- .../sis/io/wkt/GeodeticObjectParserTest.java | 3 +- .../org/apache/sis/referencing/CommonCRSTest.java | 8 ++- .../sis/referencing/EPSGFactoryFallbackTest.java | 14 +++-- .../sis/referencing/crs/DefaultDerivedCRSTest.java | 24 ++++----- .../referencing/factory/AuthorityFactoryMock.java | 5 +- .../factory/MultiAuthoritiesFactoryTest.java | 3 -- .../referencing/factory/sql/EPSGFactoryTest.java | 3 +- .../operation/CoordinateOperationFinderTest.java | 5 +- .../sis/referencing/privy/WKTKeywordsTest.java | 5 +- .../report/CoordinateReferenceSystems.java | 4 +- .../sis/storage/geotiff/reader/CRSBuilder.java | 12 ++--- .../apache/sis/storage/netcdf/base/CRSBuilder.java | 7 ++- geoapi/snapshot | 2 +- .../org/apache/sis/gui/referencing/CRSChooser.java | 4 +- 43 files changed, 242 insertions(+), 239 deletions(-) diff --git a/buildSrc/src/main/resources/org/apache/sis/buildtools/book/GEOAPI.lst b/buildSrc/src/main/resources/org/apache/sis/buildtools/book/GEOAPI.lst index 98b792e99c..dfea7437fb 100644 --- a/buildSrc/src/main/resources/org/apache/sis/buildtools/book/GEOAPI.lst +++ b/buildSrc/src/main/resources/org/apache/sis/buildtools/book/GEOAPI.lst @@ -82,7 +82,6 @@ GCPCollection GeneralDerivedCRS GeneralParameterDescriptor GeneralParameterValue -GeocentricCRS GeodeticCRS GeodeticDatum GeographicBoundingBox diff --git a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/io/wkt/GeodeticObjectParser.java b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/io/wkt/GeodeticObjectParser.java index f08bd05626..9486ec792b 100644 --- a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/io/wkt/GeodeticObjectParser.java +++ b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/io/wkt/GeodeticObjectParser.java @@ -1647,8 +1647,9 @@ class GeodeticObjectParser extends MathTransformParser implements Comparator<Coo final CRSFactory crsFactory = factories.getCRSFactory(); try { final CoordinateSystem cs = parseCoordinateSystem(element, null, 1, isWKT1, unit, datum); - final Map<String,?> properties = parseMetadataAndClose(element, name, datum); + final Map<String,Object> properties = parseMetadataAndClose(element, name, datum); if (baseCRS != null) { + properties.put(Legacy.DERIVED_TYPE_KEY, EngineeringCRS.class); return crsFactory.createDerivedCRS(properties, baseCRS, fromBase, cs); } return crsFactory.createEngineeringCRS(properties, datum, cs); @@ -1708,7 +1709,7 @@ class GeodeticObjectParser extends MathTransformParser implements Comparator<Coo * @param dimension the minimal number of dimensions (usually 2). * @param csType the default coordinate system type, or {@code null} if unknown. * Should be non-null only when parsing a {@link GeneralDerivedCRS#getBaseCRS()} component. - * @return the {@code "GeodeticCRS"} element as a {@link GeographicCRS} or {@link GeocentricCRS} object. + * @return the {@code "GeodeticCRS"} element as a {@link GeographicCRS} or {@link GeodeticCRS} object. * @throws ParseException if the {@code "GeodeticCRS"} element cannot be parsed. * * @see org.apache.sis.referencing.crs.DefaultGeographicCRS#formatTo(Formatter) @@ -1850,11 +1851,11 @@ class GeodeticObjectParser extends MathTransformParser implements Comparator<Coo return crsFactory.createGeographicCRS(properties, datum, (EllipsoidalCS) cs); } if (cs instanceof CartesianCS) { // The second most frequent case. - return crsFactory.createGeocentricCRS(properties, datum, + return crsFactory.createGeodeticCRS(properties, datum, Legacy.forGeocentricCRS((CartesianCS) cs, false)); } if (cs instanceof SphericalCS) { // Not very common case. - return crsFactory.createGeocentricCRS(properties, datum, (SphericalCS) cs); + return crsFactory.createGeodeticCRS(properties, datum, (SphericalCS) cs); } } catch (FactoryException exception) { throw element.parseFailed(exception); diff --git a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/CommonCRS.java b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/CommonCRS.java index ddc4683637..0a436f01a3 100644 --- a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/CommonCRS.java +++ b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/CommonCRS.java @@ -33,7 +33,6 @@ import org.opengis.referencing.crs.GeodeticCRS; import org.opengis.referencing.crs.VerticalCRS; import org.opengis.referencing.crs.TemporalCRS; import org.opengis.referencing.crs.GeographicCRS; -import org.opengis.referencing.crs.GeocentricCRS; import org.opengis.referencing.crs.ProjectedCRS; import org.opengis.referencing.crs.EngineeringCRS; import org.opengis.referencing.crs.SingleCRS; @@ -377,16 +376,14 @@ public enum CommonCRS { * * @see #geocentric() */ - @SuppressWarnings("deprecation") - private transient volatile GeocentricCRS cachedGeocentric; + private transient volatile GeodeticCRS cachedGeocentric; /** * The geocentric CRS using spherical coordinate system, created when first needed. * * @see #spherical() */ - @SuppressWarnings("deprecation") - private transient volatile GeocentricCRS cachedSpherical; + private transient volatile GeodeticCRS cachedSpherical; /** * The Universal Transverse Mercator (UTM) or Universal Polar Stereographic (UPS) projections, @@ -748,14 +745,14 @@ public enum CommonCRS { * @see CRS#forCode(String) * @see DefaultGeocentricCRS */ - public GeocentricCRS geocentric() { - GeocentricCRS object = cachedGeocentric; + public GeodeticCRS geocentric() { + GeodeticCRS object = cachedGeocentric; if (object == null) { if (geocentric != 0) { final GeodeticAuthorityFactory factory = factory(); if (factory != null) try { // Synchronization provided by the cache of the factory. - cachedGeocentric = object = factory.createGeocentricCRS(String.valueOf(geocentric)); + cachedGeocentric = object = factory.createGeodeticCRS(String.valueOf(geocentric)); return object; } catch (FactoryException e) { failure(this, "geocentric", e, geocentric); @@ -801,8 +798,8 @@ public enum CommonCRS { * * @since 0.7 */ - public GeocentricCRS spherical() { - GeocentricCRS object = cachedSpherical; + public GeodeticCRS spherical() { + GeodeticCRS object = cachedSpherical; if (object == null) { /* * All constants defined in this enumeration use the same coordinate system, EPSG:6404. diff --git a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/EPSGFactoryFallback.java b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/EPSGFactoryFallback.java index d680035673..5840115862 100644 --- a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/EPSGFactoryFallback.java +++ b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/EPSGFactoryFallback.java @@ -28,7 +28,7 @@ import org.opengis.referencing.datum.Ellipsoid; import org.opengis.referencing.datum.Datum; import org.opengis.referencing.datum.GeodeticDatum; import org.opengis.referencing.datum.VerticalDatum; -import org.opengis.referencing.crs.GeocentricCRS; +import org.opengis.referencing.crs.GeodeticCRS; import org.opengis.referencing.crs.GeographicCRS; import org.opengis.referencing.crs.ProjectedCRS; import org.opengis.referencing.crs.VerticalCRS; @@ -131,15 +131,14 @@ final class EPSGFactoryFallback extends GeodeticAuthorityFactory final boolean ellipsoid = type.isAssignableFrom(Ellipsoid .class); final boolean datum = type.isAssignableFrom(GeodeticDatum.class); final boolean geographic = type.isAssignableFrom(GeographicCRS.class); - @SuppressWarnings("deprecation") - final boolean geocentric = type.isAssignableFrom(GeocentricCRS.class); + final boolean geodetic = type.isAssignableFrom(GeodeticCRS .class); final boolean projected = type.isAssignableFrom(ProjectedCRS .class); final Set<String> codes = new LinkedHashSet<>(); if (pm) codes.add(StandardDefinitions.GREENWICH); for (final CommonCRS crs : CommonCRS.values()) { - if (ellipsoid) add(codes, crs.ellipsoid); - if (datum) add(codes, crs.datum); - if (geocentric) add(codes, crs.geocentric); + if (ellipsoid) add(codes, crs.ellipsoid); + if (datum) add(codes, crs.datum); + if (geodetic) add(codes, crs.geocentric); if (geographic) { add(codes, crs.geographic); add(codes, crs.geo3D); diff --git 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 index 4900d62993..38c5dff592 100644 --- 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 @@ -24,6 +24,7 @@ import jakarta.xml.bind.annotation.XmlType; import jakarta.xml.bind.annotation.XmlRootElement; import jakarta.xml.bind.annotation.XmlSeeAlso; import javax.measure.Unit; +import org.opengis.geometry.MismatchedDimensionException; import org.opengis.referencing.datum.Datum; import org.opengis.referencing.cs.AffineCS; import org.opengis.referencing.cs.CartesianCS; @@ -182,6 +183,28 @@ public class AbstractCRS extends AbstractReferenceSystem implements CoordinateRe forConvention = forConvention(this); } + /** + * Verifies that the given coordinate system has a number of dimensions in the expected range. + * + * @param min minimum number of dimensions, inclusive. + * @param max maximum number of dimensions, inclusive. + * @param cs the coordinate system for which to validate the number of dimensions. + * @throws MismatchedDimensionException if the actual number of dimension is out of bounds. + */ + static void checkDimension(final int min, final int max, final CoordinateSystem cs) { + final int actual = cs.getDimension(); + final int expected; + if (actual < min) { + expected = min; + } else if (actual > max) { + expected = max; + } else { + return; + } + throw new MismatchedDimensionException(Errors.format( + Errors.Keys.MismatchedDimension_3, "cs", expected, actual)); + } + /** * Creates a new CRS derived from the specified one, but with different axis order or unit. * @@ -223,8 +246,7 @@ public class AbstractCRS extends AbstractReferenceSystem implements CoordinateRe * <li>If the given object is {@code null}, then this method returns {@code null}.</li> * <li>Otherwise if the given object is an instance of * {@link org.opengis.referencing.crs.GeodeticCRS} (including the - * {@link org.opengis.referencing.crs.GeographicCRS} and - * {@link org.opengis.referencing.crs.GeocentricCRS} subtypes), + * {@link org.opengis.referencing.crs.GeographicCRS subtype}), * {@link org.opengis.referencing.crs.VerticalCRS}, * {@link org.opengis.referencing.crs.TemporalCRS}, * {@link org.opengis.referencing.crs.EngineeringCRS} or diff --git 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 index 4da215ea62..21aec9e2b5 100644 --- 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 @@ -54,9 +54,11 @@ import org.apache.sis.xml.bind.referencing.CS_CoordinateSystem; import org.apache.sis.referencing.privy.ReferencingUtilities; import org.apache.sis.referencing.privy.WKTUtilities; import org.apache.sis.referencing.privy.WKTKeywords; +import static org.apache.sis.referencing.internal.Legacy.DERIVED_TYPE_KEY; import org.apache.sis.io.wkt.Convention; import org.apache.sis.io.wkt.Formatter; import org.apache.sis.util.ComparisonMode; +import org.apache.sis.util.collection.Containers; // Specific to the geoapi-3.1 and geoapi-4.0 branches: import org.opengis.referencing.datum.DatumEnsemble; @@ -281,7 +283,7 @@ public class DefaultDerivedCRS extends AbstractDerivedCRS<Conversion> implements throws MismatchedDimensionException { if (baseCRS != null && derivedCS != null) { - final String type = getType(baseCRS, derivedCS); + final String type = getTypeKeyword(properties, baseCRS, derivedCS); if (type != null) switch (type) { case WKTKeywords.GeodeticCRS: return new Geodetic (properties, (GeodeticCRS) baseCRS, conversion, derivedCS); case WKTKeywords.VerticalCRS: return new Vertical (properties, (VerticalCRS) baseCRS, conversion, (VerticalCS) derivedCS); @@ -293,8 +295,7 @@ public class DefaultDerivedCRS extends AbstractDerivedCRS<Conversion> implements * But only the latter is associated to EngineeringDatum; the two formers are associated * to GeodeticDatum. Consequently, we can implement the EngineeringCRS.getDatum() method * only if the base CRS is itself of kind EngineeringCRS. Otherwise we will return the - * "type-neutral" DefaultDerivedCRS implementation. Note that even in the latter case, - * the WKT format will still be able to detect that the WKT keyword is "EngineeringCRS". + * "type-neutral" DefaultDerivedCRS implementation. */ if (baseCRS instanceof EngineeringCRS) { return new Engineering(properties, (EngineeringCRS) baseCRS, conversion, derivedCS); @@ -336,7 +337,7 @@ public class DefaultDerivedCRS extends AbstractDerivedCRS<Conversion> implements final CoordinateSystem derivedCS) { if (baseCRS != null && derivedCS != null) { - final String type = getType(baseCRS, derivedCS); + final String type = getTypeKeyword(properties, baseCRS, derivedCS); if (type != null) switch (type) { case WKTKeywords.GeodeticCRS: return new Geodetic (properties, (GeodeticCRS) baseCRS, interpolationCRS, method, baseToDerived, derivedCS); case WKTKeywords.VerticalCRS: return new Vertical (properties, (VerticalCRS) baseCRS, interpolationCRS, method, baseToDerived, (VerticalCS) derivedCS); @@ -368,7 +369,7 @@ public class DefaultDerivedCRS extends AbstractDerivedCRS<Conversion> implements if (object == null || object instanceof DefaultDerivedCRS) { return (DefaultDerivedCRS) object; } else { - final String type = getType(object.getBaseCRS(), object.getCoordinateSystem()); + final String type = getTypeKeyword(null, object.getBaseCRS(), object.getCoordinateSystem()); if (type != null) switch (type) { case WKTKeywords.GeodeticCRS: return new Geodetic (object); case WKTKeywords.VerticalCRS: return new Vertical (object); @@ -566,12 +567,12 @@ public class DefaultDerivedCRS extends AbstractDerivedCRS<Conversion> implements } /** - * Return the WKT 2 keyword for this {@code DerivedCRS}, or {@code null} if unknown. + * Returns the WKT 2 keyword for this {@code DerivedCRS}, or {@code null} if unknown. * Inner subclasses will override this method for returning a constant value instead * than trying to infer it from the components. */ String keyword(final Formatter formatter) { - final String longKeyword = getType(getBaseCRS(), getCoordinateSystem()); + final String longKeyword = getTypeKeyword(null, getBaseCRS(), getCoordinateSystem()); final String shortKeyword; if (longKeyword == null) { return null; @@ -587,20 +588,28 @@ public class DefaultDerivedCRS extends AbstractDerivedCRS<Conversion> implements /** * Returns the WKT 2 keyword for a {@code DerivedCRS} having the given base CRS and derived coordinate system. - * If the type cannot be identifier, then this method returns {@code null}. + * If the type cannot be identified, then this method returns {@code null}. + * + * @param properties user-specified properties, or {@code null} if none. + * @param baseCRS the base CRS of the derived CRS to construct. + * @param derivedCS the coordinate system of the derived CRS to construct. + * @return the WKT keyword of the derived CRS type, or {@code null} if it cannot be inferred or if + * the type specified in the properties map is incompatible with the given coordinate system. */ - static String getType(final SingleCRS baseCRS, final CoordinateSystem derivedCS) { - final Class<?> type; - if (baseCRS instanceof AbstractIdentifiedObject) { - /* - * For avoiding ambiguity if a user chooses to implement more - * than 1 CRS interface (not recommended, but may happen). - */ - type = ((AbstractIdentifiedObject) baseCRS).getInterface(); - } else if (baseCRS != null) { - type = baseCRS.getClass(); - } else { - return null; + static String getTypeKeyword(final Map<String,?> properties, final SingleCRS baseCRS, final CoordinateSystem derivedCS) { + Class<?> type = Containers.property(properties, DERIVED_TYPE_KEY, Class.class); + if (type == null) { + if (baseCRS instanceof AbstractIdentifiedObject) { + /* + * For avoiding ambiguity if a user chooses to implement more + * than 1 CRS interface (not recommended, but may happen). + */ + type = ((AbstractIdentifiedObject) baseCRS).getInterface(); + } else if (baseCRS != null) { + type = baseCRS.getClass(); + } else { + return null; + } } if (GeodeticCRS.class.isAssignableFrom(type) && CoordinateSystems.isGeodetic(derivedCS)) { return WKTKeywords.GeodeticCRS; @@ -954,7 +963,7 @@ public class DefaultDerivedCRS extends AbstractDerivedCRS<Conversion> implements */ @XmlElement(name = "derivedCRSType", required = true) SC_DerivedCRSType getType() { - return SC_DerivedCRSType.fromWKT(getType(getBaseCRS(), getCoordinateSystem())); + return SC_DerivedCRSType.fromWKT(getTypeKeyword(null, getBaseCRS(), getCoordinateSystem())); } /** diff --git a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/crs/DefaultGeocentricCRS.java b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/crs/DefaultGeocentricCRS.java index e8cb41b856..0a812d4823 100644 --- a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/crs/DefaultGeocentricCRS.java +++ b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/crs/DefaultGeocentricCRS.java @@ -18,20 +18,22 @@ package org.apache.sis.referencing.crs; import java.util.Map; import jakarta.xml.bind.annotation.XmlTransient; +import org.opengis.referencing.cs.CoordinateSystem; import org.opengis.referencing.cs.CartesianCS; import org.opengis.referencing.cs.SphericalCS; -import org.opengis.referencing.crs.GeocentricCRS; +import org.opengis.referencing.crs.GeodeticCRS; import org.opengis.referencing.datum.GeodeticDatum; import org.apache.sis.referencing.AbstractReferenceSystem; import org.apache.sis.referencing.cs.AxesConvention; import org.apache.sis.referencing.cs.AbstractCS; +import org.apache.sis.util.ArgumentChecks; import org.apache.sis.io.wkt.Formatter; /** - * A 3-dimensional coordinate reference system with the origin at the approximate centre of mass of the earth. - * A geocentric CRS deals with the earth's curvature by taking a 3-dimensional spatial view, which obviates - * the need to model the earth's curvature. + * A 2- or 3-dimensional coordinate reference system with the origin at the approximate centre of mass of the earth. + * This class is used for geodetic CRS that are not geographic, and is named "geocentric" for historical reasons. + * Note that ISO 19111 does not define a {@code GeocentricCRS} interface. * * <p><b>Used with datum type:</b> * {@linkplain org.apache.sis.referencing.datum.DefaultGeodeticDatum Geodetic}.<br> @@ -47,13 +49,13 @@ import org.apache.sis.io.wkt.Formatter; * The other choices provide more freedom. * * <ol> - * <li>Create a {@code GeocentricCRS} from one of the static convenience shortcuts listed in + * <li>Create a {@code GeodeticCRS} from one of the static convenience shortcuts listed in * {@link org.apache.sis.referencing.CommonCRS#geocentric()}.</li> - * <li>Create a {@code GeocentricCRS} from an identifier in a database by invoking - * {@link org.apache.sis.referencing.factory.GeodeticAuthorityFactory#createGeocentricCRS(String)}.</li> - * <li>Create a {@code GeocentricCRS} by invoking the {@code CRSFactory.createGeocentricCRS(…)} method + * <li>Create a {@code GeodeticCRS} from an identifier in a database by invoking + * {@link org.apache.sis.referencing.factory.GeodeticAuthorityFactory#createGeodeticCRS(String)}.</li> + * <li>Create a {@code GeodeticCRS} by invoking the {@code CRSFactory.createGeodeticCRS(…)} method * (implemented for example by {@link org.apache.sis.referencing.factory.GeodeticObjectFactory}).</li> - * <li>Create a {@code GeocentricCRS} by invoking the + * <li>Create a {@code GeodeticCRS} by invoking the * {@linkplain #DefaultGeocentricCRS(Map, GeodeticDatum, CartesianCS) constructor}.</li> * </ol> * @@ -68,19 +70,15 @@ import org.apache.sis.io.wkt.Formatter; * the coordinate system and the datum instances given to the constructor are also immutable. Unless otherwise noted * in the javadoc, this condition holds if all components were created using only SIS factories and static constants. * - * @deprecated ISO 19111:2019 does not define an explicit class for geocentric CRS. - * The {@code GeodeticCRS} parent class should be used instead. - * * @author Martin Desruisseaux (IRD, Geomatys) * @version 1.5 * - * @see org.apache.sis.referencing.factory.GeodeticAuthorityFactory#createGeocentricCRS(String) + * @see org.apache.sis.referencing.factory.GeodeticAuthorityFactory#createGeodeticCRS(String) * * @since 0.4 */ @XmlTransient -@Deprecated(since = "2.0") -public class DefaultGeocentricCRS extends DefaultGeodeticCRS implements GeocentricCRS { +public class DefaultGeocentricCRS extends DefaultGeodeticCRS { /** * Serial number for inter-operability with different versions. */ @@ -125,13 +123,14 @@ public class DefaultGeocentricCRS extends DefaultGeodeticCRS implements Geocentr * @param datum the datum. * @param cs the coordinate system, which must be three-dimensional. * - * @see org.apache.sis.referencing.factory.GeodeticObjectFactory#createGeocentricCRS(Map, GeodeticDatum, CartesianCS) + * @see org.apache.sis.referencing.factory.GeodeticObjectFactory#createGeodeticCRS(Map, GeodeticDatum, CartesianCS) */ public DefaultGeocentricCRS(final Map<String,?> properties, final GeodeticDatum datum, final CartesianCS cs) { super(properties, datum, cs); + checkDimension(3, 3, cs); } /** @@ -143,13 +142,14 @@ public class DefaultGeocentricCRS extends DefaultGeodeticCRS implements Geocentr * @param datum the datum. * @param cs the coordinate system. * - * @see org.apache.sis.referencing.factory.GeodeticObjectFactory#createGeocentricCRS(Map, GeodeticDatum, SphericalCS) + * @see org.apache.sis.referencing.factory.GeodeticObjectFactory#createGeodeticCRS(Map, GeodeticDatum, SphericalCS) */ public DefaultGeocentricCRS(final Map<String,?> properties, final GeodeticDatum datum, final SphericalCS cs) { super(properties, datum, cs); + checkDimension(2, 3, cs); } /** @@ -169,11 +169,19 @@ public class DefaultGeocentricCRS extends DefaultGeodeticCRS implements Geocentr * <p>This constructor performs a shallow copy, i.e. the properties are not cloned.</p> * * @param crs the coordinate reference system to copy. + * @throws IllegalArgumentException if the coordinate system of the given CRS is not Cartesian or spherical. * - * @see #castOrCopy(GeocentricCRS) + * @see #castOrCopy(GeodeticCRS) */ - protected DefaultGeocentricCRS(final GeocentricCRS crs) { + @SuppressWarnings("this-escape") + protected DefaultGeocentricCRS(final GeodeticCRS crs) { super(crs); + CoordinateSystem cs = super.getCoordinateSystem(); + if (cs instanceof CartesianCS) { + ArgumentChecks.ensureDimensionMatches("crs.coordinateSystem", 3, cs); + } else if (!(cs instanceof SphericalCS)) { + throw illegalCoordinateSystemType(cs); + } } /** @@ -185,26 +193,22 @@ public class DefaultGeocentricCRS extends DefaultGeodeticCRS implements Geocentr * @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. + * @throws IllegalArgumentException if the coordinate system of the given CRS is not Cartesian or spherical. */ - public static DefaultGeocentricCRS castOrCopy(final GeocentricCRS object) { + public static DefaultGeocentricCRS castOrCopy(final GeodeticCRS object) { return (object == null) || (object instanceof DefaultGeocentricCRS) ? (DefaultGeocentricCRS) object : new DefaultGeocentricCRS(object); } /** * Returns the GeoAPI interface implemented by this class. - * The SIS implementation returns {@code GeocentricCRS.class}. - * - * <h4>Note for implementers</h4> - * Subclasses usually do not need to override this method since GeoAPI does not define {@code GeocentricCRS} - * sub-interface. Overriding possibility is left mostly for implementers who wish to extend GeoAPI with their - * own set of interfaces. + * The SIS implementation returns {@code GeodeticCRS.class}. * - * @return {@code GeocentricCRS.class} or a user-defined sub-interface. + * @return {@code GeodeticCRS.class} or a user-defined sub-interface. */ @Override - public Class<? extends GeocentricCRS> getInterface() { - return GeocentricCRS.class; + public Class<? extends GeodeticCRS> getInterface() { + return super.getInterface(); } /** diff --git 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 index cb34bc26bb..231d4cfc14 100644 --- 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 @@ -41,6 +41,7 @@ import org.apache.sis.referencing.privy.WKTKeywords; import org.apache.sis.referencing.privy.WKTUtilities; import org.apache.sis.referencing.privy.ReferencingUtilities; import org.apache.sis.metadata.privy.ImplementationHelper; +import org.apache.sis.util.resources.Errors; import org.apache.sis.io.wkt.Convention; import org.apache.sis.io.wkt.Formatter; import org.apache.sis.measure.Units; @@ -68,7 +69,7 @@ import org.apache.sis.measure.Units; "datum" }) @XmlRootElement(name = "GeodeticCRS") -class DefaultGeodeticCRS extends AbstractCRS implements GeodeticCRS { // If made public, see comment in getDatum(). +class DefaultGeodeticCRS extends AbstractCRS implements GeodeticCRS { // If made public, see comment in getDatum(). /** * Serial number for inter-operability with different versions. */ @@ -127,6 +128,18 @@ class DefaultGeodeticCRS extends AbstractCRS implements GeodeticCRS { // If made datum = crs.getDatum(); } + /** + * Creates an exception to throw for a coordinate system of illegal class. + * This is a helper method for sub-classes. + * + * @param cs the user-specified coordinate system. + * @return the exception to throw. + */ + static IllegalArgumentException illegalCoordinateSystemType(final CoordinateSystem cs) { + return new IllegalArgumentException(Errors.format(Errors.Keys.IllegalCoordinateSystem_1, + ReferencingUtilities.getInterface(CoordinateSystem.class, cs))); + } + /** * Returns the GeoAPI interface implemented by this class. * The SIS implementation returns {@code GeodeticCRS.class}. diff --git 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 index d6dfbb4462..0fb4bc2ff0 100644 --- 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 @@ -32,7 +32,6 @@ import org.apache.sis.referencing.cs.AxesConvention; import org.apache.sis.referencing.cs.AbstractCS; import org.apache.sis.io.wkt.Formatter; import org.apache.sis.measure.Longitude; -import org.apache.sis.util.resources.Errors; import static org.apache.sis.util.privy.Constants.CRS; import static org.apache.sis.util.privy.Constants.EPSG; import static org.apache.sis.util.privy.Constants.CRS27; @@ -155,6 +154,7 @@ public class DefaultGeographicCRS extends DefaultGeodeticCRS implements Geograph final EllipsoidalCS cs) { super(properties, datum, cs); + checkDimension(2, 3, cs); } /** @@ -165,6 +165,21 @@ public class DefaultGeographicCRS extends DefaultGeodeticCRS implements Geograph super(original, id, cs); } + /** + * Constructs a new coordinate reference system with the same values as the specified geodetic CRS. + * This constructor is needed because GML does not have {@code GeographicCRS} or {@code GeocentricCRS} types. + * Instead, the unmarshalling process will give us a {@code GeodeticCRS} object with the constraint that the + * coordinate system shall be ellipsoidal. This constructor may be invoked for converting such + * {@code GeodeticCRS} instance to a {@code GeographicCRS} instance. + */ + DefaultGeographicCRS(final GeodeticCRS crs) { + super(crs); + final CoordinateSystem cs = super.getCoordinateSystem(); + if (!(cs instanceof EllipsoidalCS)) { + throw illegalCoordinateSystemType(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 @@ -344,19 +359,4 @@ public class DefaultGeographicCRS extends DefaultGeodeticCRS implements Geograph */ private DefaultGeographicCRS() { } - - /** - * For {@link SC_GeographicCRS} JAXB adapter only. This is needed because GML does not have "GeographicCRS" type. - * Instead, the unmarshalling process will give us a "GeodeticCRS" object with the constraint that the coordinate - * system shall be ellipsoidal. This constructor will be invoked for converting the GeodeticCRS instance to a - * GeographicCRS instance. - */ - DefaultGeographicCRS(final GeodeticCRS crs) { - super(crs); - final CoordinateSystem cs = super.getCoordinateSystem(); - if (!(cs instanceof EllipsoidalCS)) { - throw new IllegalArgumentException(Errors.format( - Errors.Keys.IllegalClass_2, EllipsoidalCS.class, cs.getClass())); - } - } } diff --git 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 index c8cd0905f2..b8f7596eba 100644 --- 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 @@ -127,6 +127,7 @@ public class DefaultParametricCRS extends AbstractCRS implements ParametricCRS { { super(properties, cs); this.datum = Objects.requireNonNull(datum); + checkDimension(1, 1, cs); } /** diff --git a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/crs/DefaultTemporalCRS.java b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/crs/DefaultTemporalCRS.java index c5efc686ec..8a55606a48 100644 --- a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/crs/DefaultTemporalCRS.java +++ b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/crs/DefaultTemporalCRS.java @@ -152,13 +152,13 @@ public class DefaultTemporalCRS extends AbstractCRS implements TemporalCRS { * * @see org.apache.sis.referencing.factory.GeodeticObjectFactory#createTemporalCRS(Map, TemporalDatum, TimeCS) */ - @SuppressWarnings("this-escape") public DefaultTemporalCRS(final Map<String,?> properties, final TemporalDatum datum, final TimeCS cs) { super(properties, cs); this.datum = Objects.requireNonNull(datum); + checkDimension(1, 1, cs); initializeConverter(); } diff --git a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/crs/DefaultVerticalCRS.java b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/crs/DefaultVerticalCRS.java index a4ce53c658..e061c405be 100644 --- a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/crs/DefaultVerticalCRS.java +++ b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/crs/DefaultVerticalCRS.java @@ -126,6 +126,7 @@ public class DefaultVerticalCRS extends AbstractCRS implements VerticalCRS { { super(properties, cs); this.datum = Objects.requireNonNull(datum); + checkDimension(1, 1, cs); } /** diff --git a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/crs/SC_GeographicCRS.java b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/crs/SC_GeographicCRS.java index 6f9ef6accf..d4d3fc7ab0 100644 --- a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/crs/SC_GeographicCRS.java +++ b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/crs/SC_GeographicCRS.java @@ -25,9 +25,8 @@ import org.apache.sis.xml.bind.gco.PropertyType; * JAXB adapter for {@link GeographicCRS}, in order to integrate the value in an element * complying with OGC/ISO standard. * - * <p><b>Note:</b> JAXB adapters are usually declared in the {@link org.apache.sis.xml.bind.referencing} - * package, but this one is an exception because it needs access to package-privated {@link DefaultGeodeticCRS} - * class.</p> + * <p><b>Note:</b> JAXB adapters are usually declared in the {@link org.apache.sis.xml.bind.referencing} package, + * but this one is an exception because it needs access to package-private {@link DefaultGeodeticCRS} class.</p> * * @author Martin Desruisseaux (Geomatys) */ diff --git a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/crs/SubTypes.java b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/crs/SubTypes.java index 2b160b158a..e02e655b75 100644 --- a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/crs/SubTypes.java +++ b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/crs/SubTypes.java @@ -16,15 +16,12 @@ */ package org.apache.sis.referencing.crs; -import java.util.Map; import java.util.Comparator; import org.opengis.referencing.crs.CoordinateReferenceSystem; import org.opengis.referencing.crs.CompoundCRS; import org.opengis.referencing.crs.DerivedCRS; import org.opengis.referencing.crs.EngineeringCRS; -import org.opengis.referencing.crs.GeocentricCRS; import org.opengis.referencing.crs.GeodeticCRS; -import org.opengis.referencing.crs.GeographicCRS; import org.opengis.referencing.crs.ProjectedCRS; import org.opengis.referencing.crs.TemporalCRS; import org.opengis.referencing.crs.VerticalCRS; @@ -32,8 +29,6 @@ import org.opengis.referencing.cs.CoordinateSystem; import org.opengis.referencing.cs.CartesianCS; import org.opengis.referencing.cs.EllipsoidalCS; import org.opengis.referencing.cs.SphericalCS; -import org.opengis.referencing.datum.GeodeticDatum; -import org.apache.sis.referencing.IdentifiedObjects; import org.apache.sis.referencing.cs.AxesConvention; @@ -110,19 +105,6 @@ final class SubTypes implements Comparator<Object> { return DefaultDerivedCRS.castOrCopy((DerivedCRS) object); } if (object instanceof GeodeticCRS) { - if (object instanceof GeographicCRS) { - return DefaultGeographicCRS.castOrCopy((GeographicCRS) object); - } - if (object instanceof GeocentricCRS) { - return DefaultGeocentricCRS.castOrCopy((GeocentricCRS) object); - } - /* - * The GeographicCRS and GeocentricCRS types are not part of ISO 19111. - * ISO uses a single type, GeodeticCRS, for both of them and infer the - * geographic or geocentric type from the coordinate system. We do this - * check here for instantiating the most appropriate SIS type, but only - * if we need to create a new object anyway (see below for rational). - */ if (object instanceof DefaultGeodeticCRS) { /* * Result of XML unmarshalling — keep as-is. We avoid creating a new object because it @@ -131,17 +113,13 @@ final class SubTypes implements Comparator<Object> { */ return (DefaultGeodeticCRS) object; } - final Map<String,?> properties = IdentifiedObjects.getProperties(object); - final GeodeticDatum datum = ((GeodeticCRS) object).getDatum(); - final CoordinateSystem cs = object.getCoordinateSystem(); + final var crs = (GeodeticCRS) object; + final CoordinateSystem cs = crs.getCoordinateSystem(); if (cs instanceof EllipsoidalCS) { - return new DefaultGeographicCRS(properties, datum, (EllipsoidalCS) cs); - } - if (cs instanceof SphericalCS) { - return new DefaultGeocentricCRS(properties, datum, (SphericalCS) cs); + return new DefaultGeographicCRS(crs); } - if (cs instanceof CartesianCS) { - return new DefaultGeocentricCRS(properties, datum, (CartesianCS) cs); + if (cs instanceof CartesianCS || cs instanceof SphericalCS) { + return new DefaultGeocentricCRS(crs); } } if (object instanceof VerticalCRS) { diff --git a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/datum/BursaWolfParameters.java b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/datum/BursaWolfParameters.java index 42a36c2251..03fc38e034 100644 --- a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/datum/BursaWolfParameters.java +++ b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/datum/BursaWolfParameters.java @@ -237,7 +237,7 @@ public class BursaWolfParameters extends FormattableObject implements Cloneable, * <p><b>Maintenance note:</b> * if the above policy regarding prime meridians is modified, then some {@code createOperationStep(…)} method * implementations in {@link org.apache.sis.referencing.operation.CoordinateOperationFinder} may need to be - * revisited. See especially the methods creating a transformation between a pair of {@code GeocentricCRS} or + * revisited. See especially the methods creating a transformation between a pair of geocentric CRS or * between a pair of {@code GeographicCRS} (tip: search for {@code DefaultGeodeticDatum}).</p> * * @param pm the prime meridian of the enclosing {@code GeodeticDatum}. diff --git a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/factory/AuthorityFactoryProxy.java b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/factory/AuthorityFactoryProxy.java index abe367a11d..8947411b87 100644 --- a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/factory/AuthorityFactoryProxy.java +++ b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/factory/AuthorityFactoryProxy.java @@ -454,14 +454,13 @@ abstract class AuthorityFactoryProxy<T> { } }; - @SuppressWarnings("deprecation") - static final AuthorityFactoryProxy<GeocentricCRS> GEOCENTRIC_CRS = - new AuthorityFactoryProxy<GeocentricCRS>(GeocentricCRS.class, AuthorityFactoryIdentifier.CRS) { - @Override GeocentricCRS create(GeodeticAuthorityFactory factory, String code) throws FactoryException { - return factory.createGeocentricCRS(code); + static final AuthorityFactoryProxy<GeodeticCRS> GEODETIC_CRS = + new AuthorityFactoryProxy<GeodeticCRS>(GeodeticCRS.class, AuthorityFactoryIdentifier.CRS) { + @Override GeodeticCRS create(GeodeticAuthorityFactory factory, String code) throws FactoryException { + return factory.createGeodeticCRS(code); } - @Override GeocentricCRS createFromAPI(AuthorityFactory factory, String code) throws FactoryException { - return crsFactory(factory).createGeocentricCRS(code); + @Override GeodeticCRS createFromAPI(AuthorityFactory factory, String code) throws FactoryException { + return crsFactory(factory).createGeodeticCRS(code); } }; @@ -544,7 +543,6 @@ abstract class AuthorityFactoryProxy<T> { static final AuthorityFactoryProxy<?>[] PROXIES = new AuthorityFactoryProxy<?>[] { PROJECTED_CRS, // Special kind of GeneralDerivedCRS. GEOGRAPHIC_CRS, // Special kind of GeodeticCRS. - GEOCENTRIC_CRS, // Special kind of GeodeticCRS. VERTICAL_CRS, TEMPORAL_CRS, ENGINEERING_CRS, diff --git a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/factory/ConcurrentAuthorityFactory.java b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/factory/ConcurrentAuthorityFactory.java index fa6331cab3..34e23dddab 100644 --- a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/factory/ConcurrentAuthorityFactory.java +++ b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/factory/ConcurrentAuthorityFactory.java @@ -928,26 +928,22 @@ public abstract class ConcurrentAuthorityFactory<DAO extends GeodeticAuthorityFa * The default implementation performs the following steps: * <ul> * <li>Return the cached instance for the given code if such instance already exists.</li> - * <li>Otherwise if the Data Access Object (DAO) overrides the {@code createGeocentricCRS(String)} + * <li>Otherwise if the Data Access Object (DAO) overrides the {@code createGeodeticCRS(String)} * method, invoke that method and cache the result for future use.</li> - * <li>Otherwise delegate to the {@link GeodeticAuthorityFactory#createGeocentricCRS(String)} + * <li>Otherwise delegate to the {@link GeodeticAuthorityFactory#createGeodeticCRS(String)} * method in the parent class. This allows to check if the more generic * {@link #createCoordinateReferenceSystem(String)} method cached a value before to try that method.</li> * </ul> * * @return the coordinate reference system for the given code. * @throws FactoryException if the object creation failed. - * - * @deprecated ISO 19111:2019 does not define an explicit class for geocentric CRS. - * The {@code GeodeticCRS} parent class should be used instead. */ @Override - @Deprecated(since = "2.0") - public GeocentricCRS createGeocentricCRS(final String code) throws FactoryException { - if (isDefault(GeocentricCRS.class)) { - return super.createGeocentricCRS(code); + public GeodeticCRS createGeodeticCRS(final String code) throws FactoryException { + if (isDefault(GeodeticCRS.class)) { + return super.createGeodeticCRS(code); } - return create(AuthorityFactoryProxy.GEOCENTRIC_CRS, code); + return create(AuthorityFactoryProxy.GEODETIC_CRS, code); } /** diff --git a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/factory/GeodeticAuthorityFactory.java b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/factory/GeodeticAuthorityFactory.java index 338d80a203..4985f629fc 100644 --- a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/factory/GeodeticAuthorityFactory.java +++ b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/factory/GeodeticAuthorityFactory.java @@ -332,13 +332,9 @@ public abstract class GeodeticAuthorityFactory extends AbstractFactory implement * * @see org.apache.sis.referencing.crs.DefaultGeocentricCRS * @see org.apache.sis.referencing.CommonCRS#geocentric() - * - * @deprecated ISO 19111:2019 does not define an explicit class for geocentric CRS. - * The {@code GeodeticCRS} parent class should be used instead. */ - @Deprecated(since = "2.0") - public GeocentricCRS createGeocentricCRS(final String code) throws NoSuchAuthorityCodeException, FactoryException { - return cast(GeocentricCRS.class, createCoordinateReferenceSystem(code), code); + public GeodeticCRS createGeodeticCRS(final String code) throws NoSuchAuthorityCodeException, FactoryException { + return cast(GeodeticCRS.class, createCoordinateReferenceSystem(code), code); } /** diff --git a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/factory/GeodeticObjectFactory.java b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/factory/GeodeticObjectFactory.java index cf596c51d3..666eb45942 100644 --- a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/factory/GeodeticObjectFactory.java +++ b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/factory/GeodeticObjectFactory.java @@ -317,7 +317,7 @@ public class GeodeticObjectFactory extends AbstractFactory implements CRSFactory /** * Creates a geocentric coordinate reference system from a {@linkplain CartesianCS Cartesian coordinate system}. * Geocentric CRS have their origin at the approximate centre of mass of the earth. - * An {@linkplain #createGeocentricCRS(Map, GeodeticDatum, SphericalCS) alternate method} allows creation of the + * An {@linkplain #createGeodeticCRS(Map, GeodeticDatum, SphericalCS) alternate method} allows creation of the * same kind of CRS with spherical coordinate system instead of a Cartesian one. * * <h4>Dependencies</h4> @@ -340,15 +340,11 @@ public class GeodeticObjectFactory extends AbstractFactory implements CRSFactory * @param cs the three-dimensional Cartesian coordinate system for the created CRS. * @throws FactoryException if the object creation failed. * - * @see GeodeticAuthorityFactory#createGeocentricCRS(String) + * @see GeodeticAuthorityFactory#createGeodeticCRS(String) * @see DefaultGeocentricCRS#DefaultGeocentricCRS(Map, GeodeticDatum, CartesianCS) - * - * @deprecated ISO 19111:2019 does not define an explicit class for geocentric CRS. - * The {@code GeodeticCRS} parent class should be used instead. */ @Override - @Deprecated(since = "2.0") - public GeocentricCRS createGeocentricCRS(final Map<String,?> properties, + public GeodeticCRS createGeodeticCRS(final Map<String,?> properties, final GeodeticDatum datum, final CartesianCS cs) throws FactoryException { final DefaultGeocentricCRS crs; @@ -357,7 +353,7 @@ public class GeodeticObjectFactory extends AbstractFactory implements CRSFactory } catch (IllegalArgumentException exception) { throw new InvalidGeodeticParameterException(exception); } - return unique("createGeocentricCRS", crs); + return unique("createGeodeticCRS", crs); } /** @@ -399,7 +395,7 @@ public class GeodeticObjectFactory extends AbstractFactory implements CRSFactory /** * Creates a geocentric coordinate reference system from a {@linkplain SphericalCS spherical coordinate system}. * Geocentric CRS have their origin at the approximate centre of mass of the earth. - * An {@linkplain #createGeocentricCRS(Map, GeodeticDatum, CartesianCS) alternate method} allows creation of the + * An {@linkplain #createGeodeticCRS(Map, GeodeticDatum, CartesianCS) alternate method} allows creation of the * same kind of CRS with Cartesian coordinate system instead of a spherical one. * * <h4>Dependencies</h4> @@ -423,14 +419,10 @@ public class GeodeticObjectFactory extends AbstractFactory implements CRSFactory * @throws FactoryException if the object creation failed. * * @see DefaultGeocentricCRS#DefaultGeocentricCRS(Map, GeodeticDatum, SphericalCS) - * @see GeodeticAuthorityFactory#createGeocentricCRS(String) - * - * @deprecated ISO 19111:2019 does not define an explicit class for geocentric CRS. - * The {@code GeodeticCRS} parent class should be used instead. + * @see GeodeticAuthorityFactory#createGeodeticCRS(String) */ @Override - @Deprecated(since = "2.0") - public GeocentricCRS createGeocentricCRS(final Map<String,?> properties, + public GeodeticCRS createGeodeticCRS(final Map<String,?> properties, final GeodeticDatum datum, final SphericalCS cs) throws FactoryException { final DefaultGeocentricCRS crs; @@ -439,7 +431,7 @@ public class GeodeticObjectFactory extends AbstractFactory implements CRSFactory } catch (IllegalArgumentException exception) { throw new InvalidGeodeticParameterException(exception); } - return unique("createGeocentricCRS", crs); + return unique("createGeodeticCRS", crs); } /** diff --git a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/factory/MultiAuthoritiesFactory.java b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/factory/MultiAuthoritiesFactory.java index a3a645da73..55fe728fb9 100644 --- a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/factory/MultiAuthoritiesFactory.java +++ b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/factory/MultiAuthoritiesFactory.java @@ -956,14 +956,10 @@ public class MultiAuthoritiesFactory extends GeodeticAuthorityFactory implements * * @return the coordinate reference system for the given code. * @throws FactoryException if the object creation failed. - * - * @deprecated ISO 19111:2019 does not define an explicit class for geocentric CRS. - * The {@code GeodeticCRS} parent class should be used instead. */ @Override - @Deprecated(since = "2.0") - public GeocentricCRS createGeocentricCRS(final String code) throws FactoryException { - return create(AuthorityFactoryProxy.GEOCENTRIC_CRS, code); + public GeodeticCRS createGeodeticCRS(final String code) throws FactoryException { + return create(AuthorityFactoryProxy.GEODETIC_CRS, code); } /** @@ -1666,7 +1662,7 @@ public class MultiAuthoritiesFactory extends GeodeticAuthorityFactory implements if (cs instanceof EllipsoidalCS) { return factory.createGeographicCRS(properties, datum, (EllipsoidalCS) cs); } else if (cs instanceof SphericalCS) { - return factory.createGeocentricCRS(properties, datum, (SphericalCS) cs); + return factory.createGeodeticCRS(properties, datum, (SphericalCS) cs); } } return null; diff --git a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/factory/sql/EPSGDataAccess.java b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/factory/sql/EPSGDataAccess.java index 44ef1d1933..b7b6a74d2e 100644 --- a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/factory/sql/EPSGDataAccess.java +++ b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/factory/sql/EPSGDataAccess.java @@ -1569,9 +1569,9 @@ codes: for (int i=0; i<codes.length; i++) { final Map<String,Object> properties = createProperties("Coordinate Reference System", name, epsg, area, scope, remarks, deprecated); if (cs instanceof CartesianCS) { - crs = crsFactory.createGeocentricCRS(properties, datum, (CartesianCS) cs); + crs = crsFactory.createGeodeticCRS(properties, datum, (CartesianCS) cs); } else if (cs instanceof SphericalCS) { - crs = crsFactory.createGeocentricCRS(properties, datum, (SphericalCS) cs); + crs = crsFactory.createGeodeticCRS(properties, datum, (SphericalCS) cs); } else { throw new FactoryDataException(error().getString( Errors.Keys.IllegalCoordinateSystem_1, cs.getName())); diff --git a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/factory/sql/TableInfo.java b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/factory/sql/TableInfo.java index 44d7e556b1..1b16b321d5 100644 --- a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/factory/sql/TableInfo.java +++ b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/factory/sql/TableInfo.java @@ -61,14 +61,13 @@ final class TableInfo { * * The order is significant: it is the key for a {@code switch} statement. */ - @SuppressWarnings("deprecation") static final TableInfo[] EPSG = { CRS = new TableInfo(CoordinateReferenceSystem.class, "[Coordinate Reference System]", "COORD_REF_SYS_CODE", "COORD_REF_SYS_NAME", "COORD_REF_SYS_KIND", - new Class<?>[] { ProjectedCRS.class, GeographicCRS.class, GeocentricCRS.class, + new Class<?>[] { ProjectedCRS.class, GeographicCRS.class, GeodeticCRS.class, VerticalCRS.class, CompoundCRS.class, EngineeringCRS.class, DerivedCRS.class, TemporalCRS.class, ParametricCRS.class}, // See comment below new String[] {"projected", "geographic", "geocentric", diff --git a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/internal/EPSGFactoryProxyCRS.java b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/internal/EPSGFactoryProxyCRS.java index d257e5d221..38262f0363 100644 --- a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/internal/EPSGFactoryProxyCRS.java +++ b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/internal/EPSGFactoryProxyCRS.java @@ -21,7 +21,7 @@ import org.opengis.referencing.crs.CompoundCRS; import org.opengis.referencing.crs.CoordinateReferenceSystem; import org.opengis.referencing.crs.DerivedCRS; import org.opengis.referencing.crs.EngineeringCRS; -import org.opengis.referencing.crs.GeocentricCRS; +import org.opengis.referencing.crs.GeodeticCRS; import org.opengis.referencing.crs.GeographicCRS; import org.opengis.referencing.crs.ProjectedCRS; import org.opengis.referencing.crs.TemporalCRS; @@ -79,9 +79,8 @@ public final class EPSGFactoryProxyCRS extends EPSGFactoryProxy implements CRSAu } @Override - @Deprecated(since = "2.0") - public GeocentricCRS createGeocentricCRS(String code) throws FactoryException { - return factory().createGeocentricCRS(code); + public GeodeticCRS createGeodeticCRS(String code) throws FactoryException { + return factory().createGeodeticCRS(code); } @Override diff --git a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/internal/Legacy.java b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/internal/Legacy.java index 9adb3d80ce..79324f86ba 100644 --- a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/internal/Legacy.java +++ b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/internal/Legacy.java @@ -51,6 +51,20 @@ import java.time.temporal.Temporal; * @author Martin Desruisseaux (Geomatys) */ public final class Legacy { + /** + * Key for the <code>{@value}</code> property to be given to {@code DerivedCRS} constructors. + * This is used for specifying which interface the derived CRS should implement. + * If no value is associated to this key, then the interface will be inferred + * from the type of the base CRS and the derived coordinate system. + * + * <p>Value shall be an instance of {@code Class} such as {@code EngineeringCRS.class}. + * This key can be used when the type of the CRS to create is potentially ambiguous. + * For example a CRS derived from a {@link GeodeticCRS} can be itself geodetic (which is the default), + * but could also be an {@link EngineeringCRS} if a change of datum type is allowed. + * The latter is normally not allowed, but was nevertheless done in older versions of ISO 19111.</p> + */ + public static final String DERIVED_TYPE_KEY = "derivedType"; + /** * A three-dimensional Cartesian CS with the legacy set of geocentric axes. * OGC 01-009 defines the default geocentric axes as: diff --git a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/operation/DefaultOperationMethod.java b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/operation/DefaultOperationMethod.java index 70a02adcbd..72722234ce 100644 --- a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/operation/DefaultOperationMethod.java +++ b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/operation/DefaultOperationMethod.java @@ -409,7 +409,6 @@ public class DefaultOperationMethod extends AbstractIdentifiedObject implements * @return {@code true} if both objects are equal. */ @Override - @SuppressWarnings("deprecation") public boolean equals(final Object object, final ComparisonMode mode) { if (object == this) { return true; // Slight optimization. diff --git a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/operation/provider/AbstractProvider.java b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/operation/provider/AbstractProvider.java index f3089b3ff6..f7f6f19e72 100644 --- a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/operation/provider/AbstractProvider.java +++ b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/operation/provider/AbstractProvider.java @@ -278,7 +278,7 @@ public abstract class AbstractProvider extends DefaultOperationMethod implements * This is a SIS-specific information which may be changed in any future SIS version. * Current implementation provides this information in a "all or nothing" way: either all parameter values * can have their sign reversed, or either the operation is considered not revertible at all. - * This is different than the EPSG dataset in two way: + * This is different than the EPSG dataset in two ways: * * <ul class="verbose"> * <li>EPSG provides an equivalent information in the {@code PARAM_SIGN_REVERSAL} column of the diff --git a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/privy/ReferencingUtilities.java b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/privy/ReferencingUtilities.java index 5230a4ce64..b8f0346daf 100644 --- a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/privy/ReferencingUtilities.java +++ b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/privy/ReferencingUtilities.java @@ -322,7 +322,7 @@ public final class ReferencingUtilities extends Static { } if (crs instanceof GeodeticCRS) { /* - * At this point we usually have a GeographicCRS, but it could also be a GeocentricCRS. + * At this point we usually have a GeographicCRS, but it could also be a geocentric CRS. * If we can let `forConvention` do its job, do that first since it may return a cached * instance. If the CRS is a `GeographicCRS` but not a `DefaultGeographicCRS`, create a * CRS in this code instead of invoking `DefaultGeographicCRS.castOrCopy(…)` in order diff --git a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/privy/WKTKeywords.java b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/privy/WKTKeywords.java index f2d6f8561a..35cf70a5ec 100644 --- a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/privy/WKTKeywords.java +++ b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/privy/WKTKeywords.java @@ -234,10 +234,10 @@ public final class WKTKeywords extends Static { private static final Map<Class<?>,String[]> TYPES = new HashMap<>(30); static { /* - * `SingleCRS` subtypes. The `GeodeticCRS` is a common parent of - * `GeographicCRS` and `GeocentricCRS`, repeated for both of them. + * `SingleCRS` subtypes. The `GeographicCRS` and `GeocentricCRS` types are handled separately + * because they are implied by the `GeodeticCRS` type in the `subtypes` array, so they do not + * need to be repeated there. */ - addType(org.opengis.referencing.crs.GeocentricCRS.class, GeodeticCRS, GeodCRS, GeocCS); addType(org.opengis.referencing.crs.GeographicCRS.class, GeodeticCRS, GeodCRS, GeogCS); String[][] subtypes; subtypes = new String[][] { diff --git a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/xml/bind/referencing/SC_CRS.java b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/xml/bind/referencing/SC_CRS.java index ba4153c178..765abe0ade 100644 --- a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/xml/bind/referencing/SC_CRS.java +++ b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/xml/bind/referencing/SC_CRS.java @@ -84,8 +84,8 @@ public final class SC_CRS extends PropertyType<SC_CRS, CoordinateReferenceSystem * Invoked by JAXB at unmarshalling time for storing the result temporarily. * * <h4>Design note</h4> - * The unmarshalled CRS may be of {@code GeodeticCRS} type, which is not the most specific GeoAPI type. - * But the {@code GeographicCRS} and {@code GeocentricCRS} sub-types are currently not part of ISO 19111. + * The unmarshalled CRS may be of {@code GeodeticCRS} type, which is not the most specific SIS type. + * But the {@code GeographicCRS} and {@code GeocentricCRS} sub-types do not exist in the GML schema. * We could substitute the CRS by a more specific type here, but this would break the references specified * by {@code xlink:href} attributes. For now we live with the {@code GeodeticCRS} as-is — most of Apache SIS * should be able to work with that. diff --git a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/io/wkt/GeodeticObjectParserTest.java b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/io/wkt/GeodeticObjectParserTest.java index 362722ed93..dd36e4cae3 100644 --- a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/io/wkt/GeodeticObjectParserTest.java +++ b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/io/wkt/GeodeticObjectParserTest.java @@ -241,9 +241,8 @@ public final class GeodeticObjectParserTest extends TestCase { * @throws ParseException if the parsing failed. */ @Test - @SuppressWarnings("deprecation") public void testGeocentricCRS() throws ParseException { - final GeocentricCRS crs = parse(GeocentricCRS.class, + final GeodeticCRS crs = parse(GeodeticCRS.class, "GEOCCS[“Geocentric”,\n" + " DATUM[“World Geodetic System 1984”,\n" + " SPHEROID[“WGS84”, 6378137.0, 298.257223563, AUTHORITY[“EPSG”, “7030”]],\n" + diff --git a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/CommonCRSTest.java b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/CommonCRSTest.java index 68387a29f3..33cb5ac12a 100644 --- a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/CommonCRSTest.java +++ b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/CommonCRSTest.java @@ -26,7 +26,7 @@ import org.opengis.referencing.IdentifiedObject; import org.opengis.referencing.crs.TemporalCRS; import org.opengis.referencing.crs.VerticalCRS; import org.opengis.referencing.crs.GeographicCRS; -import org.opengis.referencing.crs.GeocentricCRS; +import org.opengis.referencing.crs.GeodeticCRS; import org.opengis.referencing.crs.ProjectedCRS; import org.opengis.referencing.cs.AxisDirection; import org.opengis.referencing.cs.CoordinateSystem; @@ -176,9 +176,8 @@ public final class CommonCRSTest extends TestCase { * Tests the {@link CommonCRS#geocentric()} method. */ @Test - @SuppressWarnings("deprecation") public void testGeocentric() { - final GeocentricCRS crs = CommonCRS.WGS72.geocentric(); + final GeodeticCRS crs = CommonCRS.WGS72.geocentric(); Validators.validate(crs); assertEquals ("WGS 72", crs.getName().getCode()); assertSame (CommonCRS.WGS72.geographic().getDatum(), crs.getDatum()); @@ -196,9 +195,8 @@ public final class CommonCRSTest extends TestCase { * Tests the {@link CommonCRS#spherical()} method. */ @Test - @SuppressWarnings("deprecation") public void testSpherical() { - final GeocentricCRS crs = CommonCRS.ETRS89.spherical(); + final GeodeticCRS crs = CommonCRS.ETRS89.spherical(); Validators.validate(crs); assertEquals ("ETRS89", crs.getName().getCode()); assertSame (CommonCRS.ETRS89.geographic().getDatum(), crs.getDatum()); diff --git a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/EPSGFactoryFallbackTest.java b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/EPSGFactoryFallbackTest.java index 0fb25ebb21..dc82cff0f2 100644 --- a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/EPSGFactoryFallbackTest.java +++ b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/EPSGFactoryFallbackTest.java @@ -24,7 +24,7 @@ import org.opengis.util.FactoryException; import org.opengis.referencing.crs.SingleCRS; import org.opengis.referencing.crs.VerticalCRS; import org.opengis.referencing.crs.GeographicCRS; -import org.opengis.referencing.crs.GeocentricCRS; +import org.opengis.referencing.crs.GeodeticCRS; import org.opengis.referencing.crs.ProjectedCRS; import org.opengis.referencing.crs.CoordinateReferenceSystem; import org.opengis.referencing.cs.CoordinateSystem; @@ -70,7 +70,6 @@ public final class EPSGFactoryFallbackTest extends TestCaseWithLogs { * @throws FactoryException if the set of authority codes cannot be fetched. */ @Test - @SuppressWarnings("deprecation") public void testGetAuthorityCodes() throws FactoryException { assertSetEquals(List.of(StandardDefinitions.GREENWICH), EPSGFactoryFallback.INSTANCE.getAuthorityCodes(PrimeMeridian.class)); @@ -84,12 +83,18 @@ public final class EPSGFactoryFallbackTest extends TestCaseWithLogs { EPSGFactoryFallback.INSTANCE.getAuthorityCodes(SphericalCS.class)); assertSetEquals(List.of("6500", "4400", "1026", "1027"), EPSGFactoryFallback.INSTANCE.getAuthorityCodes(CartesianCS.class)); - assertSetEquals(List.of("4978", "4984", "4936"), - EPSGFactoryFallback.INSTANCE.getAuthorityCodes(GeocentricCRS.class)); assertSetEquals(List.of("4326", "4322", "4019", "4047", "4269", "4267", "4258", "4230", "4979", "4985", "4937"), EPSGFactoryFallback.INSTANCE.getAuthorityCodes(GeographicCRS.class)); assertSetEquals(List.of("5714", "5715", "5703"), EPSGFactoryFallback.INSTANCE.getAuthorityCodes(VerticalCRS.class)); + /* + * Geodetic CRS include geographic CRS with the addition of the following. + */ + Set<String> geographic = EPSGFactoryFallback.INSTANCE.getAuthorityCodes(GeographicCRS.class); + Set<String> geodetic = EPSGFactoryFallback.INSTANCE.getAuthorityCodes(GeodeticCRS.class); + assertTrue(geodetic.containsAll(geographic)); + assertTrue(geodetic.removeAll(geographic)); + assertSetEquals(List.of("4978", "4984", "4936"), geodetic); /* * There is too many ProjectedCRS codes for enumerating all of them, so test only a sampling. */ @@ -265,6 +270,7 @@ public final class EPSGFactoryFallbackTest extends TestCaseWithLogs { } loggings.skipNextLogIfContains("EPSG:4047"); loggings.skipNextLogIfContains("EPSG:4019"); // Deprecated EPSG entry. + loggings.skipNextLogIfContains("EPSG:4047"); // Repeated because order may vary. loggings.assertNoUnexpectedLog(); } } diff --git a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/crs/DefaultDerivedCRSTest.java b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/crs/DefaultDerivedCRSTest.java index cdf8024a09..84b99e3d04 100644 --- a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/crs/DefaultDerivedCRSTest.java +++ b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/crs/DefaultDerivedCRSTest.java @@ -69,50 +69,50 @@ public final class DefaultDerivedCRSTest extends TestCase { } /** - * Tests {@link DefaultDerivedCRS#getType(SingleCRS, CoordinateSystem)}. + * Tests {@link DefaultDerivedCRS#getTypeKeyword(Map, SingleCRS, CoordinateSystem)}. */ @Test public void testGetType() { // Using consistent arguments. assertEquals(WKTKeywords.VerticalCRS, - DefaultDerivedCRS.getType(HardCodedCRS.ELLIPSOIDAL_HEIGHT, HardCodedCS.GRAVITY_RELATED_HEIGHT)); + DefaultDerivedCRS.getTypeKeyword(null, HardCodedCRS.ELLIPSOIDAL_HEIGHT, HardCodedCS.GRAVITY_RELATED_HEIGHT)); // Using inconsistent arguments. - assertNull(DefaultDerivedCRS.getType(HardCodedCRS.ELLIPSOIDAL_HEIGHT, HardCodedCS.SECONDS)); + assertNull(DefaultDerivedCRS.getTypeKeyword(null, HardCodedCRS.ELLIPSOIDAL_HEIGHT, HardCodedCS.SECONDS)); // Using consistent arguments. assertEquals(WKTKeywords.TimeCRS, - DefaultDerivedCRS.getType(HardCodedCRS.TIME, HardCodedCS.SECONDS)); + DefaultDerivedCRS.getTypeKeyword(null, HardCodedCRS.TIME, HardCodedCS.SECONDS)); // Using inconsistent arguments. - assertNull(DefaultDerivedCRS.getType(HardCodedCRS.TIME, HardCodedCS.GRAVITY_RELATED_HEIGHT)); + assertNull(DefaultDerivedCRS.getTypeKeyword(null, HardCodedCRS.TIME, HardCodedCS.GRAVITY_RELATED_HEIGHT)); // Using consistent arguments. assertEquals(WKTKeywords.GeodeticCRS, - DefaultDerivedCRS.getType(HardCodedCRS.WGS84, HardCodedCS.GEODETIC_2D)); + DefaultDerivedCRS.getTypeKeyword(null, HardCodedCRS.WGS84, HardCodedCS.GEODETIC_2D)); // Using consistent arguments but one more dimension. assertEquals(WKTKeywords.GeodeticCRS, - DefaultDerivedCRS.getType(HardCodedCRS.WGS84, HardCodedCS.GEODETIC_3D)); + DefaultDerivedCRS.getTypeKeyword(null, HardCodedCRS.WGS84, HardCodedCS.GEODETIC_3D)); // Using consistent arguments. assertEquals(WKTKeywords.GeodeticCRS, - DefaultDerivedCRS.getType(HardCodedCRS.GEOCENTRIC, HardCodedCS.CARTESIAN_3D)); + DefaultDerivedCRS.getTypeKeyword(null, HardCodedCRS.GEOCENTRIC, HardCodedCS.CARTESIAN_3D)); // Using consistent arguments but one less dimension. assertEquals(WKTKeywords.GeodeticCRS, - DefaultDerivedCRS.getType(HardCodedCRS.GEOCENTRIC, HardCodedCS.CARTESIAN_2D)); + DefaultDerivedCRS.getTypeKeyword(null, HardCodedCRS.GEOCENTRIC, HardCodedCS.CARTESIAN_2D)); // Using different coordinate system type. assertEquals(WKTKeywords.GeodeticCRS, - DefaultDerivedCRS.getType(HardCodedCRS.GEOCENTRIC, HardCodedCS.SPHERICAL)); + DefaultDerivedCRS.getTypeKeyword(null, HardCodedCRS.GEOCENTRIC, HardCodedCS.SPHERICAL)); // Using different coordinate system type. assertEquals(WKTKeywords.GeodeticCRS, - DefaultDerivedCRS.getType(HardCodedCRS.WGS84, HardCodedCS.CARTESIAN_2D)); + DefaultDerivedCRS.getTypeKeyword(null, HardCodedCRS.WGS84, HardCodedCS.CARTESIAN_2D)); // Using illegal coordinate system type. - assertNull(DefaultDerivedCRS.getType(HardCodedCRS.WGS84, HardCodedCS.GRAVITY_RELATED_HEIGHT)); + assertNull(DefaultDerivedCRS.getTypeKeyword(null, HardCodedCRS.WGS84, HardCodedCS.GRAVITY_RELATED_HEIGHT)); } /** diff --git a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/factory/AuthorityFactoryMock.java b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/factory/AuthorityFactoryMock.java index 010e8db29d..f1762481ef 100644 --- a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/factory/AuthorityFactoryMock.java +++ b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/factory/AuthorityFactoryMock.java @@ -24,7 +24,7 @@ import org.opengis.metadata.citation.Citation; import org.opengis.referencing.IdentifiedObject; import org.opengis.referencing.NoSuchAuthorityCodeException; import org.opengis.referencing.crs.CRSAuthorityFactory; -import org.opengis.referencing.crs.GeocentricCRS; +import org.opengis.referencing.crs.GeodeticCRS; import org.opengis.referencing.crs.GeographicCRS; import org.opengis.referencing.crs.VerticalCRS; import org.opengis.referencing.cs.EllipsoidalCS; @@ -108,11 +108,10 @@ public final class AuthorityFactoryMock extends GeodeticAuthorityFactory impleme * @return the set of authority codes for referencing objects of the given type. */ @Override - @SuppressWarnings("deprecation") public Set<String> getAuthorityCodes(Class<? extends IdentifiedObject> type) { assertFalse(isClosed()); final Set<String> codes = new LinkedHashSet<>(); - if (type.isAssignableFrom(GeocentricCRS.class)) add(codes, 4979); + if (type.isAssignableFrom(GeodeticCRS.class)) add(codes, 4979); if (type.isAssignableFrom(GeographicCRS.class)) add(codes, 84, 4326); if (type.isAssignableFrom(PrimeMeridian.class)) add(codes, 8901, 8903, 8914); if (type.isAssignableFrom(GeodeticDatum.class)) add(codes, 6326, 6322, 6807, 6301, 6612, 6047); diff --git a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/factory/MultiAuthoritiesFactoryTest.java b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/factory/MultiAuthoritiesFactoryTest.java index e57be20fd2..7811744d27 100644 --- a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/factory/MultiAuthoritiesFactoryTest.java +++ b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/factory/MultiAuthoritiesFactoryTest.java @@ -22,7 +22,6 @@ import org.opengis.referencing.IdentifiedObject; import org.opengis.referencing.NoSuchAuthorityCodeException; import org.opengis.referencing.crs.CRSAuthorityFactory; import org.opengis.referencing.crs.CoordinateReferenceSystem; -import org.opengis.referencing.crs.GeocentricCRS; import org.opengis.referencing.crs.GeodeticCRS; import org.opengis.referencing.crs.GeographicCRS; import org.opengis.referencing.crs.VerticalCRS; @@ -68,11 +67,9 @@ public final class MultiAuthoritiesFactoryTest extends TestCaseWithLogs { * @throws FactoryException if no object was found for a code. */ @Test - @SuppressWarnings("deprecation") public void testAuthorityFactoryMock() throws FactoryException { final var factory = new AuthorityFactoryMock("MOCK", null); final Class<?>[] types = { - GeocentricCRS.class, GeographicCRS.class, GeodeticDatum.class, VerticalDatum.class, diff --git a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/factory/sql/EPSGFactoryTest.java b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/factory/sql/EPSGFactoryTest.java index 3cc0a49e78..c754bc93af 100644 --- a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/factory/sql/EPSGFactoryTest.java +++ b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/factory/sql/EPSGFactoryTest.java @@ -175,8 +175,7 @@ public final class EPSGFactoryTest extends TestCaseWithLogs { @Test public void testGeocentric() throws FactoryException { final EPSGFactory factory = dataEPSG.factory(); - @SuppressWarnings("deprecation") - final GeocentricCRS crs = factory.createGeocentricCRS("epsg:4915"); + final GeodeticCRS crs = factory.createGeodeticCRS("epsg:4915"); assertEpsgNameAndIdentifierEqual("ITRF93", 4915, crs); assertEpsgNameAndIdentifierEqual("International Terrestrial Reference Frame 1993", 6652, crs.getDatum()); assertAxisDirectionsEqual(crs.getCoordinateSystem(), AxisDirection.GEOCENTRIC_X, AxisDirection.GEOCENTRIC_Y, AxisDirection.GEOCENTRIC_Z); diff --git a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/CoordinateOperationFinderTest.java b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/CoordinateOperationFinderTest.java index 3e4a28e8f0..45672693bb 100644 --- a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/CoordinateOperationFinderTest.java +++ b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/CoordinateOperationFinderTest.java @@ -24,7 +24,7 @@ import org.opengis.util.FactoryException; import org.opengis.parameter.ParameterValueGroup; import org.opengis.referencing.cs.AxisDirection; import org.opengis.referencing.crs.GeographicCRS; -import org.opengis.referencing.crs.GeocentricCRS; +import org.opengis.referencing.crs.GeodeticCRS; import org.opengis.referencing.crs.VerticalCRS; import org.opengis.referencing.crs.TemporalCRS; import org.opengis.referencing.crs.CompoundCRS; @@ -366,8 +366,7 @@ public final class CoordinateOperationFinderTest extends MathTransformTestCase { " Axis[“(Z)”, geocentricZ],\n" + " Unit[“kilometre”, 1000]]"); - @SuppressWarnings("deprecation") - final GeocentricCRS targetCRS = CommonCRS.WGS84.geocentric(); + final GeodeticCRS targetCRS = CommonCRS.WGS84.geocentric(); final CoordinateOperation operation = finder().createOperation(sourceCRS, targetCRS); assertSame(sourceCRS, operation.getSourceCRS()); diff --git a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/privy/WKTKeywordsTest.java b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/privy/WKTKeywordsTest.java index 6da8c448ba..bbfb963e00 100644 --- a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/privy/WKTKeywordsTest.java +++ b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/privy/WKTKeywordsTest.java @@ -71,12 +71,11 @@ public final class WKTKeywordsTest extends TestCase { * contain all WKT keywords associated to subtypes. */ @Test - @SuppressWarnings("deprecation") public void verifyTypeHierarchy() { - verifyTypeHierarchy(SingleCRS.class, GeocentricCRS.class, GeographicCRS.class, ProjectedCRS.class, + verifyTypeHierarchy(SingleCRS.class, GeodeticCRS.class, GeographicCRS.class, ProjectedCRS.class, VerticalCRS.class, TemporalCRS.class, EngineeringCRS.class); verifyTypeHierarchy(CoordinateReferenceSystem.class, SingleCRS.class, CompoundCRS.class, - GeocentricCRS.class, GeographicCRS.class, ProjectedCRS.class, + GeodeticCRS.class, GeographicCRS.class, ProjectedCRS.class, VerticalCRS.class, TemporalCRS.class, EngineeringCRS.class); verifyTypeHierarchy(Datum.class, GeodeticDatum.class, VerticalDatum.class, TemporalDatum.class, EngineeringDatum.class); diff --git a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/report/CoordinateReferenceSystems.java b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/report/CoordinateReferenceSystems.java index 945607b763..19f1056342 100644 --- a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/report/CoordinateReferenceSystems.java +++ b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/report/CoordinateReferenceSystems.java @@ -34,7 +34,7 @@ import org.opengis.referencing.cs.SphericalCS; import org.opengis.referencing.cs.CoordinateSystem; import org.opengis.referencing.crs.CompoundCRS; import org.opengis.referencing.crs.VerticalCRS; -import org.opengis.referencing.crs.GeocentricCRS; +import org.opengis.referencing.crs.GeodeticCRS; import org.opengis.referencing.crs.GeographicCRS; import org.opengis.referencing.crs.EngineeringCRS; import org.opengis.referencing.crs.GeneralDerivedCRS; @@ -421,7 +421,7 @@ public final class CoordinateReferenceSystems extends AuthorityCodesReport { + "\">" + method.getName().getCode().replace('_', ' ') + "</a>"; } } - if (crs instanceof GeocentricCRS) { + if (crs instanceof GeodeticCRS) { final CoordinateSystem cs = crs.getCoordinateSystem(); if (cs instanceof CartesianCS) { return "Geocentric (Cartesian coordinate system)"; diff --git a/endorsed/src/org.apache.sis.storage.geotiff/main/org/apache/sis/storage/geotiff/reader/CRSBuilder.java b/endorsed/src/org.apache.sis.storage.geotiff/main/org/apache/sis/storage/geotiff/reader/CRSBuilder.java index 8b4e33ec33..0412578521 100644 --- a/endorsed/src/org.apache.sis.storage.geotiff/main/org/apache/sis/storage/geotiff/reader/CRSBuilder.java +++ b/endorsed/src/org.apache.sis.storage.geotiff/main/org/apache/sis/storage/geotiff/reader/CRSBuilder.java @@ -42,7 +42,7 @@ import org.opengis.parameter.ParameterValueGroup; import org.opengis.parameter.ParameterNotFoundException; import org.opengis.referencing.IdentifiedObject; import org.opengis.referencing.NoSuchAuthorityCodeException; -import org.opengis.referencing.crs.GeocentricCRS; +import org.opengis.referencing.crs.GeodeticCRS; import org.opengis.referencing.crs.GeographicCRS; import org.opengis.referencing.crs.CoordinateReferenceSystem; import org.opengis.referencing.crs.ProjectedCRS; @@ -1121,8 +1121,7 @@ public final class CRSBuilder extends ReferencingFactoryContainer { * * @see #createGeodeticDatum(String[], Unit, Unit) */ - @SuppressWarnings("deprecation") - private GeocentricCRS createGeocentricCRS() throws FactoryException { + private GeodeticCRS createGeocentricCRS() throws FactoryException { final int epsg = getAsInteger(GeoKeys.GeodeticCRS); switch (epsg) { case GeoCodes.undefined: { @@ -1142,7 +1141,7 @@ public final class CRSBuilder extends ReferencingFactoryContainer { if (!Units.METRE.equals(linearUnit)) { cs = replaceLinearUnit(cs, linearUnit); } - final GeocentricCRS crs = getCRSFactory().createGeocentricCRS(properties(getOrDefault(names, GCRS)), datum, cs); + final GeodeticCRS crs = getCRSFactory().createGeodeticCRS(properties(getOrDefault(names, GCRS)), datum, cs); lastName = crs.getName(); return crs; } @@ -1152,7 +1151,7 @@ public final class CRSBuilder extends ReferencingFactoryContainer { * But if the file also defines the components, verify that those components are consistent * with what we would expect for a CRS of the given EPSG code. */ - final GeocentricCRS crs = getCRSAuthorityFactory().createGeocentricCRS(String.valueOf(epsg)); + final GeodeticCRS crs = getCRSAuthorityFactory().createGeodeticCRS(String.valueOf(epsg)); verify(crs); return crs; } @@ -1166,8 +1165,7 @@ public final class CRSBuilder extends ReferencingFactoryContainer { * * @param crs the CRS created from the EPSG geodetic dataset. */ - @SuppressWarnings("deprecation") - private void verify(final GeocentricCRS crs) throws FactoryException { + private void verify(final GeodeticCRS crs) throws FactoryException { /* * Note: current createUnit(…) implementation does not allow us to distinguish whether METRE ou DEGREE units * were specified in the GeoTIFF file or if we got the default values. We do not compare units for that reason. diff --git a/endorsed/src/org.apache.sis.storage.netcdf/main/org/apache/sis/storage/netcdf/base/CRSBuilder.java b/endorsed/src/org.apache.sis.storage.netcdf/main/org/apache/sis/storage/netcdf/base/CRSBuilder.java index 29a1c9b0cb..7e2b7b8173 100644 --- a/endorsed/src/org.apache.sis.storage.netcdf/main/org/apache/sis/storage/netcdf/base/CRSBuilder.java +++ b/endorsed/src/org.apache.sis.storage.netcdf/main/org/apache/sis/storage/netcdf/base/CRSBuilder.java @@ -33,8 +33,8 @@ import org.opengis.referencing.cs.*; import org.opengis.referencing.datum.*; import org.opengis.referencing.crs.SingleCRS; import org.opengis.referencing.crs.CRSFactory; +import org.opengis.referencing.crs.GeodeticCRS; import org.opengis.referencing.crs.GeographicCRS; -import org.opengis.referencing.crs.GeocentricCRS; import org.opengis.referencing.crs.CoordinateReferenceSystem; import org.opengis.referencing.operation.OperationMethod; import org.opengis.referencing.operation.Conversion; @@ -662,11 +662,10 @@ previous: for (int i=components.size(); --i >= 0;) { * Possibly sets {@link #datum} and {@link #coordinateSystem} to predefined objects * matching the axes defined in the netCDF file. */ - @SuppressWarnings("deprecation") @Override void setPredefinedComponents(final Decoder decoder) throws FactoryException { super.setPredefinedComponents(decoder); if (isPredefinedCS(Units.DEGREE)) { - GeocentricCRS crs = defaultCRS.spherical(); + GeodeticCRS crs = defaultCRS.spherical(); if (isLongitudeFirst) { crs = DefaultGeocentricCRS.castOrCopy(crs).forConvention(AxesConvention.RIGHT_HANDED); } @@ -696,7 +695,7 @@ previous: for (int i=components.size(); --i >= 0;) { * This method is invoked under conditions similar to the ones of above {@code createCS(…)} method. */ @Override void createCRS(CRSFactory factory, Map<String,?> properties) throws FactoryException { - referenceSystem = factory.createGeocentricCRS(properties, datum, coordinateSystem); + referenceSystem = factory.createGeodeticCRS(properties, datum, coordinateSystem); } } diff --git a/geoapi/snapshot b/geoapi/snapshot index 0c4eba464e..62db019354 160000 --- a/geoapi/snapshot +++ b/geoapi/snapshot @@ -1 +1 @@ -Subproject commit 0c4eba464e80d307637806cb76cf56fa494e1f75 +Subproject commit 62db019354dc62d805b877c4b37227ed68ed0a7c diff --git a/optional/src/org.apache.sis.gui/main/org/apache/sis/gui/referencing/CRSChooser.java b/optional/src/org.apache.sis.gui/main/org/apache/sis/gui/referencing/CRSChooser.java index f4ec1b16a5..1630a4efd2 100644 --- a/optional/src/org.apache.sis.gui/main/org/apache/sis/gui/referencing/CRSChooser.java +++ b/optional/src/org.apache.sis.gui/main/org/apache/sis/gui/referencing/CRSChooser.java @@ -47,7 +47,6 @@ import org.opengis.geometry.Envelope; import org.opengis.util.FactoryException; import org.opengis.referencing.crs.GeodeticCRS; import org.opengis.referencing.crs.GeographicCRS; -import org.opengis.referencing.crs.GeocentricCRS; import org.opengis.referencing.crs.ProjectedCRS; import org.opengis.referencing.crs.VerticalCRS; import org.opengis.referencing.crs.TemporalCRS; @@ -377,8 +376,7 @@ public class CRSChooser extends Dialog<CoordinateReferenceSystem> { final short key; final int expected; if (crs instanceof GeographicCRS) {key = Vocabulary.Keys.Geographic; expected = 2;} - else if (crs instanceof GeocentricCRS) {key = Vocabulary.Keys.Geocentric; expected = 3;} - else if (crs instanceof GeodeticCRS) {key = Vocabulary.Keys.Geodetic; expected = 0;} + else if (crs instanceof GeodeticCRS) {key = Vocabulary.Keys.Geocentric; expected = 2;} else if (crs instanceof VerticalCRS) {key = Vocabulary.Keys.Vertical; expected = 1;} else if (crs instanceof TemporalCRS) {key = Vocabulary.Keys.Temporal; expected = 1;} else if (crs instanceof ProjectedCRS) {key = Vocabulary.Keys.Projected; expected = 2;}