This is an automated email from the ASF dual-hosted git repository. desruisseaux pushed a commit to branch main in repository https://gitbox.apache.org/repos/asf/sis.git
commit 3403855d4538f69120d0adf2829a8187799de9d2 Merge: 129054c2fa abe39d4ffc Author: Martin Desruisseaux <martin.desruisse...@geomatys.com> AuthorDate: Tue Apr 9 13:22:51 2024 +0200 Merge branch 'geoapi-3.1'. .../sis/buildtools/coding/ReorganizeImports.java | 1 + .../apache/sis/coverage/grid/GridExtentCRS.java | 2 +- .../sis/metadata/iso/extent/DefaultExtent.java | 3 +- .../apache/sis/metadata/iso/extent/Extents.java | 4 ++ .../gazetteer/ModifiableLocationType.java | 2 +- .../gazetteer/ReferencingByIdentifiers.java | 31 +++++-------- .../gazetteer/ReferencingByIdentifiersTest.java | 2 +- .../main/org/apache/sis/io/wkt/ElementKind.java | 50 +++++++++++++-------- .../main/org/apache/sis/referencing/CRS.java | 23 +++------- .../apache/sis/referencing/IdentifiedObjects.java | 51 +++++++++++++++++++++ .../org/apache/sis/referencing/Properties.java | 3 +- .../apache/sis/referencing/crs/AbstractCRS.java | 5 +-- .../sis/referencing/crs/DefaultDerivedCRS.java | 2 +- .../sis/referencing/datum/BursaWolfParameters.java | 3 ++ .../operation/AbstractCoordinateOperation.java | 5 +-- .../operation/AbstractSingleOperation.java | 3 +- .../operation/CoordinateOperationFinder.java | 3 +- .../operation/CoordinateOperationSorter.java | 3 +- .../operation/DefaultConcatenatedOperation.java | 3 +- .../referencing/operation/DefaultConversion.java | 2 +- .../DefaultCoordinateOperationFactory.java | 14 +++--- .../operation/DefaultPassThroughOperation.java | 3 +- .../operation/DefaultTransformation.java | 2 +- .../operation/InverseOperationMethod.java | 6 ++- .../operation/transform/MathTransforms.java | 2 +- .../privy/EllipsoidalHeightCombiner.java | 2 +- .../referencing/privy/NilReferencingObject.java | 22 ++++++--- .../sis/xml/bind/referencing/CS_UserDefinedCS.java | 1 - .../referencing/AbstractReferenceSystemTest.java | 10 +++-- .../sis/referencing/GeodeticObjectVerifier.java | 45 ++++++++++++++----- .../referencing/crs/DefaultGeodeticCRSTest.java | 3 +- .../referencing/crs/DefaultProjectedCRSTest.java | 3 +- .../datum/DefaultGeodeticDatumTest.java | 12 +++-- .../datum/DefaultTemporalDatumTest.java | 15 ++++--- .../datum/DefaultVerticalDatumTest.java | 5 ++- .../sis/referencing/datum/HardCodedDatum.java | 21 +++++++-- .../operation/SingleOperationMarshallingTest.java | 12 ++--- .../sis/test/integration/MetadataVerticalTest.java | 5 ++- .../apache/sis/storage/base/MetadataBuilder.java | 5 ++- .../main/org/apache/sis/util/ComparisonMode.java | 4 +- .../org/apache/sis/util/LenientComparable.java | 3 +- .../test/org/apache/sis/test/TestUtilities.java | 52 ++++++++++++++++++++++ .../org/apache/sis/gui/referencing/CRSChooser.java | 20 +++++---- .../gui/referencing/RecentReferenceSystems.java | 2 +- .../main/org/apache/sis/gui/referencing/Utils.java | 21 +++++---- 45 files changed, 331 insertions(+), 160 deletions(-) diff --cc endorsed/src/org.apache.sis.feature/main/org/apache/sis/coverage/grid/GridExtentCRS.java index e11b6372c8,cacfa9b7fa..ae28430fdb --- a/endorsed/src/org.apache.sis.feature/main/org/apache/sis/coverage/grid/GridExtentCRS.java +++ b/endorsed/src/org.apache.sis.feature/main/org/apache/sis/coverage/grid/GridExtentCRS.java @@@ -178,12 -181,12 +178,12 @@@ final class GridExtentCRS /* * Put everything together: parameters, conversion and finally the derived CRS. */ - final HashMap<String,Object> properties = new HashMap<>(8); + final var properties = new HashMap<String,Object>(8); properties.put(IdentifiedObject.NAME_KEY, METHOD.getName()); properties.put(DefaultConversion.LOCALE_KEY, locale); - properties.put(ObjectDomain.SCOPE_KEY, SCOPE); + properties.put(Conversion.SCOPE_KEY, SCOPE); gg.getGeographicExtent().ifPresent((domain) -> { - properties.put(ObjectDomain.DOMAIN_OF_VALIDITY_KEY, + properties.put(Conversion.DOMAIN_OF_VALIDITY_KEY, new DefaultExtent(null, domain, null, null)); }); final ParameterValueGroup params = METHOD.getParameters().createValue(); diff --cc endorsed/src/org.apache.sis.referencing.gazetteer/main/org/apache/sis/referencing/gazetteer/ReferencingByIdentifiers.java index 7d35fb2f14,0d526a2fd7..b348bd7770 --- a/endorsed/src/org.apache.sis.referencing.gazetteer/main/org/apache/sis/referencing/gazetteer/ReferencingByIdentifiers.java +++ b/endorsed/src/org.apache.sis.referencing.gazetteer/main/org/apache/sis/referencing/gazetteer/ReferencingByIdentifiers.java @@@ -133,21 -120,17 +133,17 @@@ public abstract class ReferencingByIden * <th>Property name</th> * <th>Value type</th> * <th>Returned by</th> - * </tr> - * <tr> + * </tr><tr> - * <td>{@value org.opengis.referencing.gazetteer.ReferenceSystemUsingIdentifiers#THEME_KEY}</td> + * <td>"theme"</td> * <td>{@link String} or {@link InternationalString}</td> * <td>{@link #getTheme()}</td> - * </tr> - * <tr> + * </tr><tr> - * <td>{@value org.opengis.referencing.gazetteer.ReferenceSystemUsingIdentifiers#OVERALL_OWNER_KEY}</td> - * <td>{@link Party}</td> + * <td>"overallOwner"</td> + * <td>{@code Party}</td> * <td>{@link #getOverallOwner()}</td> - * </tr> - * <tr> + * </tr><tr> * <th colspan="3" class="hsep">Defined in parent class (reminder)</th> - * </tr> - * <tr> + * </tr><tr> * <td>{@value org.opengis.referencing.IdentifiedObject#NAME_KEY}</td> * <td>{@link org.opengis.metadata.Identifier} or {@link String}</td> * <td>{@link #getName()}</td> @@@ -166,16 -146,14 +159,14 @@@ * <td>{@value org.opengis.referencing.IdentifiedObject#REMARKS_KEY}</td> * <td>{@link org.opengis.util.InternationalString} or {@link String}</td> * <td>{@link #getRemarks()}</td> - * </tr> - * <tr> + * </tr><tr> - * <td>{@value org.opengis.referencing.ObjectDomain#DOMAIN_OF_VALIDITY_KEY}</td> + * <td>{@value org.opengis.referencing.ReferenceSystem#DOMAIN_OF_VALIDITY_KEY}</td> * <td>{@link org.opengis.metadata.extent.Extent}</td> - * <td>{@link #getDomainOfValidity()}</td> - * </tr> - * <tr> + * <td>{@link org.apache.sis.referencing.DefaultObjectDomain#getDomainOfValidity()}</td> + * </tr><tr> - * <td>{@value org.opengis.referencing.ObjectDomain#SCOPE_KEY}</td> + * <td>{@value org.opengis.referencing.ReferenceSystem#SCOPE_KEY}</td> * <td>{@link org.opengis.util.InternationalString} or {@link String}</td> - * <td>{@link #getScope()}</td> + * <td>{@link org.apache.sis.referencing.DefaultObjectDomain#getScope()}</td> * </tr> * </table> * diff --cc endorsed/src/org.apache.sis.referencing.gazetteer/test/org/apache/sis/referencing/gazetteer/ReferencingByIdentifiersTest.java index 4bbacde137,04e97af060..756f05d2cc --- a/endorsed/src/org.apache.sis.referencing.gazetteer/test/org/apache/sis/referencing/gazetteer/ReferencingByIdentifiersTest.java +++ b/endorsed/src/org.apache.sis.referencing.gazetteer/test/org/apache/sis/referencing/gazetteer/ReferencingByIdentifiersTest.java @@@ -49,9 -52,9 +49,9 @@@ public final class ReferencingByIdentif private static ReferencingByIdentifiers create(final boolean inherit) { final Map<String,Object> properties = new HashMap<>(); assertNull(properties.put(ReferencingByIdentifiers.NAME_KEY, "UK property addressing")); - assertNull(properties.put(ReferencingByIdentifiers.DOMAIN_OF_VALIDITY_KEY, new DefaultExtent("UK", null, null, null))); assertNull(properties.put(ReferencingByIdentifiers.THEME_KEY, "property")); assertNull(properties.put(ReferencingByIdentifiers.OVERALL_OWNER_KEY, new DefaultOrganisation("Office for National Statistics", null, null, null))); - assertNull(properties.put(ObjectDomain.DOMAIN_OF_VALIDITY_KEY, new DefaultExtent("UK", null, null, null))); ++ assertNull(properties.put(ReferencingByIdentifiers.DOMAIN_OF_VALIDITY_KEY, new DefaultExtent("UK", null, null, null))); return new ReferencingByIdentifiers(properties, LocationTypeTest.create(inherit)) { @Override public ReferencingByIdentifiers.Coder createCoder() { throw new UnsupportedOperationException(); diff --cc endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/CRS.java index 644aac07e6,6ffbe5671c..d425ff7add --- 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 @@@ -91,10 -91,13 +91,9 @@@ import org.apache.sis.util.privy.Numeri import org.apache.sis.util.resources.Errors; import org.apache.sis.util.logging.Logging; -// Specific to the geoapi-3.1 and geoapi-4.0 branches: -import org.opengis.geometry.Geometry; -import org.opengis.referencing.ObjectDomain; -import org.opengis.referencing.datum.DynamicReferenceFrame; -import org.opengis.metadata.extent.BoundingPolygon; -import org.opengis.metadata.extent.GeographicExtent; -import org.opengis.coordinate.CoordinateMetadata; +// Specific to the main branch: - import org.apache.sis.referencing.internal.Legacy; +import org.apache.sis.pending.geoapi.referencing.DynamicReferenceFrame; +import org.apache.sis.coordinate.DefaultCoordinateMetadata; /** diff --cc endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/IdentifiedObjects.java index b06543dc03,c8b2c0c321..38b841055f --- a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/IdentifiedObjects.java +++ b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/IdentifiedObjects.java @@@ -53,8 -59,8 +59,9 @@@ import org.apache.sis.referencing.facto import org.apache.sis.referencing.factory.UnavailableFactoryException; import org.apache.sis.referencing.factory.NoSuchAuthorityFactoryException; -// Specific to the geoapi-3.1 and geoapi-4.0 branches: -import org.opengis.referencing.ObjectDomain; +// Specific to the main branch: +import org.opengis.referencing.ReferenceIdentifier; ++import org.apache.sis.referencing.internal.Legacy; /** @@@ -433,6 -439,50 +440,50 @@@ public final class IdentifiedObjects ex return name; } + /** + * Returns the domain of validity of the given object. + * If the object specifies more than one domain of validity, + * then this method computes their intersection (note that this is the opposite of + * {@link #getGeographicBoundingBox(IdentifiedObject)}, which computes the union). + * If there is no intersection, then the returned object implements {@link Emptiable} + * and the {@link Emptiable#isEmpty()} method returns {@code true}. + * + * @param object the object for which to get the domain of validity, or {@code null}. + * @return the domain of validity where the object is valid, or empty if unspecified. + * + * @since 1.5 + */ + public static Optional<Extent> getDomainOfValidity(final IdentifiedObject object) { + Extent domain = null; + if (object != null) { - for (ObjectDomain obj : object.getDomains()) { ++ for (DefaultObjectDomain obj : Legacy.getDomains(object)) { + domain = Extents.intersection(domain, obj.getDomainOfValidity()); + } + } + return Optional.ofNullable(domain); + } + + /** + * Returns the geographic bounding box computed from the domains of the given object. + * If the given object contains more than one domain, then this method computes their union. + * Note that this is the opposite of {@link #getDomainOfValidity(IdentifiedObject)}, + * which computes the intersection. + * + * @param object the object for which to get the domain of validity, or {@code null}. + * @return the geographic area where the object is valid, or empty if unspecified. + * + * @see IdentifiedObject#getDomains() + * @see Extents#getGeographicBoundingBox(Stream) + * + * @since 1.5 + */ + public static Optional<GeographicBoundingBox> getGeographicBoundingBox(final IdentifiedObject object) { + if (object == null) { + return Optional.empty(); + } - return Extents.getGeographicBoundingBox(object.getDomains().stream().map(ObjectDomain::getDomainOfValidity)); ++ return Extents.getGeographicBoundingBox(Legacy.getDomains(object).stream().map(DefaultObjectDomain::getDomainOfValidity)); + } + /** * Looks up a URN, such as {@code "urn:ogc:def:crs:EPSG:9.1:4326"}, of the specified object. * This method searches in all {@linkplain org.apache.sis.referencing.factory.GeodeticAuthorityFactory geodetic diff --cc endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/crs/DefaultDerivedCRS.java index 7b97f75f51,1cc86465d3..2606e972ce --- 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 @@@ -209,9 -211,9 +209,9 @@@ public class DefaultDerivedCRS extends * <td>{@link org.opengis.metadata.Identifier} (optionally as array)</td> * <td>{@code this.getIdentifiers()}</td> * </tr><tr> - * <td>{@value org.opengis.referencing.ObjectDomain#DOMAIN_OF_VALIDITY_KEY}</td> + * <td>{@value org.opengis.referencing.operation.CoordinateOperation#DOMAIN_OF_VALIDITY_KEY}</td> * <td>{@link org.opengis.metadata.extent.Extent}</td> - * <td>{@code conversionFromBase.getDomainOfValidity()}</td> + * <td>{@code domain.getDomainOfValidity()}</td> * </tr> * </table> * diff --cc endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/datum/BursaWolfParameters.java index ed4ff0171f,42a36c2251..848558d6a2 --- 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 @@@ -609,9 -611,10 +611,10 @@@ public class BursaWolfParameters extend * * @see org.apache.sis.metadata.iso.extent.DefaultExtent */ + @OptionalCandidate public Extent getDomainOfValidity() { if (domainOfValidity == null && targetDatum != null) { - return IdentifiedObjects.getDomainOfValidity(targetDatum).orElse(null); + return targetDatum.getDomainOfValidity(); } return domainOfValidity; } diff --cc endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/operation/DefaultConversion.java index b8b3e081d2,0c5331ca99..29a6f003a8 --- a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/operation/DefaultConversion.java +++ b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/operation/DefaultConversion.java @@@ -113,9 -113,9 +113,9 @@@ public class DefaultConversion extends * <td>{@link org.opengis.metadata.Identifier} (optionally as array)</td> * <td>{@link #getIdentifiers()}</td> * </tr><tr> - * <td>{@value org.opengis.referencing.ObjectDomain#DOMAIN_OF_VALIDITY_KEY}</td> + * <td>{@value org.opengis.referencing.operation.CoordinateOperation#DOMAIN_OF_VALIDITY_KEY}</td> * <td>{@link org.opengis.metadata.extent.Extent}</td> - * <td>{@link #getDomainOfValidity()}</td> + * <td>{@link org.apache.sis.referencing.DefaultObjectDomain#getDomainOfValidity()}</td> * </tr> * </table> * diff --cc endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/operation/DefaultCoordinateOperationFactory.java index 2f6d30370f,b4f4c42b55..aa00964495 --- a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/operation/DefaultCoordinateOperationFactory.java +++ b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/operation/DefaultCoordinateOperationFactory.java @@@ -377,9 -390,9 +377,9 @@@ public class DefaultCoordinateOperation * <td>{@link org.opengis.metadata.Identifier} (optionally as array)</td> * <td>{@link DefaultConversion#getIdentifiers()}</td> * </tr><tr> - * <td>{@value org.opengis.referencing.ObjectDomain#DOMAIN_OF_VALIDITY_KEY}</td> + * <td>{@value org.opengis.referencing.operation.CoordinateOperation#DOMAIN_OF_VALIDITY_KEY}</td> * <td>{@link org.opengis.metadata.extent.Extent}</td> - * <td>{@link DefaultConversion#getDomainOfValidity()}</td> + * <td>{@link org.apache.sis.referencing.DefaultObjectDomain#getDomainOfValidity()}</td> * </tr> * </table> * @@@ -467,9 -480,9 +467,9 @@@ next: for (int i=components.size(); - * <td>{@link org.opengis.metadata.Identifier} (optionally as array)</td> * <td>{@link DefaultConversion#getIdentifiers()}</td> * </tr><tr> - * <td>{@value org.opengis.referencing.ObjectDomain#DOMAIN_OF_VALIDITY_KEY}</td> + * <td>{@value org.opengis.referencing.operation.CoordinateOperation#DOMAIN_OF_VALIDITY_KEY}</td> * <td>{@link org.opengis.metadata.extent.Extent}</td> - * <td>{@link DefaultConversion#getDomainOfValidity()}</td> + * <td>{@link org.apache.sis.referencing.DefaultObjectDomain#getDomainOfValidity()}</td> * </tr> * </table> * diff --cc endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/operation/DefaultTransformation.java index e25994c584,d3bdca7358..058f19493d --- a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/operation/DefaultTransformation.java +++ b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/operation/DefaultTransformation.java @@@ -87,9 -87,9 +87,9 @@@ public class DefaultTransformation exte * <td>{@link org.opengis.metadata.quality.PositionalAccuracy} (optionally as array)</td> * <td>{@link #getCoordinateOperationAccuracy()}</td> * </tr><tr> - * <td>{@value org.opengis.referencing.ObjectDomain#DOMAIN_OF_VALIDITY_KEY}</td> + * <td>{@value org.opengis.referencing.operation.CoordinateOperation#DOMAIN_OF_VALIDITY_KEY}</td> * <td>{@link org.opengis.metadata.extent.Extent}</td> - * <td>{@link #getDomainOfValidity()}</td> + * <td>{@link org.apache.sis.referencing.DefaultObjectDomain#getDomainOfValidity()}</td> * </tr> * </table> * diff --cc endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/operation/InverseOperationMethod.java index 967e44a047,2ada34c583..ed43dac223 --- a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/operation/InverseOperationMethod.java +++ b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/operation/InverseOperationMethod.java @@@ -40,6 -40,9 +40,10 @@@ import org.apache.sis.referencing.opera import org.apache.sis.util.Deprecable; import org.apache.sis.util.collection.Containers; -// Specific to the geoapi-3.1 and geoapi-4.0 branches: -import org.opengis.referencing.ObjectDomain; ++// Specific to the main branch: ++import org.apache.sis.referencing.internal.Legacy; ++import org.apache.sis.referencing.DefaultObjectDomain; + /** * Description of the inverse of another method. This class should be used only when no operation is defined @@@ -135,7 -138,7 +139,7 @@@ final class InverseOperationMethod exte * @param target where to store the properties of the inverse operation. */ static void properties(final SingleOperation source, final Map<String,Object> target) { - target.put(SingleOperation.DOMAIN_OF_VALIDITY_KEY, source.getDomainOfValidity()); - target.put(SingleOperation.DOMAINS_KEY, source.getDomains().toArray(ObjectDomain[]::new)); ++ target.put("domains", Legacy.getDomains(source).toArray(DefaultObjectDomain[]::new)); final Collection<PositionalAccuracy> accuracy = source.getCoordinateOperationAccuracy(); if (!Containers.isNullOrEmpty(accuracy)) { target.put(SingleOperation.COORDINATE_OPERATION_ACCURACY_KEY, diff --cc endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/privy/EllipsoidalHeightCombiner.java index 9d0f450bf9,0780da7d33..0f1dbbf49a --- a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/privy/EllipsoidalHeightCombiner.java +++ b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/privy/EllipsoidalHeightCombiner.java @@@ -217,11 -220,13 +217,11 @@@ public final class EllipsoidalHeightCom ArgumentChecks.ensureNonNullElement("components", i, crs); if (i != 0) name.append(" + "); name.append(crs.getName().getCode()); - for (ObjectDomain obj : crs.getDomains()) { - domain = Extents.intersection(domain, obj.getDomainOfValidity()); - } + domain = Extents.intersection(domain, crs.getDomainOfValidity()); } - final Map<String,Object> properties = new HashMap<>(2); + final var properties = new HashMap<String,Object>(4); properties.put(CoordinateReferenceSystem.NAME_KEY, name.toString()); - properties.put(ObjectDomain.DOMAIN_OF_VALIDITY_KEY, domain); + properties.put(CoordinateReferenceSystem.DOMAIN_OF_VALIDITY_KEY, domain); return properties; } } diff --cc endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/privy/NilReferencingObject.java index efc6503e34,6d95249674..51e1ebc998 --- a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/privy/NilReferencingObject.java +++ b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/privy/NilReferencingObject.java @@@ -74,26 -67,20 +74,36 @@@ public final class NilReferencingObjec return NilReason.TEMPLATE; } - /* - * Simple properties. Not all of them are optional, but SIS is tolerant to null values. - * Returning null for collection are okay in the particular case of SIS implementation, - * because the constructor will replace empty collections by null references anyway. + /** + * Returns the localized "unnamed" name because this property is mandatory. */ - @Override public ReferenceIdentifier getName() {return UNNAMED;} + @Override + public ReferenceIdentifier getName() { + return UNNAMED; + } + + /** + * For avoiding ambiguity. + */ + @Override + @Deprecated + public InternationalString getScope() { + return null; + } ++ + @Override public Collection<GenericName> getAlias() {return null;} + @Override public Set<ReferenceIdentifier> getIdentifiers() {return null;} + @Override public InternationalString getRemarks() {return null;} - @Override public InternationalString getScope() {return null;} + @Override public Extent getDomainOfValidity() {return null;} + + /** + * Throws the exception in all cases. + * + * @return never return. + * @throws UnformattableObjectException always thrown. + */ + @Override + public String toWKT() throws UnformattableObjectException { + throw new UnformattableObjectException(); + } } diff --cc endorsed/src/org.apache.sis.referencing/main/org/apache/sis/xml/bind/referencing/CS_UserDefinedCS.java index c1022ef664,c1022ef664..9312025284 --- a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/xml/bind/referencing/CS_UserDefinedCS.java +++ b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/xml/bind/referencing/CS_UserDefinedCS.java @@@ -30,7 -30,7 +30,6 @@@ import org.opengis.referencing.cs.UserD * * @author Martin Desruisseaux (Geomatys) */ --@SuppressWarnings("deprecation") public final class CS_UserDefinedCS extends PropertyType<CS_UserDefinedCS, UserDefinedCS> { /** * Empty constructor for JAXB only. diff --cc endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/AbstractReferenceSystemTest.java index b4814290ef,5314c05016..7b40839761 --- a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/AbstractReferenceSystemTest.java +++ b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/AbstractReferenceSystemTest.java @@@ -19,7 -19,7 +19,8 @@@ package org.apache.sis.referencing import java.util.Map; import java.util.HashMap; import java.util.Locale; + import org.opengis.util.InternationalString; +import static org.opengis.referencing.ReferenceSystem.*; import org.apache.sis.io.wkt.Convention; import org.apache.sis.metadata.iso.citation.Citations; import org.apache.sis.metadata.iso.extent.DefaultExtent; diff --cc endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/GeodeticObjectVerifier.java index 63c6dfb55a,d5a6fc3dd1..7b726e2c70 --- a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/GeodeticObjectVerifier.java +++ b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/GeodeticObjectVerifier.java @@@ -20,6 -20,6 +20,7 @@@ import org.opengis.metadata.Identifier import org.opengis.metadata.extent.Extent; import org.opengis.metadata.extent.GeographicExtent; import org.opengis.metadata.extent.GeographicBoundingBox; ++import org.opengis.referencing.IdentifiedObject; import org.opengis.referencing.datum.Ellipsoid; import org.opengis.referencing.datum.PrimeMeridian; import org.opengis.referencing.datum.GeodeticDatum; @@@ -34,6 -34,10 +35,11 @@@ import org.opengis.referencing.crs.Geod import org.apache.sis.metadata.privy.AxisNames; import org.apache.sis.measure.Units; -// Specific to the geoapi-3.1 and geoapi-4.0 branches: -import org.opengis.referencing.ObjectDomain; -import org.opengis.referencing.IdentifiedObject; ++// Specific to the main branch: ++import org.opengis.referencing.datum.Datum; ++import org.opengis.referencing.ReferenceSystem; ++import org.opengis.referencing.operation.CoordinateOperation; + // Test dependencies import static org.junit.jupiter.api.Assertions.*; @@@ -54,8 -58,21 +60,27 @@@ public final class GeodeticObjectVerifi } /** - * Asserts that all {@link GeographicBoundingBox}, if any, - * {@linkplain #assertIsWorld(GeographicBoundingBox) encompasses the world}. + * Asserts that the first geographic bounding box, if any, encompasses the world. + * + * @param object the object to verify, or {@code null} if none. + * @param isMandatory {@code true} if an absence of world extent is a failure. + */ + private static void assertIsWorld(final IdentifiedObject object, boolean isMandatory) { - for (ObjectDomain domain : object.getDomains()) { - assertIsWorld(domain.getDomainOfValidity(), isMandatory); - isMandatory = false; ++ final Extent extent; ++ if (object instanceof ReferenceSystem) { ++ extent = ((ReferenceSystem) object).getDomainOfValidity(); ++ } else if (object instanceof Datum) { ++ extent = ((Datum) object).getDomainOfValidity(); ++ } else if (object instanceof CoordinateOperation) { ++ extent = ((CoordinateOperation) object).getDomainOfValidity(); ++ } else { ++ extent = null; + } - assertFalse(isMandatory, "Expected a world extent element."); ++ assertIsWorld(extent, isMandatory); + } + + /** + * Asserts that the first geographic bounding box, if any, encompasses the world. * * <p><b>Note:</b> a future version of this method may accept other kinds of extent, * for example a polygon encompassing the world.</p> diff --cc endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/datum/DefaultTemporalDatumTest.java index 13c935f3cb,887c1f8870..d7fabb12d4 --- a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/datum/DefaultTemporalDatumTest.java +++ b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/datum/DefaultTemporalDatumTest.java @@@ -32,9 -31,12 +31,11 @@@ import org.apache.sis.xml.test.TestCase import org.apache.sis.metadata.iso.citation.HardCodedCitations; import static org.apache.sis.referencing.Assertions.assertWktEquals; import static org.apache.sis.test.TestUtilities.getSingleton; + import static org.apache.sis.test.TestUtilities.getScope; -// Specific to the geoapi-3.1 and geoapi-4.0 branches: -import static org.opengis.referencing.ObjectDomain.*; -import static org.opengis.referencing.IdentifiedObject.*; -import static org.opengis.test.Assertions.assertIdentifierEquals; +// Specific to the main branch: ++import static org.opengis.referencing.ReferenceSystem.*; +import static org.apache.sis.test.GeoapiAssert.assertIdentifierEquals; /** diff --cc endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/SingleOperationMarshallingTest.java index b680ce4011,9ced366669..1cc9107bea --- a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/SingleOperationMarshallingTest.java +++ b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/SingleOperationMarshallingTest.java @@@ -47,11 -47,13 +47,13 @@@ import org.opengis.test.Validators import org.apache.sis.xml.bind.referencing.CC_OperationParameterGroupTest; import org.apache.sis.xml.test.TestCase; import static org.apache.sis.test.TestUtilities.getSingleton; + import static org.apache.sis.test.TestUtilities.getScope; + import static org.apache.sis.test.TestUtilities.getDomainOfValidity; import static org.apache.sis.metadata.Assertions.assertXmlEquals; -// Specific to the geoapi-3.1 and geoapi-4.0 branches: -import static org.opengis.test.Assertions.assertIdentifierEquals; -import static org.opengis.test.Assertions.assertMatrixEquals; +// Specific to the main branch: +import static org.apache.sis.test.GeoapiAssert.assertIdentifierEquals; +import static org.apache.sis.test.GeoapiAssert.assertMatrixEquals; /** diff --cc endorsed/src/org.apache.sis.referencing/test/org/apache/sis/test/integration/MetadataVerticalTest.java index 67408e5c26,57d29028b3..8cb6ee88d1 --- a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/test/integration/MetadataVerticalTest.java +++ b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/test/integration/MetadataVerticalTest.java @@@ -44,11 -44,12 +44,12 @@@ import org.apache.sis.xml.NilReason import org.junit.jupiter.api.Test; import static org.junit.jupiter.api.Assertions.*; import org.apache.sis.xml.test.TestCase; + import static org.apache.sis.test.TestUtilities.getScope; import static org.apache.sis.test.TestUtilities.getSingleton; -// Specific to the geoapi-3.1 and geoapi-4.0 branches: -import java.nio.charset.StandardCharsets; -import static org.opengis.test.Assertions.assertIdentifierEquals; +// Specific to the main branch: +import org.opengis.metadata.identification.CharacterSet; +import static org.apache.sis.test.GeoapiAssert.assertIdentifierEquals; /** diff --cc endorsed/src/org.apache.sis.util/test/org/apache/sis/test/TestUtilities.java index 9a75478ef5,d8e2de7ce1..75faeb8601 --- a/endorsed/src/org.apache.sis.util/test/org/apache/sis/test/TestUtilities.java +++ b/endorsed/src/org.apache.sis.util/test/org/apache/sis/test/TestUtilities.java @@@ -36,6 -36,10 +36,9 @@@ import java.text.Format import java.text.DateFormat; import java.text.ParseException; import java.text.SimpleDateFormat; + import org.opengis.util.InternationalString; + import org.opengis.referencing.IdentifiedObject; -import org.opengis.metadata.extent.GeographicExtent; + import org.opengis.metadata.extent.GeographicBoundingBox; import org.apache.sis.util.Debug; import org.apache.sis.util.Static; import org.apache.sis.util.CharSequences; @@@ -46,6 -50,9 +49,12 @@@ import org.apache.sis.util.collection.T import org.apache.sis.util.privy.X364; import static org.apache.sis.util.privy.StandardDateFormat.UTC; -// Specific to the geoapi-3.1 and geoapi-4.0 branches: -import org.opengis.referencing.ObjectDomain; ++// Specific to the main branch: ++import org.opengis.metadata.extent.Extent; ++import org.opengis.referencing.datum.Datum; ++import org.opengis.referencing.ReferenceSystem; ++import org.opengis.referencing.operation.CoordinateOperation; + // Test dependencies import static org.junit.jupiter.api.Assertions.*; @@@ -351,6 -358,31 +360,49 @@@ public final class TestUtilities extend return element; } + /** + * Returns the scope of the given object. Exactly one scope shall exist. + * + * @param object the object for which to get the scope. + * @return the single scope of the given object. + */ + public static String getScope(final IdentifiedObject object) { - InternationalString scope = getSingleton(object.getDomains()).getScope(); ++ final InternationalString scope; ++ if (object instanceof ReferenceSystem) { ++ scope = ((ReferenceSystem) object).getScope(); ++ } else if (object instanceof Datum) { ++ scope = ((Datum) object).getScope(); ++ } else if (object instanceof CoordinateOperation) { ++ scope = ((CoordinateOperation) object).getScope(); ++ } else { ++ scope = null; ++ } + assertNotNull(scope, "Missing scope."); + return scope.toString(); + } + + /** + * Returns the domain of validity of the given object. Exactly one domain shall exist, + * and that domain shall be a geographic bounding box. + * + * @param object the object for which to get the domain of validity. + * @return the single domain of validity of the given object. + */ + public static GeographicBoundingBox getDomainOfValidity(final IdentifiedObject object) { - ObjectDomain domain = getSingleton(object.getDomains()); - GeographicExtent extent = getSingleton(domain.getDomainOfValidity().getGeographicElements()); - return assertInstanceOf(GeographicBoundingBox.class, extent); ++ final Extent extent; ++ if (object instanceof ReferenceSystem) { ++ extent = ((ReferenceSystem) object).getDomainOfValidity(); ++ } else if (object instanceof Datum) { ++ extent = ((Datum) object).getDomainOfValidity(); ++ } else if (object instanceof CoordinateOperation) { ++ extent = ((CoordinateOperation) object).getDomainOfValidity(); ++ } else { ++ extent = null; ++ } ++ assertNotNull(extent, "Missing extent."); ++ return assertInstanceOf(GeographicBoundingBox.class, getSingleton(extent.getGeographicElements())); + } + /** * Returns a copy of the given array with the last coordinate values dropped for each coordinates. * diff --cc optional/src/org.apache.sis.gui/main/org/apache/sis/gui/referencing/CRSChooser.java index 64ba82974f,313f1ac979..3a85d0c22c --- 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 @@@ -345,13 -347,17 +344,16 @@@ public class CRSChooser extends Dialog< /** * Sets the text that describes the domain of validity. */ - private void setDomainOfValidity(final Extent domainOfValidity, final Locale locale) { - String text = Extents.getDescription(domainOfValidity, locale); - String tip = text; + private void setDomainOfValidity(final CoordinateReferenceSystem crs, final Locale locale) { + String extent = null; - for (ObjectDomain c : crs.getDomains()) { - extent = Extents.getDescription(c.getDomainOfValidity(), locale); - if (extent != null) break; ++ if (crs != null) { ++ extent = Extents.getDescription(crs.getDomainOfValidity(), locale); + } + String tip = extent; Color color = Styles.NORMAL_TEXT; - if (!Utils.intersects(areaOfInterest, domainOfValidity)) { + if (!Utils.intersects(areaOfInterest, crs)) { tip = Resources.forLocale(locale).getString(Resources.Keys.DoesNotCoverAOI); - text = Styles.WARNING_ICON + " " + (text != null ? text : tip); + extent = Styles.WARNING_ICON + " " + (extent != null ? extent : tip); color = Styles.ERROR_TEXT; } domain.setTextFill(color); diff --cc optional/src/org.apache.sis.gui/main/org/apache/sis/gui/referencing/Utils.java index 41d5c19be6,ecf7ceaf8e..f11cc31dbf --- a/optional/src/org.apache.sis.gui/main/org/apache/sis/gui/referencing/Utils.java +++ b/optional/src/org.apache.sis.gui/main/org/apache/sis/gui/referencing/Utils.java @@@ -81,14 -83,20 +80,20 @@@ final class Utils * The reason for returning {@code true} is because it will usually result in no action from the caller, * while {@code false} results in warning emitted or CRS filtered out. */ - static boolean intersects(final ImmutableEnvelope areaOfInterest, final Extent domainOfValidity) { + static boolean intersects(final ImmutableEnvelope areaOfInterest, final ReferenceSystem crs) { + boolean conservative = true; if (areaOfInterest != null) { - final GeographicBoundingBox bbox = Extents.getGeographicBoundingBox(domainOfValidity); - if (bbox != null) { - return areaOfInterest.intersects(new ImmutableEnvelope(bbox)); - for (final ObjectDomain domain : crs.getDomains()) { - final GeographicBoundingBox bbox = Extents.getGeographicBoundingBox(domain.getDomainOfValidity()); ++ if (crs != null) { ++ final GeographicBoundingBox bbox = Extents.getGeographicBoundingBox(crs.getDomainOfValidity()); + if (bbox != null) { + if (areaOfInterest.intersects(new ImmutableEnvelope(bbox))) { + return true; + } + conservative = false; + } } } - return true; + return conservative; } /**