This is an automated email from the ASF dual-hosted git repository.

desruisseaux pushed a commit to branch geoapi-3.1
in repository https://gitbox.apache.org/repos/asf/sis.git

commit 43241772b657472a14b8ff52fde9cc2e8f18fca9
Merge: 74a6061f9e adbe2180c3
Author: Martin Desruisseaux <martin.desruisse...@geomatys.com>
AuthorDate: Fri Apr 19 19:18:45 2024 +0200

    Merge branch 'geoapi-4.0' into geoapi-3.1: reduce usage of deprecated 
`AxisDirection.OTHER` and `VerticalDatumType`.

 .../apache/sis/coverage/grid/GridExtentCRS.java    |   6 +-
 .../apache/sis/metadata/iso/extent/Extents.java    |  66 +++---
 .../sis/metadata/iso/extent/ExtentsTest.java       |   9 +-
 .../org/apache/sis/test/mock/VerticalCRSMock.java  |  25 +--
 .../apache/sis/io/wkt/GeodeticObjectParser.java    |  29 ++-
 .../main/org/apache/sis/referencing/CRS.java       |   4 +-
 .../main/org/apache/sis/referencing/CommonCRS.java |  28 +--
 .../org/apache/sis/referencing/cs/AbstractCS.java  |   5 +-
 .../main/org/apache/sis/referencing/cs/Codes.java  |  24 ++-
 .../org/apache/sis/referencing/cs/Normalizer.java  |   4 +-
 .../referencing/datum/DefaultVerticalDatum.java    |  82 ++-----
 .../referencing/factory/GeodeticObjectFactory.java |  28 ++-
 .../referencing/factory/sql/EPSGCodeFinder.java    |   7 -
 .../referencing/factory/sql/EPSGDataAccess.java    |  14 +-
 .../sis/referencing/factory/sql/TableInfo.java     |   1 -
 .../apache/sis/referencing/internal/Legacy.java    |   7 +-
 .../referencing/internal/VerticalDatumTypes.java   | 240 ++++++++++-----------
 .../sis/referencing/operation/matrix/Matrices.java |   2 +-
 .../sis/referencing/privy/AxisDirections.java      |   8 +-
 .../privy/EllipsoidalHeightCombiner.java           |   2 +-
 .../referencing/privy/ReferencingUtilities.java    |   8 +-
 .../org/apache/sis/io/wkt/TransliteratorTest.java  |  12 +-
 .../org/apache/sis/referencing/CommonCRSTest.java  |  24 ++-
 .../apache/sis/referencing/cs/HardCodedAxes.java   |   4 +-
 .../apache/sis/referencing/cs/NormalizerTest.java  |   1 +
 .../datum/DefaultVerticalDatumTest.java            |  43 +---
 .../sis/referencing/datum/HardCodedDatum.java      |   6 +-
 .../referencing/datum/VerticalDatum (GML 3.1).xml  |   2 +-
 .../internal/VerticalDatumTypesTest.java           |  25 +--
 .../sis/referencing/privy/AxisDirectionsTest.java  |  20 +-
 .../sis/test/integration/MetadataVerticalTest.java |   2 -
 .../org/apache/sis/storage/netcdf/base/Axis.java   |   2 +-
 .../apache/sis/storage/netcdf/base/CRSBuilder.java |   2 +-
 geoapi/snapshot                                    |   2 +-
 34 files changed, 328 insertions(+), 416 deletions(-)

diff --cc 
endorsed/src/org.apache.sis.metadata/test/org/apache/sis/test/mock/VerticalCRSMock.java
index e189a2e320,4b9315783c..2ad61c5b4f
--- 
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
@@@ -23,13 -23,8 +23,12 @@@ import org.opengis.referencing.cs.Coord
  import org.opengis.referencing.cs.RangeMeaning;
  import org.opengis.referencing.cs.VerticalCS;
  import org.opengis.referencing.datum.VerticalDatum;
- import org.opengis.referencing.datum.VerticalDatumType;
  import org.apache.sis.measure.Units;
  
 +// Specific to the main and geoapi-3.1 branches:
 +import org.opengis.metadata.extent.Extent;
 +import org.opengis.util.InternationalString;
 +
  // Specific to the geoapi-3.1 and geoapi-4.0 branches:
  import java.util.Optional;
  import org.opengis.referencing.datum.RealizationMethod;
@@@ -135,10 -119,7 +123,9 @@@ public final class VerticalCRSMock exte
      }
  
      @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;}
diff --cc 
endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/cs/AbstractCS.java
index 1bd437faf7,f69e8f1555..1625e20723
--- 
a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/cs/AbstractCS.java
+++ 
b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/cs/AbstractCS.java
@@@ -197,6 -197,6 +197,7 @@@ public class AbstractCS extends Abstrac
       * @param  properties  properties given at construction time, or {@code 
null} if none.
       * @throws IllegalArgumentException if an axis has an illegal direction 
or an illegal unit of measurement.
       */
++    @SuppressWarnings("deprecation")
      void validate(final Map<String,?> properties) {
          for (int i=0; i<axes.length; i++) {
              final CoordinateSystemAxis axis = axes[i];
@@@ -228,7 -228,7 +229,7 @@@
               * more than one time axis. Such case happen in meteorological 
models.
               */
              final AxisDirection dir = AxisDirections.absolute(direction);
-             if (!dir.equals(AxisDirection.OTHER)) {
 -            if (dir != AxisDirection.UNSPECIFIED && 
!AxisDirections.isLegacyOther(dir)) {
++            if (dir != AxisDirection.UNSPECIFIED && dir != 
AxisDirection.OTHER) {
                  for (int j=i; --j>=0;) {
                      final AxisDirection other = axes[j].getDirection();
                      final AxisDirection abs = AxisDirections.absolute(other);
diff --cc 
endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/datum/DefaultVerticalDatum.java
index e0a3a531aa,76e48235db..776b9d95dd
--- 
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
@@@ -96,16 -99,6 +96,14 @@@ public class DefaultVerticalDatum exten
       */
      private RealizationMethod method;
  
 +    /**
 +     * The type of this vertical datum.
-      * If {@code null}, a value will be inferred from the name by {@link 
#type()}.
 +     *
-      * @see #type()
 +     * @see #getVerticalDatumType()
 +     */
 +    @SuppressWarnings("deprecation")
 +    private VerticalDatumType type;
 +
      /**
       * Creates a vertical datum from the given properties. The properties map 
is given
       * unchanged to the {@linkplain AbstractDatum#AbstractDatum(Map) 
super-class constructor}.
@@@ -157,22 -150,6 +155,22 @@@
      public DefaultVerticalDatum(final Map<String,?> properties, final 
RealizationMethod method) {
          super(properties);
          this.method = method;
-         type = VerticalDatum.super.getVerticalDatumType();
++        type = VerticalDatumTypes.fromMethod(method);
 +    }
 +
 +    /**
 +     * 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.
 +     *
 +     * @deprecated As of ISO 19111:2019, the {@code VerticalDatumType} 
argument is replaced by {@code RealizationMethod}.
 +     */
 +    @Deprecated(since = "2.0")  // Temporary version number until this branch 
is released.
 +    public DefaultVerticalDatum(final Map<String,?> properties, final 
VerticalDatumType type) {
 +        super(properties);
 +        this.type = Objects.requireNonNull(type);
-         setRealizationMethod();
++        method = VerticalDatumTypes.toMethod(type);
      }
  
      /**
@@@ -186,13 -163,9 +184,11 @@@
       *
       * @see #castOrCopy(VerticalDatum)
       */
 +    @SuppressWarnings("deprecation")
      protected DefaultVerticalDatum(final VerticalDatum datum) {
          super(datum);
+         method = datum.getRealizationMethod().orElse(null);
 +        type = datum.getVerticalDatumType();
-         if (datum instanceof DefaultVerticalDatum) {
-             method = ((DefaultVerticalDatum) datum).method;
-         }
      }
  
      /**
@@@ -237,63 -211,6 +234,25 @@@
          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.
-      * It may also happen if the datum were created using reflection.
-      *
-      * <p>This method uses heuristic rules and may be changed in any future 
SIS version. If the type cannot be
-      * determined, default on the ellipsoidal type since it will usually 
implies no additional calculation.</p>
-      *
-      * <p>No synchronization needed; this is not a problem if this value is 
computed twice.
-      * This method returns only existing immutable instances.</p>
-      *
-      * @see #getVerticalDatumType()
-      * @see #getTypeElement()
-      */
-     @SuppressWarnings("deprecation")
-     private VerticalDatumType type() {
-         VerticalDatumType t = type;
-         if (t == null) {
-             final Identifier name = super.getName();
-             type = t = VerticalDatumTypes.guess(name != null ? name.getCode() 
: null, super.getAlias(), null);
-         }
-         return t;
-     }
- 
 +    /**
 +     * Returns the type of this vertical datum.
 +     *
 +     * <h4>Historical note:</h4>
 +     * This property was defined in the ISO 19111 specification published in 
2003,
 +     * but removed from the revision published 2007.
 +     * This property provides an information similar to the {@linkplain 
#getAnchorPoint() anchor definition},
 +     * 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")  // Temporary version number until this branch 
is released.
 +    public VerticalDatumType getVerticalDatumType() {
-         return type();
++        return type;
 +    }
 +
      /**
       * Compares this vertical datum with the specified object for equality.
       *
@@@ -315,7 -231,7 +274,7 @@@
          switch (mode) {
              case STRICT: {
                  final var other = (DefaultVerticalDatum) object;
-                 return Objects.equals(method, other.method) && 
type().equals(other.type());
 -                return Objects.equals(method, other.method);
++                return Objects.equals(method, other.method) && 
Objects.equals(type, other.type);
              }
              case BY_CONTRACT: {
                  final var other = (VerticalDatum) object;
@@@ -363,7 -277,7 +321,7 @@@
      protected String formatTo(final Formatter formatter) {
          super.formatTo(formatter);
          if (formatter.getConvention().majorVersion() == 1) {
-             formatter.append(VerticalDatumTypes.toLegacy(type()));
 -            formatter.append(VerticalDatumTypes.toLegacy(method));
++            
formatter.append(VerticalDatumTypes.toLegacy(getVerticalDatumType()));
              return WKTKeywords.Vert_Datum;
          }
          return formatter.shortOrLong(WKTKeywords.VDatum, 
WKTKeywords.VerticalDatum);
@@@ -408,13 -325,11 +366,13 @@@
      /**
       * Invoked by JAXB only. The vertical datum type is set only if it has 
not already been specified.
       */
 -    private void setTypeElement(final String type) {
 -        if (method == null) {
 -            method = VerticalDatumTypes.fromName(type);
 +    @SuppressWarnings("deprecation")
-     private void setTypeElement(final VerticalDatumType t) {
++    private void setTypeElement(final VerticalDatumType value) {
 +        if (type == null) {
-             type = t;
-             setRealizationMethod();
++            type = value;
++            method = VerticalDatumTypes.toMethod(value);
          } else {
 -            
ImplementationHelper.propertyAlreadySet(DefaultVerticalDatum.class, "setType", 
"verticalDatumType");
 +            
ImplementationHelper.propertyAlreadySet(DefaultVerticalDatum.class, 
"setTypeElement", "verticalDatumType");
          }
      }
  }
diff --cc 
endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/factory/GeodeticObjectFactory.java
index e65cd8db77,a3b869bed1..144f64ba79
--- 
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
@@@ -972,28 -922,27 +972,54 @@@ public class GeodeticObjectFactory exte
       * 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.
+      * @throws FactoryException if the object creation failed.
+      *
+      * @see DefaultVerticalDatum#DefaultVerticalDatum(Map, RealizationMethod)
+      * @see GeodeticAuthorityFactory#createVerticalDatum(String)
+      *
+      * @since 2.0
+      */
+     @Override
+     public VerticalDatum createVerticalDatum(final Map<String,?> properties,
+             final RealizationMethod method) throws FactoryException
+     {
+         final DefaultVerticalDatum datum;
+         try {
+             datum = new DefaultVerticalDatum(complete(properties), method);
+         } catch (IllegalArgumentException exception) {
+             throw new InvalidGeodeticParameterException(exception);
+         }
+         return unique("createVerticalDatum", datum);
+     }
+ 
++    /**
++     * Creates a vertical datum from an enumerated type value.
++     * The default implementation creates a {@link DefaultVerticalDatum} 
instance.
++     *
++     * @param  properties  name and other properties to give to the new 
object.
 +     * @param  type        the type of this vertical datum (often geoidal).
 +     * @throws FactoryException if the object creation failed.
 +     *
 +     * @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")  // Temporary version number until this branch 
is released.
 +    public VerticalDatum createVerticalDatum(final Map<String,?> properties,
 +            final VerticalDatumType type) throws FactoryException
 +    {
 +        final DefaultVerticalDatum datum;
 +        try {
 +            datum = new DefaultVerticalDatum(complete(properties), type);
 +        } catch (IllegalArgumentException exception) {
 +            throw new InvalidGeodeticParameterException(exception);
 +        }
 +        return unique("createVerticalDatum", datum);
 +    }
 +
      /**
       * Creates a vertical coordinate system.
       * This coordinate system can be used with vertical and derived CRS.
diff --cc 
endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/factory/sql/EPSGDataAccess.java
index 66c7599240,7f7a4fdf29..a05d123ee6
--- 
a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/factory/sql/EPSGDataAccess.java
+++ 
b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/factory/sql/EPSGDataAccess.java
@@@ -1718,14 -1711,8 +1712,8 @@@ codes:  for (int i=0; i<codes.length; i
                          datum = datumFactory.createGeodeticDatum(properties, 
ellipsoid, meridian);
                          break;
                      }
-                     /*
-                      * Vertical datum type is hard-coded to geoidal. It would 
be possible to infer other
-                      * types by looking at the coordinate system, but it 
could result in different datum
-                      * associated to the same EPSG code.  Since vertical 
datum type is no longer part of
-                      * ISO 19111:2007, it is probably not worth to handle 
such cases.
-                      */
                      case "vertical": {
-                         datum = datumFactory.createVerticalDatum(properties, 
VERTICAL_DATUM_TYPE);
 -                        datum = datumFactory.createVerticalDatum(properties, 
null);
++                        datum = datumFactory.createVerticalDatum(properties, 
(RealizationMethod) null);
                          break;
                      }
                      /*
diff --cc 
endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/internal/Legacy.java
index e19dbc0ac3,9707a27c18..3a000e0cfe
--- 
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
@@@ -63,8 -85,8 +63,9 @@@ public final class Legacy 
       * the ISO 19111's ones (ISO names are "Geocentric X", "Geocentric Y" and 
"Geocentric Z"). This constant uses
       * the invalid names and directions for WKT 1 parsing/formatting purposes.
       */
-     private static final CartesianCS LEGACY = new 
DefaultCartesianCS(Map.of(NAME_KEY, "Legacy geocentric"),
++    @SuppressWarnings("deprecation")
+     private static final CartesianCS GEOCENTRIC = new 
DefaultCartesianCS(Map.of(NAME_KEY, "Legacy geocentric"),
 -            new DefaultCoordinateSystemAxis(Map.of(NAME_KEY, "X"), "X",       
        OTHER, Units.METRE),
 +            new DefaultCoordinateSystemAxis(Map.of(NAME_KEY, "X"), "X", 
AxisDirection.OTHER, Units.METRE),
              new DefaultCoordinateSystemAxis(Map.of(NAME_KEY, "Y"), "Y", 
AxisDirection.EAST,  Units.METRE),
              new DefaultCoordinateSystemAxis(Map.of(NAME_KEY, "Z"), "Z", 
AxisDirection.NORTH, Units.METRE));
  
diff --cc 
endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/internal/VerticalDatumTypes.java
index 416435cccb,b209366666..d7ff9b2036
--- 
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
@@@ -16,12 -16,11 +16,12 @@@
   */
  package org.apache.sis.referencing.internal;
  
+ import java.util.Locale;
  import java.util.Collection;
- import java.util.function.Predicate;
  import javax.measure.Unit;
- import org.opengis.util.CodeList;
  import org.opengis.util.GenericName;
+ import org.opengis.referencing.datum.RealizationMethod;
 +import org.opengis.referencing.datum.VerticalDatumType;
  import org.opengis.referencing.cs.CoordinateSystemAxis;
  import org.opengis.referencing.cs.AxisDirection;
  import org.apache.sis.util.Characters;
@@@ -32,7 -29,8 +30,8 @@@ import org.apache.sis.measure.Units
  
  
  /**
-  * Extensions to the standard set of {@link VerticalDatumType}.
+  * Extensions to the standard set of {@link RealizationEpoch}.
 - * Some of those constants are derived from a legacy {@code 
VerticalDatumType} code list.
++ * Some of those constants are derived from a legacy {@link 
VerticalDatumType} code list.
   * Those constants are not in public API because they were intentionally 
omitted from ISO 19111,
   * and the ISO experts said that they should really not be public.
   *
@@@ -105,29 -105,63 +106,68 @@@ public final class VerticalDatumTypes 
      }
  
      /**
-      * Returns the legacy code for the datum type, or 0 if unknown.
+      * Returns the legacy code for the datum type, or 2000 (other surface) if 
unknown.
       * This method is used for WKT 1 formatting.
       *
 -     * @param  method  the realization method, or {@code null} if unknown.
 +     * @param  type  the vertical datum type, or {@code null} if unknown.
       * @return the legacy code for the given datum type, or 0 if unknown.
       */
 -    public static int toLegacy(final RealizationMethod method) {
 -        if (method != null) {
 -            switch (method.name()) {
++    @SuppressWarnings("deprecation")
 +    public static int toLegacy(final VerticalDatumType type) {
 +        if (type != null) {
-             final int ordinal = type.ordinal();
-             if (ordinal >= 0 && ordinal < LEGACY_CODES.length) {
-                 return LEGACY_CODES[ordinal];
++            switch (type.name()) {
+                 case ORTHOMETRIC: return 2001;      // CS_VD_Orthometric
+                 case ELLIPSOIDAL: return 2002;      // CS_VD_Ellipsoidal
+                 case BAROMETRIC:  return 2003;      // 
CS_VD_AltitudeBarometric
 -                case "GEOID":     return 2005;      // CS_VD_GeoidModelDerived
 -                case "TIDAL":     return 2006;      // CS_VD_Depth
++                case "GEOIDAL":   return 2005;      // CS_VD_GeoidModelDerived
++                case "DEPTH":     return 2006;      // CS_VD_Depth
              }
          }
-         return 0;
+         return 2000;
      }
  
      /**
-      * Guesses the type of a datum from its name, aliases or a given vertical 
axis. This is sometimes needed
-      * after XML unmarshalling or WKT parsing, since GML 3.2 and ISO 19162 do 
not contain any attribute for
-      * the datum type.
+      * 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.
       *
-      * <p>This method uses heuristic rules and may be changed in any future 
SIS version.
-      * If the type cannot be determined, defaults to {@link 
VerticalDatumType#OTHER_SURFACE}.</p>
+      * @param  method  the realization method, or {@code null}.
 -     * @return the vertical datum type name (never null).
++     * @return the vertical datum type (never null).
+      */
 -    public static String toName(final RealizationMethod method) {
 -        if (method == RealizationMethod.GEOID) return "geoidal";
 -        if (method == RealizationMethod.TIDAL) return "depth";
++    @SuppressWarnings("deprecation")
++    public static VerticalDatumType fromMethod(final RealizationMethod 
method) {
++        if (method == RealizationMethod.GEOID) return 
VerticalDatumType.GEOIDAL;
++        if (method == RealizationMethod.TIDAL) return VerticalDatumType.DEPTH;
+         if (method != null) {
 -            return method.name().toLowerCase(Locale.US);
++            return 
VerticalDatumType.valueOf(method.name().toUpperCase(Locale.US));
+         }
 -        return "other surface";
++        return VerticalDatumType.OTHER_SURFACE;
+     }
+ 
+     /**
+      * Returns the realization method from a name.
+      *
+      * @param  type  the vertical datum type, or {@code null}.
+      * @return the realization method, or {@code null} if none.
+      */
 -    public static RealizationMethod fromName(final String type) {
 -        if ("GEOIDAL"  .equalsIgnoreCase(type)) return 
RealizationMethod.GEOID;
 -        if ("DEPTH"    .equalsIgnoreCase(type)) return 
RealizationMethod.TIDAL;
 -        if (BAROMETRIC .equalsIgnoreCase(type)) return 
RealizationMethod.valueOf(BAROMETRIC);
 -        if (ORTHOMETRIC.equalsIgnoreCase(type)) return 
RealizationMethod.valueOf(ORTHOMETRIC);
 -        if (ELLIPSOIDAL.equalsIgnoreCase(type)) return ellipsoidal();
++    @SuppressWarnings("deprecation")
++    public static RealizationMethod toMethod(final VerticalDatumType type) {
++        if (type != null) {
++            if (type == VerticalDatumType.GEOIDAL)         return 
RealizationMethod.GEOID;
++            if (type == VerticalDatumType.DEPTH)           return 
RealizationMethod.TIDAL;
++            if (type == VerticalDatumType.BAROMETRIC)      return 
RealizationMethod.valueOf(BAROMETRIC);
++            if (ORTHOMETRIC.equalsIgnoreCase(type.name())) return 
RealizationMethod.valueOf(ORTHOMETRIC);
++            if (ELLIPSOIDAL.equalsIgnoreCase(type.name())) return 
ellipsoidal();
++        }
+         return null;
+     }
+ 
+     /**
+      * Guesses the realization method of a datum from its name, aliases or a 
given vertical axis.
+      * This is sometimes needed after XML unmarshalling or WKT parsing, 
because GML 3.2 and ISO 19162
+      * do not contain any attribute for the datum type.
+      *
+      * <p>This method uses heuristic rules and may be changed in any future 
SIS version.</p>
       *
       * @param  name     the name of the datum for which to guess a type, or 
{@code null} if unknown.
       * @param  aliases  the aliases of the datum for which to guess a type, 
or {@code null} if unknown.
diff --cc 
endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/privy/AxisDirections.java
index 9a42c857f1,aa443b4110..4671df63a3
--- 
a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/privy/AxisDirections.java
+++ 
b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/privy/AxisDirections.java
@@@ -103,13 -103,13 +103,15 @@@ public final class AxisDirections exten
      /**
       * Proposed abbreviations for some axis directions.
       */
++    @SuppressWarnings("deprecation")
      private static final Map<AxisDirection,String> ABBREVIATIONS = Map.of(
              FUTURE,            "t",
              COLUMN_POSITIVE,   "i",
              ROW_POSITIVE,      "j",
              DISPLAY_RIGHT,     "x",
              DISPLAY_UP,        "y",
-             OTHER,             "z",     // Arbitrary abbreviation, may change 
in any future SIS version.
+             UNSPECIFIED,       "m",     // Arbitrary abbreviation, may change 
in any future SIS version.
++            OTHER,             "m",     // Idem.
              AWAY_FROM,         "r",
              COUNTER_CLOCKWISE, "θ");
  
diff --cc 
endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/cs/NormalizerTest.java
index 3a6b0585e8,28ff4bb908..4b8a95d56c
--- 
a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/cs/NormalizerTest.java
+++ 
b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/cs/NormalizerTest.java
@@@ -113,9 -114,9 +113,10 @@@ public final class NormalizerTest exten
       * with axes of legacy (WKT 1) axes.
       */
      @Test
++    @SuppressWarnings("deprecation")
      public void testSortWKT1() {
          assertOrdered(new AxisDirection[] {
 -            Legacy.OTHER,
 +            AxisDirection.OTHER,
              AxisDirection.EAST,
              AxisDirection.NORTH
          }, new AxisDirection[] {
diff --cc 
endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/internal/VerticalDatumTypesTest.java
index 8a92099e5a,4061d9b3c4..98bc4ab01d
--- 
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
@@@ -16,7 -16,7 +16,8 @@@
   */
  package org.apache.sis.referencing.internal;
  
+ import org.opengis.referencing.datum.RealizationMethod;
 +import org.opengis.referencing.datum.VerticalDatumType;
  import org.apache.sis.util.ArraysExt;
  
  // Test dependencies
@@@ -53,9 -53,9 +54,9 @@@ public final class VerticalDatumTypesTe
       */
      @Test
      public void testToLegacy() {
-         assertEquals(2002, 
VerticalDatumTypes.toLegacy(VerticalDatumTypes.ELLIPSOIDAL));
-         assertEquals(2005, VerticalDatumTypes.toLegacy(VerticalDatumType 
.GEOIDAL));
-         assertEquals(2006, VerticalDatumTypes.toLegacy(VerticalDatumType 
.DEPTH));
 -        assertEquals(2002, 
VerticalDatumTypes.toLegacy(VerticalDatumTypes.ellipsoidal()));
 -        assertEquals(2005, VerticalDatumTypes.toLegacy(RealizationMethod 
.GEOID));
 -        assertEquals(2006, VerticalDatumTypes.toLegacy(RealizationMethod 
.TIDAL));
++        assertEquals(2002, 
VerticalDatumTypes.toLegacy(VerticalDatumType.valueOf("ELLIPSOIDAL")));
++        assertEquals(2005, 
VerticalDatumTypes.toLegacy(VerticalDatumType.GEOIDAL));
++        assertEquals(2006, 
VerticalDatumTypes.toLegacy(VerticalDatumType.DEPTH));
      }
  
      /**
diff --cc geoapi/snapshot
index 0eadc94db1,42382222dc..44a967c172
--- a/geoapi/snapshot
+++ b/geoapi/snapshot
@@@ -1,1 -1,1 +1,1 @@@
- Subproject commit 0eadc94db1598764a6b96ed990a41ef92c502748
 -Subproject commit 42382222dc30ef4158fb58cc96e1a517d2c44a6b
++Subproject commit 44a967c1724aa88a540e007e1000b1a172067b63

Reply via email to