This is an automated email from the ASF dual-hosted git repository. desruisseaux pushed a commit to branch geoapi-3.1 in repository https://gitbox.apache.org/repos/asf/sis.git
commit 20ded9bfa17d1c1217c96f5bb3a897bbc25d535b Merge: d9303f1d7d 6c50bd371c Author: Martin Desruisseaux <martin.desruisse...@geomatys.com> AuthorDate: Tue Apr 16 15:36:18 2024 +0200 Merge branch 'geoapi-4.0' into geoapi-3.1, but keep checking for `GeneralDerivedCRS` in `instanceof` checks. .../org/apache/sis/buildtools/book/GEOAPI.lst | 1 - .../geometry/wrapper/SpatialOperationContext.java | 2 ++ .../apache/sis/io/wkt/GeodeticObjectParser.java | 2 +- .../org/apache/sis/io/wkt/MathTransformParser.java | 2 +- .../main/org/apache/sis/io/wkt/WKTFormat.java | 4 ++-- .../main/org/apache/sis/referencing/CRS.java | 7 +++--- .../sis/referencing/crs/AbstractDerivedCRS.java | 1 + .../sis/referencing/crs/DefaultDerivedCRS.java | 5 ++--- .../referencing/datum/DefaultPrimeMeridian.java | 1 + .../referencing/factory/AuthorityFactoryProxy.java | 1 + .../factory/MultiAuthoritiesFactory.java | 4 +++- .../referencing/factory/sql/AuthorityCodes.java | 10 +++++---- .../factory/sql/CoordinateOperationSet.java | 1 + .../referencing/factory/sql/EPSGCodeFinder.java | 2 +- .../sis/referencing/factory/sql/TableInfo.java | 25 +++++++++++++++++++++- .../operation/AbstractCoordinateOperation.java | 11 +++++----- .../operation/CoordinateOperationFinder.java | 21 +++++++++++------- .../operation/DefaultOperationMethod.java | 1 + .../referencing/operation/SubOperationInfo.java | 1 + .../operation/transform/ConcatenatedTransform.java | 2 +- .../referencing/privy/CoordinateOperations.java | 1 + .../sis/referencing/privy/DefinitionVerifier.java | 1 + .../report/CoordinateOperationMethods.java | 6 +++--- .../report/CoordinateReferenceSystems.java | 5 ++--- .../integration/CoordinateReferenceSystemTest.java | 5 ++--- geoapi/snapshot | 2 +- .../src/org.apache.sis.gui/bundle/conf/imports.jsh | 1 - 27 files changed, 82 insertions(+), 43 deletions(-) diff --cc endorsed/src/org.apache.sis.feature/main/org/apache/sis/geometry/wrapper/SpatialOperationContext.java index 871ce7619b,c372eff258..ed14df684c --- a/endorsed/src/org.apache.sis.feature/main/org/apache/sis/geometry/wrapper/SpatialOperationContext.java +++ b/endorsed/src/org.apache.sis.feature/main/org/apache/sis/geometry/wrapper/SpatialOperationContext.java @@@ -304,6 -304,6 +304,7 @@@ select: if (commonCRS == null) * @throws TransformException if a coordinate conversion was required but failed. * @throws IncommensurableException if a coordinate system does not use the expected units. */ ++ @SuppressWarnings("deprecation") private static CoordinateReferenceSystem usingSystemUnit(final GeometryWrapper geometry, final CoordinateReferenceSystem geometryCRS, CoordinateReferenceSystem targetCRS, @@@ -372,6 -372,6 +373,7 @@@ * @throws TransformException if a coordinate conversion was required but failed. * @throws IncommensurableException if a coordinate system does not use the expected units. */ ++ @SuppressWarnings("deprecation") ProjectedCRS create(final GeographicCRS baseCRS, DirectPosition centroid, CoordinateReferenceSystem geometryCRS) throws FactoryException, TransformException, IncommensurableException { diff --cc endorsed/src/org.apache.sis.referencing/main/org/apache/sis/io/wkt/GeodeticObjectParser.java index 5ce1cc255d,4fb5f64603..d6ab6fa8cf --- 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 @@@ -1714,8 -1708,8 +1714,8 @@@ class GeodeticObjectParser extends Math * @param parent the parent element. * @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. + * Should be non-null only when parsing a {@link DerivedCRS#getBaseCRS()} component. - * @return the {@code "GeodeticCRS"} element as a {@link GeographicCRS} or {@link GeodeticCRS} object. + * @return the {@code "GeodeticCRS"} element as a {@link GeographicCRS} or {@link GeocentricCRS} object. * @throws ParseException if the {@code "GeodeticCRS"} element cannot be parsed. * * @see org.apache.sis.referencing.crs.DefaultGeographicCRS#formatTo(Formatter) diff --cc endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/CRS.java index 6ffbe5671c,5cc2248a7b..7176d84e27 --- a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/CRS.java +++ b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/CRS.java @@@ -38,9 -38,9 +38,10 @@@ import org.opengis.referencing.crs.Sing import org.opengis.referencing.crs.CompoundCRS; import org.opengis.referencing.crs.CoordinateReferenceSystem; import org.opengis.referencing.crs.CRSAuthorityFactory; + import org.opengis.referencing.crs.DerivedCRS; import org.opengis.referencing.crs.GeodeticCRS; import org.opengis.referencing.crs.GeographicCRS; +import org.opengis.referencing.crs.GeneralDerivedCRS; import org.opengis.referencing.crs.ProjectedCRS; import org.opengis.referencing.crs.TemporalCRS; import org.opengis.referencing.crs.VerticalCRS; diff --cc endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/crs/AbstractDerivedCRS.java index 950e43fe36,e27652217b..ebbd881eee --- a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/crs/AbstractDerivedCRS.java +++ b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/crs/AbstractDerivedCRS.java @@@ -60,7 -60,7 +60,8 @@@ import org.apache.sis.util.resources.Er DefaultDerivedCRS.class, DefaultProjectedCRS.class }) -abstract class AbstractDerivedCRS<C extends Conversion> extends AbstractCRS implements DerivedCRS { ++@SuppressWarnings("deprecation") +abstract class AbstractDerivedCRS<C extends Conversion> extends AbstractCRS implements GeneralDerivedCRS { /** * Serial number for inter-operability with different versions. */ diff --cc endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/datum/DefaultPrimeMeridian.java index b9ba5f0f7b,46cca6c3ed..70f6950895 --- a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/datum/DefaultPrimeMeridian.java +++ b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/datum/DefaultPrimeMeridian.java @@@ -326,8 -326,8 +326,9 @@@ public class DefaultPrimeMeridian exten * * @see org.apache.sis.referencing.crs.AbstractCRS#isBaseCRS(Formatter) */ ++ @SuppressWarnings("deprecation") private static boolean isElementOfBaseCRS(final Formatter formatter) { - return formatter.getEnclosingElement(2) instanceof DerivedCRS; + return formatter.getEnclosingElement(2) instanceof GeneralDerivedCRS; } /** diff --cc endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/factory/AuthorityFactoryProxy.java index 1c2cba8911,6e13333fcd..dd8756e091 --- 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 @@@ -568,10 -540,9 +568,11 @@@ abstract class AuthorityFactoryProxy<T * with a preference for those who are more likely to be requested. * This field can be declared only after all the above constants. */ ++ @SuppressWarnings("deprecation") static final AuthorityFactoryProxy<?>[] PROXIES = new AuthorityFactoryProxy<?>[] { - PROJECTED_CRS, // Special kind of DerivedCRS. + PROJECTED_CRS, // Special kind of GeneralDerivedCRS. GEOGRAPHIC_CRS, // Special kind of GeodeticCRS. + GEOCENTRIC_CRS, // Special kind of GeodeticCRS. GEODETIC_CRS, VERTICAL_CRS, TEMPORAL_CRS, diff --cc endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/factory/sql/CoordinateOperationSet.java index 63cd3c8159,f53666783b..607bd27cae --- a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/factory/sql/CoordinateOperationSet.java +++ b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/factory/sql/CoordinateOperationSet.java @@@ -110,6 -110,6 +110,7 @@@ final class CoordinateOperationSet exte * Creates a coordinate operation for the specified EPSG code. */ @Override ++ @SuppressWarnings("deprecation") protected CoordinateOperation createObject(final String code) throws FactoryException { final Integer base = projections.get(code); if (base != null) { diff --cc endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/factory/sql/TableInfo.java index 44d7e556b1,c7ed64c976..906f1e94a6 --- 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 @@@ -250,6 -259,27 +251,28 @@@ final class TableInfo return CharSequences.isAcronymForWords(name, expected); } + /** + * Appends a {@code WHERE} clause together with a condition for searching the specified object. + * This method delegates to {@link #where(Class, StringBuilder)} with the type of the given object, + * except that some object properties may be inspected for resolving ambiguities. + * + * @param object the object to search in the database. + * @param buffer where to append the {@code WHERE} clause. + */ ++ @SuppressWarnings("deprecation") + final void where(final IdentifiedObject object, final StringBuilder buffer) { + Class<?> userType = object.getClass(); + if (object instanceof GeodeticCRS) { + final CoordinateSystem cs = ((GeodeticCRS) object).getCoordinateSystem(); + if (cs instanceof EllipsoidalCS) { + userType = GeographicCRS.class; + } else if (cs instanceof CartesianCS || cs instanceof SphericalCS) { - userType = DefaultGeocentricCRS.class; ++ userType = GeocentricCRS.class; + } + } + where(userType, buffer); + } + /** * Appends a {@code WHERE} clause together with a condition for searching the most specific subtype, * if such condition can be added. The clause appended by this method looks like the following example diff --cc endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/operation/AbstractCoordinateOperation.java index b75d81ee06,75910575f1..ca25647a0c --- a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/operation/AbstractCoordinateOperation.java +++ b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/operation/AbstractCoordinateOperation.java @@@ -34,8 -34,8 +34,9 @@@ import org.opengis.util.InternationalSt import org.opengis.metadata.Identifier; import org.opengis.metadata.quality.PositionalAccuracy; import org.opengis.referencing.IdentifiedObject; + import org.opengis.referencing.crs.DerivedCRS; import org.opengis.referencing.crs.GeographicCRS; +import org.opengis.referencing.crs.GeneralDerivedCRS; import org.opengis.referencing.crs.CoordinateReferenceSystem; import org.opengis.referencing.operation.ConcatenatedOperation; import org.opengis.referencing.operation.CoordinateOperation; @@@ -498,12 -497,12 +499,12 @@@ check: for (int isTarget=0; ; isTa /* * Trick: we do not need to verify if (this instanceof Conversion) because: * - Only DefaultConversion constructor accepts null source and target CRS. - * - GeneralDerivedCRS.getConversionFromBase() return type is Conversion. + * - DerivedCRS.getConversionFromBase() return type is Conversion. */ return (sourceCRS == null && targetCRS == null) - || ((targetCRS instanceof DerivedCRS) - && ((DerivedCRS) targetCRS).getBaseCRS() == sourceCRS - && ((DerivedCRS) targetCRS).getConversionFromBase() == this); + || ((targetCRS instanceof GeneralDerivedCRS) + && ((GeneralDerivedCRS) targetCRS).getBaseCRS() == sourceCRS + && ((GeneralDerivedCRS) targetCRS).getConversionFromBase() == this); } /** diff --cc endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/operation/CoordinateOperationFinder.java index 91d78cbf25,4321c63a26..82eeff00dc --- a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/operation/CoordinateOperationFinder.java +++ b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/operation/CoordinateOperationFinder.java @@@ -226,6 -226,6 +226,7 @@@ public class CoordinateOperationFinder * @since 1.0 */ @Override ++ @SuppressWarnings("deprecation") public List<CoordinateOperation> createOperations(final CoordinateReferenceSystem sourceCRS, final CoordinateReferenceSystem targetCRS) throws FactoryException @@@ -276,10 -276,10 +277,10 @@@ //// Derived → any Single CRS //// //// //// //////////////////////////////////////////////////////////////////////////////// - if (sourceCRS instanceof DerivedCRS) { - final var source = (DerivedCRS) sourceCRS; - if (targetCRS instanceof DerivedCRS) { - return createOperationStep(source, (DerivedCRS) targetCRS); + if (sourceCRS instanceof GeneralDerivedCRS) { - final GeneralDerivedCRS source = (GeneralDerivedCRS) sourceCRS; ++ final var source = (GeneralDerivedCRS) sourceCRS; + if (targetCRS instanceof GeneralDerivedCRS) { + return createOperationStep(source, (GeneralDerivedCRS) targetCRS); } if (targetCRS instanceof SingleCRS) { return createOperationStep(source, (SingleCRS) targetCRS); @@@ -290,8 -290,8 +291,8 @@@ //// any Single CRS → Derived //// //// //// //////////////////////////////////////////////////////////////////////////////// - if (targetCRS instanceof DerivedCRS) { - final var target = (DerivedCRS) targetCRS; + if (targetCRS instanceof GeneralDerivedCRS) { - final GeneralDerivedCRS target = (GeneralDerivedCRS) targetCRS; ++ final var target = (GeneralDerivedCRS) targetCRS; if (sourceCRS instanceof SingleCRS) { return createOperationStep((SingleCRS) sourceCRS, target); } @@@ -384,8 -384,8 +385,9 @@@ * @return coordinate operations from {@code sourceCRS} to {@code targetCRS}. * @throws FactoryException if the operation cannot be constructed. */ ++ @SuppressWarnings("deprecation") protected List<CoordinateOperation> createOperationStep(final SingleCRS sourceCRS, - final DerivedCRS targetCRS) + final GeneralDerivedCRS targetCRS) throws FactoryException { final List<CoordinateOperation> operations = createOperations(sourceCRS, targetCRS.getBaseCRS()); @@@ -420,7 -420,7 +422,8 @@@ * @return a coordinate operation from {@code sourceCRS} to {@code targetCRS}. * @throws FactoryException if the operation cannot be constructed. */ - protected List<CoordinateOperation> createOperationStep(final DerivedCRS sourceCRS, ++ @SuppressWarnings("deprecation") + protected List<CoordinateOperation> createOperationStep(final GeneralDerivedCRS sourceCRS, final SingleCRS targetCRS) throws FactoryException { @@@ -462,8 -462,8 +465,9 @@@ * @return a coordinate operation from {@code sourceCRS} to {@code targetCRS}. * @throws FactoryException if the operation cannot be constructed. */ - protected List<CoordinateOperation> createOperationStep(final DerivedCRS sourceCRS, - final DerivedCRS targetCRS) ++ @SuppressWarnings("deprecation") + protected List<CoordinateOperation> createOperationStep(final GeneralDerivedCRS sourceCRS, + final GeneralDerivedCRS targetCRS) throws FactoryException { final List<CoordinateOperation> operations = createOperations(sourceCRS.getBaseCRS(), targetCRS.getBaseCRS()); @@@ -1282,7 -1267,7 +1286,8 @@@ * @param crs the CRS having a conversion that cannot be inverted. * @return a default error message. */ - private String canNotInvert(final DerivedCRS crs) { ++ @SuppressWarnings("deprecation") + private String canNotInvert(final GeneralDerivedCRS crs) { return resources().getString(Resources.Keys.NonInvertibleOperation_1, label(crs.getConversionFromBase())); } } diff --cc endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/operation/DefaultOperationMethod.java index 7f0888f2e8,f8f1f15bf3..cdbff7676c --- 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 @@@ -518,6 -477,6 +518,7 @@@ public class DefaultOperationMethod ext * @see <a href="http://docs.opengeospatial.org/is/12-063r5/12-063r5.html#118">WKT 2 specification §17.2.3</a> */ @Override ++ @SuppressWarnings("deprecation") protected String formatTo(final Formatter formatter) { final boolean isWKT1 = formatter.getConvention().majorVersion() == 1; /* diff --cc endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/operation/SubOperationInfo.java index ee444671b9,25e09effde..965942b1da --- a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/operation/SubOperationInfo.java +++ b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/operation/SubOperationInfo.java @@@ -65,9 -67,9 +65,10 @@@ final class SubOperationInfo * Returns the class of the given CRS after unwrapping derived and projected CRS. * The returned type is for use with {@link #COMPATIBLE_TYPES}. */ ++ @SuppressWarnings("deprecation") private static Class<?> type(SingleCRS crs) { - while (crs instanceof DerivedCRS) { - crs = ((DerivedCRS) crs).getBaseCRS(); + while (crs instanceof GeneralDerivedCRS) { + crs = (SingleCRS) ((GeneralDerivedCRS) crs).getBaseCRS(); } return crs.getClass(); } diff --cc endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/privy/CoordinateOperations.java index 1fe647df12,54f7a3bd52..a384398386 --- a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/privy/CoordinateOperations.java +++ b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/privy/CoordinateOperations.java @@@ -252,10 -252,10 +252,11 @@@ public final class CoordinateOperation * @param target the target of the coordinate operation. * @return target dimensions where "wrap around" may happen, or an empty set if none. */ ++ @SuppressWarnings("deprecation") public static Set<Integer> wrapAroundChanges(CoordinateReferenceSystem source, final CoordinateSystem target) { long changes = changes(source.getCoordinateSystem(), target); - while (source instanceof DerivedCRS) { - source = ((DerivedCRS) source).getBaseCRS(); + while (source instanceof GeneralDerivedCRS) { + source = ((GeneralDerivedCRS) source).getBaseCRS(); changes |= changes(source.getCoordinateSystem(), target); } final boolean useCache = (changes >= 0 && changes < CACHE.length); diff --cc endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/privy/DefinitionVerifier.java index 89a06ea9a7,ca7e25b306..ac388d3aed --- a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/privy/DefinitionVerifier.java +++ b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/privy/DefinitionVerifier.java @@@ -307,6 -307,6 +307,7 @@@ public final class DefinitionVerifier * The returned value is one of {@link #METHOD}, {@link #CONVERSION}, {@link #CS}, {@link #DATUM}, * {@link #PRIME_MERIDIAN} or {@link #OTHER} constants. */ ++ @SuppressWarnings("deprecation") private static int diffCode(final Iterator<SingleCRS> authoritative, final Iterator<SingleCRS> given) { while (authoritative.hasNext() && given.hasNext()) { final SingleCRS crsA = authoritative.next(); diff --cc geoapi/snapshot index 4da2243ded,ada952e12e..10bab8acc3 --- a/geoapi/snapshot +++ b/geoapi/snapshot @@@ -1,1 -1,1 +1,1 @@@ - Subproject commit 4da2243dedd6c1cbd51e811fe937750314fa7e1d -Subproject commit ada952e12e675417e67d13b1a404b62a49b23546 ++Subproject commit 10bab8acc33a58679276befe17b26e89c7b333b8