This is an automated email from the ASF dual-hosted git repository.
desruisseaux pushed a commit to branch geoapi-4.0
in repository https://gitbox.apache.org/repos/asf/sis.git
The following commit(s) were added to refs/heads/geoapi-4.0 by this push:
new 3e79841b4c Post-merge adjustments in `VerticalDatumTypes`.
3e79841b4c is described below
commit 3e79841b4c2fc5eac551b2ff9e8540853125c7c0
Author: Martin Desruisseaux <[email protected]>
AuthorDate: Mon Apr 22 12:54:51 2024 +0200
Post-merge adjustments in `VerticalDatumTypes`.
---
.../apache/sis/io/wkt/GeodeticObjectParser.java | 5 ++-
.../main/org/apache/sis/referencing/CommonCRS.java | 6 +++-
.../sis/referencing/StandardDefinitions.java | 3 +-
.../referencing/factory/GeodeticObjectFactory.java | 4 +--
.../apache/sis/referencing/internal/Legacy.java | 2 +-
.../referencing/internal/VerticalDatumTypes.java | 39 +++++++++++++++++-----
.../operation/CoordinateOperationRegistry.java | 2 +-
.../privy/EllipsoidalHeightCombiner.java | 3 +-
.../internal/VerticalDatumTypesTest.java | 12 +++++++
9 files changed, 55 insertions(+), 21 deletions(-)
diff --git
a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/io/wkt/GeodeticObjectParser.java
b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/io/wkt/GeodeticObjectParser.java
index 659162db6a..613eabf205 100644
---
a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/io/wkt/GeodeticObjectParser.java
+++
b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/io/wkt/GeodeticObjectParser.java
@@ -689,7 +689,6 @@ class GeodeticObjectParser extends MathTransformParser
implements Comparator<Coo
* @throws ParseException if an element cannot be parsed.
* @throws FactoryException if the factory cannot create the coordinate
system.
*/
- @SuppressWarnings("deprecation")
private CoordinateSystem parseCoordinateSystem(final Element parent,
String type, int dimension,
final boolean isWKT1, final Unit<?> defaultUnit, final Datum
datum) throws ParseException, FactoryException
{
@@ -772,8 +771,8 @@ class GeodeticObjectParser extends MathTransformParser
implements Comparator<Coo
Unit<?> unit = defaultUnit; // Depth, height
or time axis unit.
switch (type) {
/*
- * Cartesian — we can create axes only for geodetic datum, in
which case the axes are for
- * two-dimensional Projected or three-dimensional Geocentric
CRS.
+ * Cartesian — we can create axes only for geodetic datum, in
which case the axes
+ * are for two- or three-dimensional Projected or
three-dimensional Geocentric CRS.
*/
case WKTKeywords.Cartesian: {
if (datum != null && !(datum instanceof GeodeticDatum)) {
diff --git
a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/CommonCRS.java
b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/CommonCRS.java
index de5cd6e482..8abad5348b 100644
---
a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/CommonCRS.java
+++
b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/CommonCRS.java
@@ -1467,7 +1467,11 @@ public enum CommonCRS {
if (isEPSG) {
object =
StandardDefinitions.createVerticalDatum(datum);
} else {
- // BAROMETRIC and ELLIPSOIDAL cases.
+ /*
+ * All cases where the first constructor argument
is `false`, currently BAROMETRIC and
+ * ELLIPSOIDAL. The way to construct the
ellipsoidal pseudo-method shall be equivalent
+ * to a call to `VerticalDatumTypes.ellipsoidal()`.
+ */
RealizationMethod method = null;
if (this != OTHER_SURFACE) {
method = RealizationMethod.valueOf(name());
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 f872175d90..882f14cc30 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
@@ -74,7 +74,6 @@ 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;
import static org.opengis.referencing.ObjectDomain.DOMAIN_OF_VALIDITY_KEY;
@@ -348,7 +347,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),
RealizationMethod.GEOID);
+ return new DefaultVerticalDatum(properties(code, name, alias, true),
null);
}
/**
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 a3b869bed1..5d66b76bff 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
@@ -918,11 +918,11 @@ public class GeodeticObjectFactory extends
AbstractFactory implements CRSFactory
}
/**
- * Creates a vertical datum from an enumerated type value.
+ * Creates a vertical datum from a realization method.
* The default implementation creates a {@link DefaultVerticalDatum}
instance.
*
* @param properties name and other properties to give to the new object.
- * @param method the realization method the vertical datum, or
{@code null} if none.
+ * @param method the realization method of the vertical datum, or
{@code null} if none.
* @throws FactoryException if the object creation failed.
*
* @see DefaultVerticalDatum#DefaultVerticalDatum(Map, RealizationMethod)
diff --git
a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/internal/Legacy.java
b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/internal/Legacy.java
index 9707a27c18..16c9a508c9 100644
---
a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/internal/Legacy.java
+++
b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/internal/Legacy.java
@@ -97,7 +97,7 @@ public final class Legacy {
}
/**
- * The standard three-dimensional Cartesian CS as defined by ISO 19111.
+ * The standard three-dimensional geocentric Cartesian CS as defined by
ISO 19111.
*
* @param unit the linear unit of the desired coordinate system, or
{@code null} for metres.
* @return the ISO 19111 coordinate system.
diff --git
a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/internal/VerticalDatumTypes.java
b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/internal/VerticalDatumTypes.java
index b209366666..d1e2e82a46 100644
---
a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/internal/VerticalDatumTypes.java
+++
b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/internal/VerticalDatumTypes.java
@@ -40,24 +40,36 @@ public final class VerticalDatumTypes {
/**
* A pseudo-realization method for ellipsoidal heights that are measured
along
* the normal to the ellipsoid used in the definition of horizontal datum.
+ * <strong>The use of this method is deprecated</strong> as ellipsoidal
height
+ * should never be separated from the horizontal components according ISO
19111.
*
- * <p>Identifier: {@code CS_DatumType.CS_VD_Ellipsoidal}</p>
+ * <h4>Legacy</h4>
+ * This type was associated to code 2000 in the {@code Vert_Datum} element
of the legacy WKT 1 format.
+ * The UML identifier was {@code CS_DatumType.CS_VD_Ellipsoidal}.
+ *
+ * @see org.apache.sis.referencing.CommonCRS.Vertical#ELLIPSOIDAL
*/
- private static final String ELLIPSOIDAL = "ELLIPSOIDAL";
+ static final String ELLIPSOIDAL = "ELLIPSOIDAL";
/**
- * A vertical datum for orthometric heights that are measured along the
plumb line.
+ * A vertical datum type for orthometric heights that are measured along
the plumb line.
*
- * <p>Identifier: {@code CS_DatumType.CS_VD_Orthometric}</p>
+ * <h4>Legacy</h4>
+ * This type was associated to code 2001 in the {@code Vert_Datum} element
of the legacy WKT 1 format.
+ * The UML identifier was {@code CS_DatumType.CS_VD_Orthometric}.
*/
private static final String ORTHOMETRIC = "ORTHOMETRIC";
/**
- * A vertical datum for origin of the vertical axis based on atmospheric
pressure.
+ * A vertical datum type for origin of the vertical axis based on
atmospheric pressure.
+ *
+ * <h4>Legacy</h4>
+ * This type was associated to code 2003 in the {@code Vert_Datum} element
of the legacy WKT 1 format.
+ * The UML identifier was {@code CS_DatumType.CS_VD_AltitudeBarometric}.
*
- * <p>Identifier: {@code CS_DatumType.CS_VD_AltitudeBarometric}</p>
+ * @see org.apache.sis.referencing.CommonCRS.Vertical#BAROMETRIC
*/
- private static final String BAROMETRIC = "BAROMETRIC";
+ static final String BAROMETRIC = "BAROMETRIC";
/**
* Do not allow instantiation of this class.
@@ -67,6 +79,13 @@ public final class VerticalDatumTypes {
/**
* Returns a pseudo-realization method for ellipsoidal heights.
+ * <strong>The use of this method is deprecated</strong> as ellipsoidal
height
+ * should never be separated from the horizontal components according ISO
19111.
+ *
+ * <h4>Maintenance note</h4>
+ * If the implementation of this method is modified, search for {@code
RealizationMethod.valueOf}
+ * at least in {@link
org.apache.sis.referencing.CommonCRS.Vertical#datum()} and make sure that
+ * the code is equivalent.
*
* @return the ellipsoidal pseudo-realization method.
*/
@@ -113,7 +132,7 @@ public final class VerticalDatumTypes {
*/
public static int toLegacy(final RealizationMethod method) {
if (method != null) {
- switch (method.name()) {
+ switch (method.name().toUpperCase(Locale.US)) {
case ORTHOMETRIC: return 2001; // CS_VD_Orthometric
case ELLIPSOIDAL: return 2002; // CS_VD_Ellipsoidal
case BAROMETRIC: return 2003; // CS_VD_AltitudeBarometric
@@ -128,6 +147,7 @@ public final class VerticalDatumTypes {
* Returns the vertical datum type from a realization method.
* If the given method cannot be mapped to a legacy type, then this method
returns "other surface".
* This is because the vertical datum type was a mandatory property in
legacy OGC/ISO standards.
+ * This method is used for writing GML documents older than GML 3.2.
*
* @param method the realization method, or {@code null}.
* @return the vertical datum type name (never null).
@@ -142,7 +162,8 @@ public final class VerticalDatumTypes {
}
/**
- * Returns the realization method from a name.
+ * Returns the realization method from a vertical datum type.
+ * This method is used for reading GML documents older than GML 3.2.
*
* @param type the vertical datum type, or {@code null}.
* @return the realization method, or {@code null} if none.
diff --git
a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/operation/CoordinateOperationRegistry.java
b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/operation/CoordinateOperationRegistry.java
index def3586a9b..45f05c2ace 100644
---
a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/operation/CoordinateOperationRegistry.java
+++
b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/operation/CoordinateOperationRegistry.java
@@ -1195,7 +1195,7 @@ class CoordinateOperationRegistry {
}
/**
- * If the given CRS is two-dimensional, append an ellipsoidal height to it.
+ * If the given CRS is two-dimensional, appends an ellipsoidal height to
it.
* It is caller's responsibility to ensure that the given CRS is
geographic.
*/
private CoordinateReferenceSystem toGeodetic3D(CoordinateReferenceSystem
crs,
diff --git
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
index d87655d6cc..c8791dbd93 100644
---
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
@@ -35,7 +35,6 @@ import org.opengis.referencing.datum.VerticalDatum;
import org.opengis.referencing.operation.Conversion;
import org.opengis.referencing.operation.CoordinateOperationFactory;
import org.apache.sis.referencing.IdentifiedObjects;
-import org.apache.sis.referencing.internal.VerticalDatumTypes;
import org.apache.sis.metadata.iso.extent.Extents;
import org.apache.sis.util.ArgumentChecks;
import org.apache.sis.util.ArraysExt;
@@ -115,7 +114,7 @@ public final class EllipsoidalHeightCombiner {
final CoordinateReferenceSystem vertical = components[i];
if (vertical instanceof VerticalCRS) {
final VerticalDatum datum = ((VerticalCRS)
vertical).getDatum();
- if (datum != null &&
VerticalDatumTypes.ellipsoidal(datum.getRealizationMethod().orElse(null))) {
+ if (ReferencingUtilities.isEllipsoidalHeight(datum)) {
int axisPosition = 0;
CoordinateSystem cs = null;
CoordinateReferenceSystem crs = null;
diff --git
a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/internal/VerticalDatumTypesTest.java
b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/internal/VerticalDatumTypesTest.java
index 4061d9b3c4..8e98da4827 100644
---
a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/internal/VerticalDatumTypesTest.java
+++
b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/internal/VerticalDatumTypesTest.java
@@ -17,6 +17,7 @@
package org.apache.sis.referencing.internal;
import org.opengis.referencing.datum.RealizationMethod;
+import org.apache.sis.referencing.CommonCRS;
import org.apache.sis.util.ArraysExt;
// Test dependencies
@@ -38,6 +39,17 @@ public final class VerticalDatumTypesTest extends TestCase {
public VerticalDatumTypesTest() {
}
+ /**
+ * Verifies name constraint with values defined in {@link
org.apache.sis.referencing.CommonCRS.Vertical}.
+ * Some enumeration values must have the same names as the constants
defined in {@link VerticalDatumTypes},
+ * because the realization method is obtained by a call to {@link
RealizationMethod#valueOf(String)}.
+ */
+ @Test
+ public void verifyNameConstraint() {
+ assertEquals(VerticalDatumTypes.ELLIPSOIDAL,
CommonCRS.Vertical.ELLIPSOIDAL.name());
+ assertEquals(VerticalDatumTypes.BAROMETRIC,
CommonCRS.Vertical.BAROMETRIC.name());
+ }
+
/**
* Tests the {@link VerticalDatumTypes#fromLegacy(int)} method.
*/