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 8eaaa32  "France geocentric interpolation" is renamed "Geocentric 
translation by Grid Interpolation (IGN)" in recent EPSG geodetic dataset. The 
new operation has additional parameters that are references EPSG codes. Those 
new parameters need to be handled in a special way in `EPSGDataAccess`.
8eaaa32 is described below

commit 8eaaa320159dc95a1c34725cbb3fffba22ca1678
Author: Martin Desruisseaux <martin.desruisse...@geomatys.com>
AuthorDate: Fri Sep 24 14:51:25 2021 +0200

    "France geocentric interpolation" is renamed "Geocentric translation by 
Grid Interpolation (IGN)" in recent EPSG geodetic dataset.
    The new operation has additional parameters that are references EPSG codes.
    Those new parameters need to be handled in a special way in 
`EPSGDataAccess`.
---
 .../provider/FranceGeocentricInterpolation.java    |  50 +++++++-
 .../internal/referencing/provider/Wraparound.java  |  21 +++-
 .../referencing/factory/sql/EPSGDataAccess.java    | 129 ++++++++++++---------
 .../provider/ParameterNameTableGenerator.java      |   3 +-
 4 files changed, 143 insertions(+), 60 deletions(-)

diff --git 
a/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/FranceGeocentricInterpolation.java
 
b/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/FranceGeocentricInterpolation.java
index 9620c7b..73435de 100644
--- 
a/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/FranceGeocentricInterpolation.java
+++ 
b/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/FranceGeocentricInterpolation.java
@@ -61,7 +61,8 @@ import static java.lang.Float.parseFloat;
 
 
 /**
- * The provider for <cite>"France geocentric interpolation"</cite> (ESPG:9655).
+ * The provider for <cite>"Geocentric translation by Grid Interpolation 
(IGN)"</cite> (EPSG:1087).
+ * This method replaces the deprecated <cite>"France geocentric 
interpolation"</cite> (ESPG:9655).
  * This operation requires a grid file provided by the French mapping agency.
  *
  * <p><b>Source:</b> IGN document {@code NTG_88.pdf},
@@ -154,6 +155,36 @@ public class FranceGeocentricInterpolation extends 
GeodeticOperation {
     public static final ParameterDescriptor<Path> FILE;
 
     /**
+     * The operation parameter descriptor for the <cite>EPSG code for 
Interpolation CRS</cite> parameter value.
+     * <!-- Generated by ParameterNameTableGenerator -->
+     * <table class="sis">
+     *   <caption>Parameter names</caption>
+     *   <tr><td> EPSG:    </td><td> EPSG code for Interpolation CRS </td></tr>
+     *   <tr><td> EPSG:    </td><td> Interpolation CRS code </td></tr>
+     * </table>
+     * <b>Notes:</b>
+     * <ul>
+     *   <li>No default value</li>
+     * </ul>
+     */
+    public static final ParameterDescriptor<Integer> INTERPOLATION_CRS;
+
+    /**
+     * The operation parameter descriptor for the <cite>EPSG code for 
"standard" CT</cite> parameter value.
+     * <!-- Generated by ParameterNameTableGenerator -->
+     * <table class="sis">
+     *   <caption>Parameter names</caption>
+     *   <tr><td> EPSG:    </td><td> EPSG code for "standard" CT </td></tr>
+     *   <tr><td> EPSG:    </td><td> Standard CT code </td></tr>
+     * </table>
+     * <b>Notes:</b>
+     * <ul>
+     *   <li>No default value</li>
+     * </ul>
+     */
+    public static final ParameterDescriptor<Integer> STANDARD_CT;
+
+    /**
      * The group of all parameters expected by this coordinate operation. The 
only parameter formally defined by EPSG
      * is {@link #FILE}. All other parameters have been taken from {@link 
Molodensky} since geocentric interpolations
      * can be though as a Molodensky operations with non-constant (ΔX, ΔY, ΔZ) 
geocentric translation terms.
@@ -165,15 +196,26 @@ public class FranceGeocentricInterpolation extends 
GeodeticOperation {
                 .addIdentifier("8727")
                 .addName("Geocentric translation file")
                 .create(Path.class, Paths.get(DEFAULT));
+        INTERPOLATION_CRS = builder
+                .addIdentifier("1048")
+                .addName("EPSG code for Interpolation CRS")
+                .addName("Interpolation CRS code")
+                .create(Integer.class, null);
+        STANDARD_CT = builder
+                .addIdentifier("1062")
+                .addName("EPSG code for \"standard\" CT")
+                .addName("Standard CT code")
+                .create(Integer.class, null);
         PARAMETERS = builder
-                .addIdentifier("9655")
-                .addName("France geocentric interpolation")
+                .addIdentifier("1087").addName("Geocentric translation by Grid 
Interpolation (IGN)")
+                .setDeprecated(true).addIdentifier("9655").addName("France 
geocentric interpolation")
+                .setDeprecated(false)
                 .createGroup(Molodensky.DIMENSION,              // Not an EPSG 
parameter.
                              Molodensky.SRC_SEMI_MAJOR,
                              Molodensky.SRC_SEMI_MINOR,
                              Molodensky.TGT_SEMI_MAJOR,
                              Molodensky.TGT_SEMI_MINOR,
-                             FILE);
+                             FILE, INTERPOLATION_CRS, STANDARD_CT);
     }
 
     /**
diff --git 
a/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/Wraparound.java
 
b/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/Wraparound.java
index fda2130..568799d 100644
--- 
a/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/Wraparound.java
+++ 
b/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/Wraparound.java
@@ -51,8 +51,13 @@ public final class Wraparound extends AbstractProvider {
      * <!-- Generated by ParameterNameTableGenerator -->
      * <table class="sis">
      *   <caption>Parameter names</caption>
-     *   <tr><td> OGC:    </td><td> dim </td></tr>
+     *   <tr><td> OGC:     </td><td> dim </td></tr>
      * </table>
+     * <b>Notes:</b>
+     * <ul>
+     *   <li>Value domain: [1…∞)</li>
+     *   <li>No default value</li>
+     * </ul>
      */
     public static final ParameterDescriptor<Integer> DIMENSION;
 
@@ -62,8 +67,13 @@ public final class Wraparound extends AbstractProvider {
      * <!-- Generated by ParameterNameTableGenerator -->
      * <table class="sis">
      *   <caption>Parameter names</caption>
-     *   <tr><td> SIS:    </td><td> wraparound_dim </td></tr>
+     *   <tr><td> SIS:     </td><td> wraparound_dim </td></tr>
      * </table>
+     * <b>Notes:</b>
+     * <ul>
+     *   <li>Value domain: [0…∞)</li>
+     *   <li>No default value</li>
+     * </ul>
      */
     public static final ParameterDescriptor<Integer> WRAPAROUND_DIMENSION;
 
@@ -73,8 +83,13 @@ public final class Wraparound extends AbstractProvider {
      * <!-- Generated by ParameterNameTableGenerator -->
      * <table class="sis">
      *   <caption>Parameter names</caption>
-     *   <tr><td> SIS:    </td><td> period </td></tr>
+     *   <tr><td> SIS:     </td><td> period </td></tr>
      * </table>
+     * <b>Notes:</b>
+     * <ul>
+     *   <li>Value domain: (0.0 … ∞)</li>
+     *   <li>No default value</li>
+     * </ul>
      */
     public static final ParameterDescriptor<Double> PERIOD;
 
diff --git 
a/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/sql/EPSGDataAccess.java
 
b/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/sql/EPSGDataAccess.java
index 9f6bce7..2159a90 100644
--- 
a/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/sql/EPSGDataAccess.java
+++ 
b/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/sql/EPSGDataAccess.java
@@ -16,6 +16,7 @@
  */
 package org.apache.sis.referencing.factory.sql;
 
+import java.util.Arrays;
 import java.util.Set;
 import java.util.Map;
 import java.util.List;
@@ -173,6 +174,16 @@ public class EPSGDataAccess extends 
GeodeticAuthorityFactory implements CRSAutho
     static final VerticalDatumType VERTICAL_DATUM_TYPE = 
VerticalDatumType.GEOIDAL;
 
     /**
+     * EPSG codes of parameters containing the EPSG code of another object.
+     * Those parameters are integers (stored as {@code double} in the database)
+     * without unit (associated to {@link Units#UNITY} in the database).
+     */
+    private static final int[] EPSG_CODE_PARAMETERS = {
+        1048,       // EPSG code for Interpolation CRS
+        1062        // EPSG code for "standard" CT
+    };
+
+    /**
      * The deprecated ellipsoidal coordinate systems and their replacements. 
Those coordinate systems are deprecated
      * because they use a unit of measurement which is no longer supported by 
OGC (for example degree-minute-second).
      * Those replacements can be used only if the ellipsoidal CS is used for 
the base geographic CRS of a derived or
@@ -2528,48 +2539,58 @@ codes:  for (int i=0; i<codes.length; i++) {
                 final String  name        = getString   (code, result, 2);
                 final String  description = getOptionalString (result, 3);
                 final boolean deprecated  = getOptionalBoolean(result, 4);
-                Class<?> type = Double.class;
                 /*
-                 * If the parameter appears to have at least one non-null 
value in the "Parameter File Name" column,
-                 * then the type is assumed to be URI as a string. Otherwise, 
the type is a floating point number.
+                 * If the parameter is an integer code, the type is integer 
and there is no unit.
                  */
-                try (ResultSet r = executeQuery("ParameterType",
-                        "SELECT PARAM_VALUE_FILE_REF FROM 
[Coordinate_Operation Parameter Value]" +
-                        " WHERE (PARAMETER_CODE = ?) AND PARAM_VALUE_FILE_REF 
IS NOT NULL", epsg))
-                {
-                    while (r.next()) {
-                        String element = getOptionalString(r, 1);
-                        if (element != null && !element.isEmpty()) {
-                            type = String.class;
-                            break;
+                Class<?> type;
+                final Set<Unit<?>> units;
+                if (epsg != null && Arrays.binarySearch(EPSG_CODE_PARAMETERS, 
epsg) >= 0) {
+                    type  = Integer.class;
+                    units = Collections.emptySet();
+                } else {
+                    /*
+                     * If the parameter appears to have at least one non-null 
value in the "Parameter File Name" column,
+                     * then the type is assumed to be URI as a string. 
Otherwise, the type is a floating point number.
+                     */
+                    type = Double.class;
+                    try (ResultSet r = executeQuery("ParameterType",
+                            "SELECT PARAM_VALUE_FILE_REF FROM 
[Coordinate_Operation Parameter Value]" +
+                            " WHERE (PARAMETER_CODE = ?) AND 
PARAM_VALUE_FILE_REF IS NOT NULL", epsg))
+                    {
+                        while (r.next()) {
+                            String element = getOptionalString(r, 1);
+                            if (element != null && !element.isEmpty()) {
+                                type = String.class;
+                                break;
+                            }
                         }
                     }
-                }
-                /*
-                 * Search for units.   We typically have many different units 
but all of the same dimension
-                 * (for example metres, kilometres, feet, etc.). In such case, 
the units Set will have only
-                 * one element and that element will be the most frequently 
used unit.  But some parameters
-                 * accept units of different dimensions. For example the 
"Coordinate 1 of evaluation point"
-                 * (EPSG:8617) parameter value may be in metres or in degrees. 
  In such case the units Set
-                 * will have two elements.
-                 */
-                final Set<Unit<?>> units = new LinkedHashSet<>();
-                try (ResultSet r = executeQuery("ParameterUnit",
-                        "SELECT UOM_CODE FROM [Coordinate_Operation Parameter 
Value]" +
-                        " WHERE (PARAMETER_CODE = ?)" +
-                        " GROUP BY UOM_CODE" +
-                        " ORDER BY COUNT(UOM_CODE) DESC", epsg))
-                {
-next:               while (r.next()) {
-                        final String c = getOptionalString(r, 1);
-                        if (c != null) {
-                            final Unit<?> candidate = owner.createUnit(c);
-                            for (final Unit<?> e : units) {
-                                if (candidate.isCompatible(e)) {
-                                    continue next;
+                    /*
+                     * Search for units.   We typically have many different 
units but all of the same dimension
+                     * (for example metres, kilometres, feet, etc.). In such 
case, the units Set will have only
+                     * one element and that element will be the most 
frequently used unit.  But some parameters
+                     * accept units of different dimensions. For example the 
"Coordinate 1 of evaluation point"
+                     * (EPSG:8617) parameter value may be in metres or in 
degrees.   In such case the units Set
+                     * will have two elements.
+                     */
+                    units = new LinkedHashSet<>();
+                    try (ResultSet r = executeQuery("ParameterUnit",
+                            "SELECT UOM_CODE FROM [Coordinate_Operation 
Parameter Value]" +
+                            " WHERE (PARAMETER_CODE = ?)" +
+                            " GROUP BY UOM_CODE" +
+                            " ORDER BY COUNT(UOM_CODE) DESC", epsg))
+                    {
+next:                   while (r.next()) {
+                            final String c = getOptionalString(r, 1);
+                            if (c != null) {
+                                final Unit<?> candidate = owner.createUnit(c);
+                                for (final Unit<?> e : units) {
+                                    if (candidate.isCompatible(e)) {
+                                        continue next;
+                                    }
                                 }
+                                units.add(candidate);
                             }
-                            units.add(candidate);
                         }
                     }
                 }
@@ -2676,22 +2697,7 @@ next:               while (r.next()) {
              " ORDER BY CU.SORT_ORDER", method, operation))
         {
             while (result.next()) {
-                final String name  = getString(operation, result, 1);
-                final double value = getOptionalDouble(result, 2);
-                final Unit<?> unit;
-                String reference;
-                if (Double.isNaN(value)) {
-                    /*
-                     * If no numeric values were provided in the database, 
then the values should be
-                     * in some external file. It may be a file in the 
$SIS_DATA/DatumChanges directory.
-                     */
-                    reference = getString(operation, result, 3);
-                    unit = null;
-                } else {
-                    reference = null;
-                    final String unitCode = getOptionalString(result, 4);
-                    unit = (unitCode != null) ? owner.createUnit(unitCode) : 
null;
-                }
+                final String name = getString(operation, result, 1);
                 final ParameterValue<?> param;
                 try {
                     param = parameters.parameter(name);
@@ -2709,6 +2715,25 @@ next:               while (r.next()) {
                     throw (NoSuchIdentifierException) new 
NoSuchIdentifierException(error().getString(
                             Errors.Keys.CanNotSetParameterValue_1, name), 
name).initCause(exception);
                 }
+                final double value = getOptionalDouble(result, 2);
+                Unit<?> unit = null;
+                String reference;
+                if (Double.isNaN(value)) {
+                    /*
+                     * If no numeric values were provided in the database, 
then the values should be
+                     * in some external file. It may be a file in the 
$SIS_DATA/DatumChanges directory.
+                     */
+                    reference = getString(operation, result, 3);
+                } else {
+                    reference = null;
+                    final String unitCode = getOptionalString(result, 4);
+                    if (unitCode != null) {
+                        unit = owner.createUnit(unitCode);
+                        if (Units.UNITY.equals(unit) && param.getUnit() == 
null) {
+                            unit = null;
+                        }
+                    }
+                }
                 try {
                     if (reference != null) {
                         param.setValue(reference);
diff --git 
a/core/sis-referencing/src/test/java/org/apache/sis/internal/referencing/provider/ParameterNameTableGenerator.java
 
b/core/sis-referencing/src/test/java/org/apache/sis/internal/referencing/provider/ParameterNameTableGenerator.java
index ca3b881..5bb2788 100644
--- 
a/core/sis-referencing/src/test/java/org/apache/sis/internal/referencing/provider/ParameterNameTableGenerator.java
+++ 
b/core/sis-referencing/src/test/java/org/apache/sis/internal/referencing/provider/ParameterNameTableGenerator.java
@@ -29,6 +29,7 @@ import java.nio.file.attribute.BasicFileAttributes;
 import javax.measure.Unit;
 import org.opengis.util.GenericName;
 import org.opengis.metadata.Identifier;
+import org.apache.sis.referencing.NamedIdentifier;
 import org.apache.sis.parameter.DefaultParameterDescriptor;
 import org.apache.sis.test.ProjectDirectories;
 import org.apache.sis.internal.jdk9.JDK9;
@@ -202,7 +203,7 @@ public final class ParameterNameTableGenerator extends 
SimpleFileVisitor<Path> {
                 write(insertAt++, "  <caption>Parameter names</caption>");
                 write(insertAt++, descriptor.getName());
                 for (final GenericName alias : descriptor.getAlias()) {
-                    write(insertAt++, (Identifier) alias);
+                    write(insertAt++, (alias instanceof Identifier) ? 
(Identifier) alias : new NamedIdentifier(alias));
                 }
                 write(insertAt++, "</table>");
                 /*

Reply via email to