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
commit 4ec3a9b1038e9c64251abd185feb9239416de514 Author: Martin Desruisseaux <martin.desruisse...@geomatys.com> AuthorDate: Thu Apr 4 16:34:16 2024 +0200 Resolve a few warnings (not all) about the deprecated `VerticalDatumType` code list. --- .../apache/sis/metadata/iso/extent/Extents.java | 1 + .../org/apache/sis/test/mock/VerticalCRSMock.java | 49 ++++++++----- .../main/org/apache/sis/io/wkt/VerticalInfo.java | 10 +-- .../sis/referencing/StandardDefinitions.java | 6 +- .../referencing/datum/DefaultVerticalDatum.java | 75 ++++++++++++++++++-- .../referencing/factory/GeodeticObjectFactory.java | 3 + .../xml/bind/referencing/CD_VerticalDatumType.java | 1 + .../test/org/apache/sis/io/wkt/WKTParserTest.java | 6 +- .../org/apache/sis/referencing/CommonCRSTest.java | 1 + .../datum/DefaultVerticalDatumTest.java | 1 + .../sis/referencing/datum/HardCodedDatum.java | 2 + .../report/CoordinateReferenceSystems.java | 9 ++- .../apache/sis/test/integration/MetadataTest.java | 80 +++++++++++----------- .../sis/test/integration/MetadataVerticalTest.java | 6 +- 14 files changed, 176 insertions(+), 74 deletions(-) diff --git a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/iso/extent/Extents.java b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/iso/extent/Extents.java index a3cb0d5f00..18e7e5e0f2 100644 --- a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/iso/extent/Extents.java +++ b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/iso/extent/Extents.java @@ -416,6 +416,7 @@ public final class Extents extends Static { * @since 0.4 */ @OptionalCandidate + @SuppressWarnings("deprecation") public static MeasurementRange<Double> getVerticalRange(final Extent extent) { MeasurementRange<Double> range = null; VerticalDatumType selectedType = null; diff --git a/endorsed/src/org.apache.sis.metadata/test/org/apache/sis/test/mock/VerticalCRSMock.java b/endorsed/src/org.apache.sis.metadata/test/org/apache/sis/test/mock/VerticalCRSMock.java index 6c3dcb1d61..aecb15b43e 100644 --- a/endorsed/src/org.apache.sis.metadata/test/org/apache/sis/test/mock/VerticalCRSMock.java +++ b/endorsed/src/org.apache.sis.metadata/test/org/apache/sis/test/mock/VerticalCRSMock.java @@ -16,6 +16,7 @@ */ package org.apache.sis.test.mock; +import java.util.Optional; import javax.measure.Unit; import org.opengis.metadata.extent.Extent; import org.opengis.referencing.crs.VerticalCRS; @@ -28,6 +29,9 @@ import org.opengis.referencing.datum.VerticalDatumType; import org.opengis.util.InternationalString; import org.apache.sis.measure.Units; +// Specific to the geoapi-3.1 and geoapi-4.0 branches: +import org.opengis.referencing.datum.RealizationMethod; + /** * A dummy implementation of {@link VerticalCRS}, which is also its own datum, coordinate system and axis. @@ -42,32 +46,42 @@ public final class VerticalCRSMock extends IdentifiedObjectMock * Height in metres. */ public static final VerticalCRS HEIGHT = new VerticalCRSMock("Height", + RealizationMethod.GEOID, VerticalDatumType.GEOIDAL, Double.NEGATIVE_INFINITY, Double.POSITIVE_INFINITY, Units.METRE, true); /** * Height in feet. */ public static final VerticalCRS HEIGHT_ft = new VerticalCRSMock("Height", + RealizationMethod.GEOID, VerticalDatumType.GEOIDAL, Double.NEGATIVE_INFINITY, Double.POSITIVE_INFINITY, Units.FOOT, true); /** * Height estimated from hPa. */ public static final VerticalCRS BAROMETRIC_HEIGHT = new VerticalCRSMock("Barometric height", + RealizationMethod.LEVELLING, VerticalDatumType.BAROMETRIC, 0, Double.POSITIVE_INFINITY, Units.HECTOPASCAL, true); /** * Depth in metres. */ public static final VerticalCRS DEPTH = new VerticalCRSMock("Depth", + RealizationMethod.TIDAL, VerticalDatumType.DEPTH, 0, Double.POSITIVE_INFINITY, Units.METRE, false); /** * Depth as a fraction of the sea floor depth at the location of the point for which the depth is evaluated. */ public static final VerticalCRS SIGMA_LEVEL = new VerticalCRSMock("Sigma level", + null, VerticalDatumType.OTHER_SURFACE, 0, 1, Units.UNITY, false); + /** + * The realization method (geoid, tidal, <i>etc.</i>), or {@code null} if unspecified. + */ + private final RealizationMethod method; + /** * The datum type (geoidal, barometric, etc.). */ @@ -92,16 +106,18 @@ public final class VerticalCRSMock extends IdentifiedObjectMock * Creates a new vertical CRS for the given name. * * @param name the CRS, CS, datum and axis name. - * @param up {@code true} if the axis direction is up, or {@code false} if down. - * @param unit the unit of measurement. + * @param method the realization method (geoid, tidal, <i>etc.</i>). * @param minimumValue the minium value. * @param maximumValue the maximum value. + * @param unit the unit of measurement. + * @param up {@code true} if the axis direction is up, or {@code false} if down. */ - private VerticalCRSMock(final String name, VerticalDatumType type, + private VerticalCRSMock(final String name, final RealizationMethod method, VerticalDatumType type, final double minimumValue, final double maximumValue, final Unit<?> unit, final boolean up) { super(name); this.type = type; + this.method = method; this.minimumValue = minimumValue; this.maximumValue = maximumValue; this.unit = unit; @@ -116,17 +132,18 @@ public final class VerticalCRSMock extends IdentifiedObjectMock return new Object[] {getCode(), alias, minimumValue, maximumValue, unit, up}; } - @Override public String getAbbreviation() {return up ? "h" : "d";} - @Override public InternationalString getScope() {return null;} - @Override public Extent getDomainOfValidity() {return null;} - @Override public VerticalDatumType getVerticalDatumType() {return type;} - @Override public VerticalDatum getDatum() {return this;} - @Override public VerticalCS getCoordinateSystem() {return this;} - @Override public int getDimension() {return 1;} - @Override public CoordinateSystemAxis getAxis(int dimension) {return this;} - @Override public AxisDirection getDirection() {return up ? AxisDirection.UP : AxisDirection.DOWN;} - @Override public double getMinimumValue() {return minimumValue;} - @Override public double getMaximumValue() {return maximumValue;} - @Override public RangeMeaning getRangeMeaning() {return RangeMeaning.EXACT;} - @Override public Unit<?> getUnit() {return unit;} + @Override public String getAbbreviation() {return up ? "h" : "d";} + @Override public InternationalString getScope() {return null;} + @Override public Extent getDomainOfValidity() {return null;} + @Override public Optional<RealizationMethod> getRealizationMethod() {return Optional.ofNullable(method);} + @Override public VerticalDatumType getVerticalDatumType() {return type;} + @Override public VerticalDatum getDatum() {return this;} + @Override public VerticalCS getCoordinateSystem() {return this;} + @Override public int getDimension() {return 1;} + @Override public CoordinateSystemAxis getAxis(int dimension) {return this;} + @Override public AxisDirection getDirection() {return up ? AxisDirection.UP : AxisDirection.DOWN;} + @Override public double getMinimumValue() {return minimumValue;} + @Override public double getMaximumValue() {return maximumValue;} + @Override public RangeMeaning getRangeMeaning() {return RangeMeaning.EXACT;} + @Override public Unit<?> getUnit() {return unit;} } diff --git a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/io/wkt/VerticalInfo.java b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/io/wkt/VerticalInfo.java index 91564453bf..37275e7cc3 100644 --- a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/io/wkt/VerticalInfo.java +++ b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/io/wkt/VerticalInfo.java @@ -27,11 +27,13 @@ import org.opengis.referencing.cs.CSFactory; import org.opengis.referencing.cs.VerticalCS; import org.opengis.referencing.crs.CRSFactory; import org.opengis.referencing.crs.VerticalCRS; -import org.opengis.referencing.datum.VerticalDatumType; import org.apache.sis.metadata.privy.AxisNames; import org.apache.sis.metadata.iso.extent.DefaultExtent; import org.apache.sis.metadata.iso.extent.DefaultVerticalExtent; +// Specific to the geoapi-3.1 and geoapi-4.0 branches: +import org.opengis.referencing.datum.RealizationMethod; + /** * Stores temporary information needed for completing the construction of an {@link DefaultVerticalExtent} instance. @@ -94,7 +96,7 @@ final class VerticalInfo { * This method invokes {@link DefaultVerticalExtent#setVerticalCRS(VerticalCRS)} with the given CRS if: * * <ul> - * <li>datum type is {@link VerticalDatumType#GEOIDAL},</li> + * <li>realization method is {@link RealizationMethod#GEOID},</li> * <li>increasing height values are up, and</li> * <li>axis unit of measurement is the given linear unit.</li> * </ul> @@ -105,7 +107,7 @@ final class VerticalInfo { * became empty as a result of this operation. */ final VerticalInfo resolve(final VerticalCRS crs) { - if (crs != null && crs.getDatum().getVerticalDatumType() == VerticalDatumType.GEOIDAL) { + if (crs != null && crs.getDatum().getRealizationMethod().orElse(null) == RealizationMethod.GEOID) { return resolve(crs, crs.getCoordinateSystem().getAxis(0)); } return this; @@ -134,7 +136,7 @@ final class VerticalInfo { * The CRS created by this method is implementation-dependent. The only guarantees are: * * <ul> - * <li>datum type is {@link VerticalDatumType#GEOIDAL},</li> + * <li>realization method is {@link RealizationMethod#GEOID},</li> * <li>increasing height values are up, and</li> * <li>axis unit of measurement is the given linear unit.</li> * </ul> diff --git a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/StandardDefinitions.java b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/StandardDefinitions.java index 779d64e4fc..c566cef765 100644 --- a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/StandardDefinitions.java +++ b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/StandardDefinitions.java @@ -28,7 +28,6 @@ import org.opengis.referencing.datum.Ellipsoid; import org.opengis.referencing.datum.PrimeMeridian; import org.opengis.referencing.datum.GeodeticDatum; import org.opengis.referencing.datum.VerticalDatum; -import org.opengis.referencing.datum.VerticalDatumType; import org.opengis.referencing.cs.RangeMeaning; import org.opengis.referencing.cs.AxisDirection; import org.opengis.referencing.cs.CoordinateSystem; @@ -75,6 +74,9 @@ import org.apache.sis.measure.Latitude; import org.apache.sis.measure.Units; import static org.apache.sis.metadata.privy.ReferencingServices.AUTHALIC_RADIUS; +// Specific to the geoapi-3.1 and geoapi-4.0 branches: +import org.opengis.referencing.datum.RealizationMethod; + /** * Definitions of referencing objects identified by the {@link CommonCRS} enumeration values. @@ -346,7 +348,7 @@ final class StandardDefinitions { case 5103: name = "North American Vertical Datum 1988"; alias = "NAVD88"; break; default: throw new AssertionError(code); } - return new DefaultVerticalDatum(properties(code, name, alias, true), VerticalDatumType.GEOIDAL); + return new DefaultVerticalDatum(properties(code, name, alias, true), RealizationMethod.GEOID); } /** diff --git a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/datum/DefaultVerticalDatum.java b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/datum/DefaultVerticalDatum.java index 2668d245f5..5405bca909 100644 --- a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/datum/DefaultVerticalDatum.java +++ b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/datum/DefaultVerticalDatum.java @@ -18,6 +18,7 @@ package org.apache.sis.referencing.datum; import java.util.Map; import java.util.Objects; +import java.util.Optional; import jakarta.xml.bind.annotation.XmlType; import jakarta.xml.bind.annotation.XmlElement; import jakarta.xml.bind.annotation.XmlRootElement; @@ -35,6 +36,7 @@ import org.apache.sis.metadata.privy.ImplementationHelper; // Specific to the geoapi-3.1 and geoapi-4.0 branches: import org.opengis.metadata.Identifier; +import org.opengis.referencing.datum.RealizationMethod; /** @@ -72,7 +74,7 @@ import org.opengis.metadata.Identifier; * all components were created using only SIS factories and static constants. * * @author Martin Desruisseaux (IRD, Geomatys) - * @version 1.4 + * @version 1.5 * * @see org.apache.sis.referencing.CommonCRS.Vertical#datum() * @see org.apache.sis.referencing.cs.DefaultVerticalCS @@ -89,6 +91,11 @@ public class DefaultVerticalDatum extends AbstractDatum implements VerticalDatum */ private static final long serialVersionUID = 380347456670516572L; + /** + * The realization method (geoid, tidal, <i>etc.</i>), or {@code null} if unspecified. + */ + private RealizationMethod method; + /** * The type of this vertical datum. * If {@code null}, a value will be inferred from the name by {@link #type()}. @@ -96,6 +103,7 @@ public class DefaultVerticalDatum extends AbstractDatum implements VerticalDatum * @see #type() * @see #getVerticalDatumType() */ + @SuppressWarnings("deprecation") private VerticalDatumType type; /** @@ -141,13 +149,30 @@ public class DefaultVerticalDatum extends AbstractDatum implements VerticalDatum * </table> * * @param properties the properties to be given to the identified object. + * @param method the realization method (geoid, tidal, <i>etc.</i>), or {@code null} if unspecified. + * + * @since 2.0 + */ + @SuppressWarnings({"deprecation", "this-escape"}) + public DefaultVerticalDatum(final Map<String,?> properties, final RealizationMethod method) { + super(properties); + this.method = method; + type = VerticalDatum.super.getVerticalDatumType(); + } + + /** + * Creates a vertical datum from the given properties. + * + * @param properties the properties to be given to the identified object. * @param type the type of this vertical datum. * - * @see org.apache.sis.referencing.factory.GeodeticObjectFactory#createVerticalDatum(Map, VerticalDatumType) + * @deprecated As of ISO 19111:2019, the {@code VerticalDatumType} argument is replaced by {@code RealizationMethod}. */ + @Deprecated(since = "2.0") public DefaultVerticalDatum(final Map<String,?> properties, final VerticalDatumType type) { super(properties); this.type = Objects.requireNonNull(type); + setRealizationMethod(); } /** @@ -161,9 +186,13 @@ public class DefaultVerticalDatum extends AbstractDatum implements VerticalDatum * * @see #castOrCopy(VerticalDatum) */ + @SuppressWarnings("deprecation") protected DefaultVerticalDatum(final VerticalDatum datum) { super(datum); type = datum.getVerticalDatumType(); + if (datum instanceof DefaultVerticalDatum) { + method = ((DefaultVerticalDatum) datum).method; + } } /** @@ -197,6 +226,31 @@ public class DefaultVerticalDatum extends AbstractDatum implements VerticalDatum return VerticalDatum.class; } + /** + * Returns the method through which this vertical reference frame is realized. + * + * @return method through which this vertical reference frame is realized. + * @since 1.5 + */ + @Override + public Optional<RealizationMethod> getRealizationMethod() { + return Optional.ofNullable(method); + } + + /** + * Sets the realization method to a default value inferred from the legacy datum type. + */ + @SuppressWarnings("deprecation") + private void setRealizationMethod() { + if (type == VerticalDatumType.GEOIDAL) { + method = RealizationMethod.GEOID; + } else if (type == VerticalDatumType.DEPTH) { + method = RealizationMethod.TIDAL; + } else if (type == VerticalDatumType.BAROMETRIC) { + method = RealizationMethod.LEVELLING; + } + } + /** * Returns the type of this datum, or infers the type from the datum name if no type were specified. * The latter case occurs after unmarshalling, since GML 3.2 does not contain any attribute for the datum type. @@ -211,6 +265,7 @@ public class DefaultVerticalDatum extends AbstractDatum implements VerticalDatum * @see #getVerticalDatumType() * @see #getTypeElement() */ + @SuppressWarnings("deprecation") private VerticalDatumType type() { VerticalDatumType t = type; if (t == null) { @@ -230,8 +285,11 @@ public class DefaultVerticalDatum extends AbstractDatum implements VerticalDatum * but in a programmatic way more suitable to coordinate transformation engines. * * @return the type of this vertical datum. + * + * @deprecated As of ISO 19111:2019, the {@code VerticalDatumType} argument is replaced by {@code RealizationMethod}. */ @Override + @Deprecated(since = "2.0") public VerticalDatumType getVerticalDatumType() { return type(); } @@ -246,6 +304,7 @@ public class DefaultVerticalDatum extends AbstractDatum implements VerticalDatum * @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. @@ -255,10 +314,13 @@ public class DefaultVerticalDatum extends AbstractDatum implements VerticalDatum } switch (mode) { case STRICT: { - return type().equals(((DefaultVerticalDatum) object).type()); + final var other = (DefaultVerticalDatum) object; + return Objects.equals(method, other.method) && type().equals(other.type()); } case BY_CONTRACT: { - return Objects.equals(getVerticalDatumType(), ((VerticalDatum) object).getVerticalDatumType()); + final var other = (VerticalDatum) object; + return Objects.equals(getRealizationMethod(), other.getRealizationMethod()) && + Objects.equals(getVerticalDatumType(), other.getVerticalDatumType()); } default: { /* @@ -281,7 +343,7 @@ public class DefaultVerticalDatum extends AbstractDatum implements VerticalDatum */ @Override protected long computeHashCode() { - return super.computeHashCode() + type().hashCode(); + return super.computeHashCode() + type().hashCode() + 37 * Objects.hashCode(method); } /** @@ -337,6 +399,7 @@ public class DefaultVerticalDatum extends AbstractDatum implements VerticalDatum * * @see <a href="http://issues.apache.org/jira/browse/SIS-160">SIS-160: Need XSLT between GML 3.1 and 3.2</a> */ + @SuppressWarnings("deprecation") @XmlElement(name = "verticalDatumType") private VerticalDatumType getTypeElement() { return Context.isGMLVersion(Context.current(), LegacyNamespaces.VERSION_3_2) ? null : getVerticalDatumType(); @@ -345,9 +408,11 @@ public class DefaultVerticalDatum extends AbstractDatum implements VerticalDatum /** * Invoked by JAXB only. The vertical datum type is set only if it has not already been specified. */ + @SuppressWarnings("deprecation") private void setTypeElement(final VerticalDatumType t) { if (type == null) { type = t; + setRealizationMethod(); } else { ImplementationHelper.propertyAlreadySet(DefaultVerticalDatum.class, "setTypeElement", "verticalDatumType"); } 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 c6593b2102..2778ac1f24 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 @@ -939,8 +939,11 @@ public class GeodeticObjectFactory extends AbstractFactory implements CRSFactory * * @see DefaultVerticalDatum#DefaultVerticalDatum(Map, VerticalDatumType) * @see GeodeticAuthorityFactory#createVerticalDatum(String) + * + * @deprecated As of ISO 19111:2019, the {@code VerticalDatumType} argument is replaced by {@code RealizationMethod}. */ @Override + @Deprecated(since = "2.0") public VerticalDatum createVerticalDatum(final Map<String,?> properties, final VerticalDatumType type) throws FactoryException { diff --git a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/xml/bind/referencing/CD_VerticalDatumType.java b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/xml/bind/referencing/CD_VerticalDatumType.java index 619e4f5620..a6eeffe0b8 100644 --- a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/xml/bind/referencing/CD_VerticalDatumType.java +++ b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/xml/bind/referencing/CD_VerticalDatumType.java @@ -25,6 +25,7 @@ import org.apache.sis.xml.bind.gml.CodeListAdapter; * * @author Martin Desruisseaux (Geomatys) */ +@SuppressWarnings("deprecation") public final class CD_VerticalDatumType extends CodeListAdapter<VerticalDatumType> { /** * Empty constructor for JAXB only. diff --git a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/io/wkt/WKTParserTest.java b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/io/wkt/WKTParserTest.java index 518128e48e..a49e94a3c5 100644 --- a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/io/wkt/WKTParserTest.java +++ b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/io/wkt/WKTParserTest.java @@ -18,7 +18,6 @@ package org.apache.sis.io.wkt; import org.opengis.referencing.cs.CoordinateSystem; import org.opengis.referencing.crs.VerticalCRS; -import org.opengis.referencing.datum.VerticalDatumType; import org.opengis.util.FactoryException; import org.apache.sis.metadata.privy.AxisNames; import org.apache.sis.referencing.factory.GeodeticObjectFactory; @@ -34,6 +33,9 @@ import org.opengis.test.wkt.CRSParserTest; import org.apache.sis.test.LoggingWatcher; import org.apache.sis.test.FailureDetailsReporter; +// Specific to the geoapi-3.1 and geoapi-4.0 branches: +import org.opengis.referencing.datum.RealizationMethod; + /** * Tests Well-Known Text parser using the tests defined in GeoAPI. Those tests use the @@ -365,7 +367,7 @@ public final class WKTParserTest extends CRSParserTest { super.testVertical(); final CoordinateSystem cs = object.getCoordinateSystem(); assertEquals(AxisNames.GRAVITY_RELATED_HEIGHT, cs.getAxis(0).getName().getCode(), "name"); - assertEquals(VerticalDatumType.GEOIDAL, ((VerticalCRS) object).getDatum().getVerticalDatumType(), "datumType"); + assertEquals(RealizationMethod.GEOID, ((VerticalCRS) object).getDatum().getRealizationMethod().orElse(null)); useStraightQuotes = true; super.testVertical(); // Test again with “ and ” replaced by ". 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 16513fdfc6..68387a29f3 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 @@ -216,6 +216,7 @@ public final class CommonCRSTest extends TestCase { * Verifies the vertical datum enumeration. */ @Test + @SuppressWarnings("deprecation") public void testVertical() { for (final CommonCRS.Vertical e : CommonCRS.Vertical.values()) { final VerticalDatumType datumType; diff --git a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/datum/DefaultVerticalDatumTest.java b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/datum/DefaultVerticalDatumTest.java index bf1131fda9..073dad5049 100644 --- a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/datum/DefaultVerticalDatumTest.java +++ b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/datum/DefaultVerticalDatumTest.java @@ -44,6 +44,7 @@ import static org.apache.sis.referencing.Assertions.assertWktEquals; * * @author Martin Desruisseaux (Geomatys) */ +@SuppressWarnings("deprecation") public final class DefaultVerticalDatumTest extends TestCase { /** * Creates a new test case. diff --git a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/datum/HardCodedDatum.java b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/datum/HardCodedDatum.java index a02f070ae5..9c3c6a0c0c 100644 --- a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/datum/HardCodedDatum.java +++ b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/datum/HardCodedDatum.java @@ -122,6 +122,7 @@ public final class HardCodedDatum { /** * Mean sea level, which can be used as an approximation of geoid. */ + @SuppressWarnings("deprecation") public static final DefaultVerticalDatum MEAN_SEA_LEVEL = new DefaultVerticalDatum( properties("Mean Sea Level", "5100", "Hydrography."), VerticalDatumType.GEOIDAL); @@ -149,6 +150,7 @@ public final class HardCodedDatum { /** * Image with {@link PixelInCell#CELL_CENTER}. */ + @SuppressWarnings("deprecation") public static final DefaultImageDatum IMAGE = new DefaultImageDatum( properties("Image", null, null), PixelInCell.CELL_CENTER); 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 05bcffd341..3a80d5f6e6 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 @@ -24,6 +24,7 @@ import java.util.TreeMap; import java.util.NavigableMap; import java.io.File; import java.io.IOException; +import java.util.Optional; import org.opengis.metadata.Identifier; import org.opengis.util.FactoryException; import org.opengis.util.InternationalString; @@ -40,7 +41,7 @@ import org.opengis.referencing.crs.GeneralDerivedCRS; import org.opengis.referencing.crs.CoordinateReferenceSystem; import org.opengis.referencing.crs.CRSAuthorityFactory; import org.opengis.referencing.datum.Datum; -import org.opengis.referencing.datum.VerticalDatumType; +import org.opengis.referencing.datum.RealizationMethod; import org.opengis.referencing.operation.OperationMethod; import org.apache.sis.metadata.iso.citation.Citations; import org.apache.sis.referencing.CRS; @@ -430,8 +431,10 @@ public final class CoordinateReferenceSystems extends AuthorityCodesReport { return "Geocentric"; } if (crs instanceof VerticalCRS vertical) { - final VerticalDatumType type = vertical.getDatum().getVerticalDatumType(); - return CharSequences.camelCaseToSentence(type.name().toLowerCase(getLocale())) + " height"; + final Optional<RealizationMethod> method = vertical.getDatum().getRealizationMethod(); + if (method.isPresent()) { + return CharSequences.camelCaseToSentence(method.get().name().toLowerCase(getLocale())) + " realization method"; + } } if (crs instanceof CompoundCRS compound) { final StringBuilder buffer = new StringBuilder(); diff --git a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/test/integration/MetadataTest.java b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/test/integration/MetadataTest.java index 9f9e143f09..2f6d75b62d 100644 --- a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/test/integration/MetadataTest.java +++ b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/test/integration/MetadataTest.java @@ -35,7 +35,6 @@ import org.opengis.metadata.identification.*; import org.opengis.metadata.maintenance.*; import org.opengis.metadata.spatial.GeometricObjectType; import org.opengis.referencing.cs.AxisDirection; -import org.opengis.referencing.datum.VerticalDatumType; import org.apache.sis.measure.Units; import org.apache.sis.metadata.iso.*; import org.apache.sis.metadata.iso.citation.*; @@ -64,6 +63,9 @@ import org.apache.sis.util.SimpleInternationalString; import org.apache.sis.util.ComparisonMode; import org.apache.sis.util.privy.Constants; +// Specific to the geoapi-3.1 and geoapi-4.0 branches: +import org.opengis.referencing.datum.RealizationMethod; + // Test dependencies import org.junit.jupiter.api.Test; import static org.junit.jupiter.api.Assertions.*; @@ -100,7 +102,7 @@ public final class MetadataTest extends TestCase.WithLogs { * @return the hard-coded representation of {@value #XML_FILE} content. */ private DefaultMetadata createHardCoded() { - final DefaultMetadata metadata = new DefaultMetadata(); + final var metadata = new DefaultMetadata(); metadata.setMetadataIdentifier(new DefaultIdentifier("test/Metadata.xml")); metadata.setLocalesAndCharsets(Map.of(Locale.ENGLISH, StandardCharsets.UTF_8)); metadata.setMetadataScopes(Set.of(new DefaultMetadataScope(ScopeCode.DATASET, "Pseudo Common Data Index record"))); @@ -111,18 +113,18 @@ public final class MetadataTest extends TestCase.WithLogs { * because this is what will be unmarshalled from the XML document. */ @SuppressWarnings("deprecation") - final DefaultResponsibility author = new DefaultResponsibleParty(Role.AUTHOR); - final Anchor country = new Anchor(URI.create("SDN:C320:2:FR"), "France"); // Non-public SIS class. + final var author = new DefaultResponsibleParty(Role.AUTHOR); + final var country = new Anchor(URI.create("SDN:C320:2:FR"), "France"); // Non-public SIS class. { - final DefaultOnlineResource online = new DefaultOnlineResource(URI.create("http://www.ifremer.fr/sismer/")); + final var online = new DefaultOnlineResource(URI.create("http://www.ifremer.fr/sismer/")); online.setProtocol(Constants.HTTP); - final DefaultContact contact = new DefaultContact(online); + final var contact = new DefaultContact(online); contact.getIdentifierMap().putSpecialized(IdentifierSpace.ID, "IFREMER"); contact.setPhones(List.of( new DefaultTelephone("+33 (0)2 xx.xx.xx.x6", TelephoneType.VOICE), new DefaultTelephone("+33 (0)2 xx.xx.xx.x4", TelephoneType.FACSIMILE) )); - final DefaultAddress address = new DefaultAddress(); + final var address = new DefaultAddress(); address.setDeliveryPoints(Set.of(new SimpleInternationalString("Brest institute"))); address.setCity(new SimpleInternationalString("Plouzane")); address.setPostalCode("29280"); @@ -136,22 +138,22 @@ public final class MetadataTest extends TestCase.WithLogs { * Data indentification. */ { - final DefaultCitation citation = new DefaultCitation("Some set of points"); + final var citation = new DefaultCitation("Some set of points"); citation.setAlternateTitles(Set.of(new SimpleInternationalString("Code XYZ"))); citation.setDates(List.of( new DefaultCitationDate(TestUtilities.date("1990-06-04 22:00:00"), DateType.REVISION), new DefaultCitationDate(TestUtilities.date("1979-08-02 22:00:00"), DateType.CREATION))); { @SuppressWarnings("deprecation") - final DefaultResponsibility originator = new DefaultResponsibleParty(Role.ORIGINATOR); - final DefaultOnlineResource online = new DefaultOnlineResource(URI.create("http://www.com.univ-mrs.fr/LOB/")); + final var originator = new DefaultResponsibleParty(Role.ORIGINATOR); + final var online = new DefaultOnlineResource(URI.create("http://www.com.univ-mrs.fr/LOB/")); online.setProtocol(Constants.HTTP); - final DefaultContact contact = new DefaultContact(online); + final var contact = new DefaultContact(online); contact.setPhones(List.of( new DefaultTelephone("+33 (0)4 xx.xx.xx.x5", TelephoneType.VOICE), new DefaultTelephone("+33 (0)4 xx.xx.xx.x8", TelephoneType.FACSIMILE) )); - final DefaultAddress address = new DefaultAddress(); + final var address = new DefaultAddress(); address.setDeliveryPoints(Set.of(new SimpleInternationalString("Oceanology institute"))); address.setCity(new SimpleInternationalString("Marseille")); address.setPostalCode("13288"); @@ -160,14 +162,14 @@ public final class MetadataTest extends TestCase.WithLogs { originator.setParties(Set.of(new DefaultOrganisation("Oceanology laboratory", null, null, contact))); citation.setCitedResponsibleParties(Set.of(originator)); } - final DefaultDataIdentification identification = new DefaultDataIdentification( + final var identification = new DefaultDataIdentification( citation, // Citation "Description of pseudo data for testing purpose only.", // Abstract Locale.ENGLISH, // Language, TopicCategory.OCEANS); // Topic category { @SuppressWarnings("deprecation") - final DefaultResponsibility custodian = new DefaultResponsibleParty(author); + final var custodian = new DefaultResponsibleParty(author); custodian.setRole(Role.CUSTODIAN); identification.setPointOfContacts(Set.of(custodian)); } @@ -175,10 +177,10 @@ public final class MetadataTest extends TestCase.WithLogs { * Data indentification / Keywords. */ { - final DefaultKeywords keyword = new DefaultKeywords( + final var keyword = new DefaultKeywords( new Anchor(URI.create("SDN:P021:35:ATTN"), "Transmittance and attenuance of the water column")); keyword.setType(KeywordType.THEME); - final DefaultCitation thesaurus = new DefaultCitation("BODC Parameter Discovery Vocabulary"); + final var thesaurus = new DefaultCitation("BODC Parameter Discovery Vocabulary"); thesaurus.setAlternateTitles(Set.of(new SimpleInternationalString("P021"))); thesaurus.setDates(Set.of(new DefaultCitationDate(TestUtilities.date("2008-11-25 23:00:00"), DateType.REVISION))); thesaurus.setEdition(new Anchor(URI.create("SDN:C371:1:35"), "35")); @@ -190,7 +192,7 @@ public final class MetadataTest extends TestCase.WithLogs { * Data indentification / Browse graphic. */ { - final DefaultBrowseGraphic g = new DefaultBrowseGraphic(URI.create("file:///thumbnail.png")); + final var g = new DefaultBrowseGraphic(URI.create("file:///thumbnail.png")); g.setFileDescription(new SimpleInternationalString("Arbitrary thumbnail for this test only.")); identification.setGraphicOverviews(Set.of(g)); } @@ -198,7 +200,7 @@ public final class MetadataTest extends TestCase.WithLogs { * Data indentification / Resource constraint. */ { - final DefaultLegalConstraints constraint = new DefaultLegalConstraints(); + final var constraint = new DefaultLegalConstraints(); constraint.setAccessConstraints(Set.of(Restriction.LICENCE)); identification.setResourceConstraints(Set.of(constraint)); } @@ -207,8 +209,8 @@ public final class MetadataTest extends TestCase.WithLogs { */ { @SuppressWarnings("deprecation") - final DefaultAssociatedResource aggregateInfo = new DefaultAggregateInformation(); - final DefaultCitation name = new DefaultCitation("Some oceanographic campaign"); + final var aggregateInfo = new DefaultAggregateInformation(); + final var name = new DefaultCitation("Some oceanographic campaign"); name.setAlternateTitles(Set.of(new SimpleInternationalString("Pseudo group of data"))); name.setDates(Set.of(new DefaultCitationDate(TestUtilities.date("1990-06-04 22:00:00"), DateType.REVISION))); aggregateInfo.setName(name); @@ -220,19 +222,19 @@ public final class MetadataTest extends TestCase.WithLogs { * Data indentification / Extent. */ { - final DefaultCoordinateSystemAxis axis = new DefaultCoordinateSystemAxis( + final var axis = new DefaultCoordinateSystemAxis( nameAndIdentifier("depth", "Depth", null), "D", AxisDirection.DOWN, Units.METRE); - final DefaultVerticalCS cs = new DefaultVerticalCS( + final var cs = new DefaultVerticalCS( nameAndIdentifier("depth", "Depth", null), axis); - final DefaultVerticalDatum datum = new DefaultVerticalDatum( - nameAndIdentifier("D28", "Depth below D28", "For testing purpose"), VerticalDatumType.OTHER_SURFACE); + final var datum = new DefaultVerticalDatum( + nameAndIdentifier("D28", "Depth below D28", "For testing purpose"), (RealizationMethod) null); - final DefaultVerticalCRS vcrs = new DefaultVerticalCRS( + final var vcrs = new DefaultVerticalCRS( nameAndIdentifier("D28", "Depth below D28", "CRS for testing purpose"), datum, cs); - final DefaultTemporalExtent temporal = new DefaultTemporalExtent(); + final var temporal = new DefaultTemporalExtent(); temporal.setBounds(TestUtilities.date("1990-06-05 00:00:00"), TestUtilities.date("1990-07-02 00:00:00")); identification.setExtents(Set.of(new DefaultExtent( null, @@ -253,8 +255,8 @@ public final class MetadataTest extends TestCase.WithLogs { * Information about spatial representation. */ { - final DefaultVectorSpatialRepresentation rep = new DefaultVectorSpatialRepresentation(); - final DefaultGeometricObjects geoObj = new DefaultGeometricObjects(GeometricObjectType.POINT); + final var rep = new DefaultVectorSpatialRepresentation(); + final var geoObj = new DefaultGeometricObjects(GeometricObjectType.POINT); rep.setGeometricObjects(Set.of(geoObj)); metadata.setSpatialRepresentationInfo(Set.of(rep)); } @@ -262,7 +264,7 @@ public final class MetadataTest extends TestCase.WithLogs { * Information about Coordinate Reference System. */ { - final DefaultCitation citation = new DefaultCitation("World Geodetic System 84"); + final var citation = new DefaultCitation("World Geodetic System 84"); citation.setAlternateTitles(Set.of(new SimpleInternationalString("L101"))); citation.setIdentifiers(Set.of(new ImmutableIdentifier(null, null, "SDN:L101:2:4326"))); citation.setEdition(new Anchor(URI.create("SDN:C371:1:2"), "2")); @@ -273,7 +275,7 @@ public final class MetadataTest extends TestCase.WithLogs { * Information about content. */ { - final DefaultImageDescription contentInfo = new DefaultImageDescription(); + final var contentInfo = new DefaultImageDescription(); contentInfo.setCloudCoverPercentage(50.0); metadata.setContentInfo(Set.of(contentInfo)); } @@ -281,7 +283,7 @@ public final class MetadataTest extends TestCase.WithLogs { * Extension to metadata. */ { - final DefaultMetadataExtensionInformation extensionInfo = new DefaultMetadataExtensionInformation(); + final var extensionInfo = new DefaultMetadataExtensionInformation(); extensionInfo.setExtendedElementInformation(Set.of(new DefaultExtendedElementInformation( "SDN:EDMO", // Name "European Directory of Marine Organisations", // Definition @@ -297,21 +299,21 @@ public final class MetadataTest extends TestCase.WithLogs { */ { @SuppressWarnings("deprecation") - final DefaultResponsibility distributor = new DefaultResponsibleParty(author); - final DefaultDistribution distributionInfo = new DefaultDistribution(); + final var distributor = new DefaultResponsibleParty(author); + final var distributionInfo = new DefaultDistribution(); distributor.setRole(Role.DISTRIBUTOR); distributionInfo.setDistributors(Set.of(new DefaultDistributor(distributor))); - final DefaultFormat format = new DefaultFormat(); - final DefaultCitation specification = new DefaultCitation(); + final var format = new DefaultFormat(); + final var specification = new DefaultCitation(); specification.setAlternateTitles(Set.of(new Anchor(URI.create("SDN:L241:1:MEDATLAS"), "MEDATLAS ASCII"))); specification.setEdition(new SimpleInternationalString("1.0")); format.setFormatSpecificationCitation(specification); distributionInfo.setDistributionFormats(Set.of(format)); - final DefaultDigitalTransferOptions transfer = new DefaultDigitalTransferOptions(); + final var transfer = new DefaultDigitalTransferOptions(); transfer.setTransferSize(2.431640625); - final DefaultOnlineResource onlines = new DefaultOnlineResource(URI.create("ftp://www.ifremer.fr/data/something")); + final var onlines = new DefaultOnlineResource(URI.create("ftp://www.ifremer.fr/data/something")); onlines.setDescription(new SimpleInternationalString("Dummy download link")); onlines.setFunction(OnLineFunction.DOWNLOAD); onlines.setProtocol("ftp"); @@ -326,7 +328,7 @@ public final class MetadataTest extends TestCase.WithLogs { * Returns a property map with a name and identifier. This is used for creating CRS components. */ private static Map<String,?> nameAndIdentifier(final String identifier, final String name, final String scope) { - final Map<String,Object> properties = new HashMap<>(4); + final var properties = new HashMap<String,Object>(4); properties.put(DefaultVerticalDatum.NAME_KEY, new NamedIdentifier(null, name)); properties.put(DefaultVerticalDatum.IDENTIFIERS_KEY, new NamedIdentifier(null, "test", identifier, null, null)); if (scope != null) { @@ -374,7 +376,7 @@ public final class MetadataTest extends TestCase.WithLogs { * now the "gml:id" attribute since SIS generates different values than the ones in our test XML file, * and those values may change in future SIS version. */ - final DocumentComparator comparator = new DocumentComparator(getResource(), xml.toString()); + final var comparator = new DocumentComparator(getResource(), xml.toString()); comparator.ignoredNodes.add(LegacyNamespaces.GMD + ":temporalElement"); comparator.ignoredAttributes.add("http://www.w3.org/2000/xmlns:*"); comparator.ignoredAttributes.add(Namespaces.XSI + ":schemaLocation"); diff --git 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 index 813a54aa5e..e1fe872ceb 100644 --- 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 @@ -132,7 +132,7 @@ public final class MetadataVerticalTest extends TestCase.WithLogs { * <gmd:MD_DataIdentification> * … */ - final DataIdentification identification = (DataIdentification) getSingleton(metadata.getIdentificationInfo()); + final var identification = (DataIdentification) getSingleton(metadata.getIdentificationInfo()); final Citation citation = identification.getCitation(); assertInstanceOf(NilObject.class, citation); assertEquals(NilReason.MISSING, ((NilObject) citation).getNilReason()); @@ -146,7 +146,7 @@ public final class MetadataVerticalTest extends TestCase.WithLogs { * </gmd:geographicElement> */ final Extent extent = getSingleton(identification.getExtents()); - final GeographicBoundingBox bbox = (GeographicBoundingBox) getSingleton(extent.getGeographicElements()); + final var bbox = (GeographicBoundingBox) getSingleton(extent.getGeographicElements()); assertEquals(Boolean.TRUE, bbox.getInclusion()); assertEquals( 4.55, bbox.getWestBoundLongitude()); assertEquals( 4.55, bbox.getEastBoundLongitude()); @@ -168,7 +168,7 @@ public final class MetadataVerticalTest extends TestCase.WithLogs { final VerticalDatum datum = crs.getDatum(); verifyIdentifiers("test2", datum); assertEquals("World", datum.getScope().toString()); - assertEquals(VerticalDatumType.DEPTH, datum.getVerticalDatumType()); // Inferred from the name. + assertEquals(VerticalDatumType.DEPTH, datum.getVerticalDatumType()); // Inferred from the name. final VerticalCS cs = crs.getCoordinateSystem(); verifyIdentifiers("test3", cs); final CoordinateSystemAxis axis = cs.getAxis(0);