sis-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From desruisse...@apache.org
Subject [sis] 07/09: Reduce the numbers of authorities declared in the ESRI-specific projections: limit to ESRI, OGC and Proj4.
Date Tue, 01 Oct 2019 17:25:18 GMT
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 6274488fad7169664133c5ee1fa8e8cca0a84533
Author: Martin Desruisseaux <martin.desruisseaux@geomatys.com>
AuthorDate: Tue Oct 1 16:41:27 2019 +0200

    Reduce the numbers of authorities declared in the ESRI-specific projections: limit to
ESRI, OGC and Proj4.
---
 .../sis/internal/referencing/provider/ESRI.java    | 59 ++++++++++++++--------
 .../referencing/provider/MapProjection.java        | 55 ++++----------------
 .../provider/PolarStereographicSouth.java          |  4 +-
 3 files changed, 50 insertions(+), 68 deletions(-)

diff --git a/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/ESRI.java
b/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/ESRI.java
index 8469888..7510166 100644
--- a/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/ESRI.java
+++ b/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/ESRI.java
@@ -17,29 +17,49 @@
 package org.apache.sis.internal.referencing.provider;
 
 import org.opengis.parameter.ParameterDescriptor;
-import org.apache.sis.parameter.DefaultParameterDescriptor;
 import org.apache.sis.parameter.ParameterBuilder;
-import org.apache.sis.measure.MeasurementRange;
 import org.apache.sis.metadata.iso.citation.Citations;
 import org.apache.sis.util.Static;
 
 
 /**
  * Constants for projections defined by ESRI but not by EPSG.
+ * Also used for some projections not defined by ESRI, but in which we reuse ESRI parameters.
+ * A characteristics of ESRI parameters is that they have the same name for all projections
+ * (at least all the ones supported by SIS). A similar pattern is observed with OGC parameters,
+ * which are close to ESRI ones.
  *
  * @author  Martin Desruisseaux (Geomatys)
- * @version 1.0
+ * @version 1.1
  * @since   1.0
  * @module
  */
 final class ESRI extends Static {
     /**
-     * The operation parameter descriptor for the <cite>Longitude of natural origin</cite>
(λ₀) parameter value.
+     * The operation parameter descriptor for the <cite>Longitude of origin</cite>
(λ₀) parameter value.
      * Valid values range is [-180 … 180]° and default value is 0°.
      */
     static final ParameterDescriptor<Double> CENTRAL_MERIDIAN;
 
     /**
+     * The operation parameter descriptor for the <cite>Latitude of origin</cite>
(φ₀) parameter value.
+     * Valid values range is (-90 … 90)° and default value is 0°.
+     */
+    static final ParameterDescriptor<Double> LATITUDE_OF_ORIGIN;
+
+    /**
+     * The operation parameter descriptor for the <cite>Latitude of 1st standard parallel</cite>
parameter value.
+     * Valid values range is [-90 … 90]° and default value is 0°.
+     */
+    static final ParameterDescriptor<Double> STANDARD_PARALLEL_1;
+
+    /**
+     * The operation parameter descriptor for the <cite>Latitude of 2nd standard parallel</cite>
parameter value.
+     * Valid values range is [-90 … 90]° and default value is 0°.
+     */
+    static final ParameterDescriptor<Double> STANDARD_PARALLEL_2;
+
+    /**
      * The operation parameter descriptor for the <cite>False easting</cite>
(FE) parameter value.
      * Valid values range is unrestricted and default value is 0 metre.
      */
@@ -52,14 +72,12 @@ final class ESRI extends Static {
     static final ParameterDescriptor<Double> FALSE_NORTHING;
     static {
         final ParameterBuilder builder = MapProjection.builder();
-        FALSE_EASTING  = asPrimary(Equirectangular.FALSE_EASTING,  builder);
-        FALSE_NORTHING = asPrimary(Equirectangular.FALSE_NORTHING, builder);
-
-        final ParameterDescriptor<Double> template = Equirectangular.LONGITUDE_OF_ORIGIN;
-        CENTRAL_MERIDIAN = MapProjection.createLongitude(builder
-                .addName(MapProjection.sameNameAs(Citations.ESRI,  template))
-                .addName(MapProjection.sameNameAs(Citations.OGC,   template))
-                .addName(MapProjection.sameNameAs(Citations.PROJ4, template)));
+        CENTRAL_MERIDIAN    = MapProjection.createLongitude(copyNames(builder, Equirectangular.LONGITUDE_OF_ORIGIN));
+        LATITUDE_OF_ORIGIN  = MapProjection.createLatitude (copyNames(builder, Equirectangular.LATITUDE_OF_ORIGIN),
true);
+        STANDARD_PARALLEL_1 = MapProjection.createLatitude (copyNames(builder, LambertConformal2SP.STANDARD_PARALLEL_1),
true);
+        STANDARD_PARALLEL_2 = MapProjection.createLatitude (copyNames(builder, LambertConformal2SP.STANDARD_PARALLEL_2),
true);
+        FALSE_EASTING       = MapProjection.createShift    (copyNames(builder, Equirectangular.FALSE_EASTING));
+        FALSE_NORTHING      = MapProjection.createShift    (copyNames(builder, Equirectangular.FALSE_NORTHING));
     }
 
     /**
@@ -69,17 +87,18 @@ final class ESRI extends Static {
     }
 
     /**
-     * Returns the same parameter than the given one, except that the alias of the ESRI authority
-     * is promoted as the primary name. The old primary name and identifiers (which are usually
the
-     * EPSG ones) are discarded.
+     * Copies the ESRI, OGC and PROJ4 names from the given parameters to the given builder.
+     * Those parameters are selected because those authorities use the same names in all
projections.
+     * The EPSG name is discarded because the name varies depending in the projection, in
attempts to
+     * describe more precisely what they are for.
      *
+     * @param  builder   the builder where to add the names.
      * @param  template  the parameter from which to copy the names and identifiers.
-     * @param  builder   an initially clean builder where to add the names.
      * @return the given {@code builder}, for method call chaining.
      */
-    @SuppressWarnings("unchecked")
-    static ParameterDescriptor<Double> asPrimary(final ParameterDescriptor<Double>
template, final ParameterBuilder builder) {
-        return MapProjection.alternativeAuthority(template, Citations.ESRI, builder).createBounded((MeasurementRange<Double>)
-                ((DefaultParameterDescriptor<Double>) template).getValueDomain(), template.getDefaultValue());
+    static ParameterBuilder copyNames(final ParameterBuilder builder, final ParameterDescriptor<Double>
template) {
+        return builder.addName(MapProjection.sameNameAs(Citations.ESRI,  template))
+                      .addName(MapProjection.sameNameAs(Citations.OGC,   template))
+                      .addName(MapProjection.sameNameAs(Citations.PROJ4, template));
     }
 }
diff --git a/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/MapProjection.java
b/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/MapProjection.java
index 5efd1ea..d553ebf 100644
--- a/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/MapProjection.java
+++ b/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/MapProjection.java
@@ -59,7 +59,7 @@ import static org.opengis.metadata.Identifier.AUTHORITY_KEY;
  * {@linkplain ParameterDescriptorGroup descriptor group} named {@code PARAMETERS}.
  *
  * @author  Martin Desruisseaux (Geomatys)
- * @version 0.8
+ * @version 1.1
  * @since   0.6
  * @module
  */
@@ -292,36 +292,19 @@ public abstract class MapProjection extends AbstractProvider {
     static ParameterBuilder renameAlias(final ParameterDescriptor<Double> template,
final Citation toRename,
             final ParameterDescriptor<Double> replacement, final ParameterBuilder builder)
     {
-        return copyAliases(template, toRename, sameNameAs(toRename, replacement),
-                IdentifiedObjects.getIdentifier(replacement, toRename), builder.addName(template.getName()));
-    }
-
-    /**
-     * Copies all aliases except the ones for the given authority. If the given replacement
is non-null,
-     * then it will be used instead of the first occurrence of the omitted name.
-     *
-     * <p>This method does not copy the primary name. It is caller's responsibility
to add it first.</p>
-     *
-     * @param  template     the parameter from which to copy the aliases.
-     * @param  exclude      the authority of the alias to omit. Can not be EPSG.
-     * @param  replacement  the alias to use instead of the omitted one, or {@code null}
if none.
-     * @param  newCode      the identifier to use instead of the omitted one, or {@code null}
if none.
-     * @param  builder      where to add the aliases.
-     * @return the given {@code builder}, for method call chaining.
-     */
-    private static ParameterBuilder copyAliases(final ParameterDescriptor<Double> template,
final Citation exclude,
-            GenericName replacement, Identifier newCode, final ParameterBuilder builder)
-    {
+        builder.addName(template.getName());
+        GenericName newName = sameNameAs(toRename, replacement);
+        Identifier newCode = IdentifiedObjects.getIdentifier(replacement, toRename);
         for (GenericName alias : template.getAlias()) {
-            if (((Identifier) alias).getAuthority() == exclude) {
-                if (replacement == null) continue;
-                alias = replacement;
-                replacement = null;
+            if (((Identifier) alias).getAuthority() == toRename) {
+                if (newName == null) continue;
+                alias = newName;
+                newName = null;
             }
             builder.addName(alias);
         }
         for (Identifier id : template.getIdentifiers()) {
-            if (id.getAuthority() == exclude) {
+            if (id.getAuthority() == toRename) {
                 if (newCode == null) continue;
                 id = newCode;
                 newCode = null;
@@ -332,26 +315,6 @@ public abstract class MapProjection extends AbstractProvider {
     }
 
     /**
-     * Copies all aliases and all identifiers except EPSG, but using the alias specified
by the given authority
-     * as the primary name. The old primary name (usually the EPSG name) is discarded.
-     *
-     * <p>This is a convenience method for defining the parameters of an ESRI-specific
(or any other authority)
-     * projection using the EPSG parameters as template.</p>
-     *
-     * @param  template    the parameter from which to copy the names.
-     * @param  authority   the authority to use for the primary name.
-     * @param  builder     an initially clean builder where to add the names.
-     * @return the given {@code builder}, for method call chaining.
-     *
-     * @since 0.8
-     */
-    static ParameterBuilder alternativeAuthority(final ParameterDescriptor<Double>
template,
-            final Citation authority, final ParameterBuilder builder)
-    {
-        return copyAliases(template, authority, null, null, builder.addName(sameNameAs(authority,
template)));
-    }
-
-    /**
      * Creates a remarks for parameters that are not formally EPSG parameter.
      *
      * @param  origin  the name of the projection for where the parameter is formally used.
diff --git a/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/PolarStereographicSouth.java
b/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/PolarStereographicSouth.java
index d06fbbe..86069eb 100644
--- a/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/PolarStereographicSouth.java
+++ b/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/PolarStereographicSouth.java
@@ -48,12 +48,12 @@ public final class PolarStereographicSouth extends AbstractStereographic
{
     static {
         final ParameterBuilder builder = builder();
         final ParameterDescriptor<Double> standardParallel =
-                alternativeAuthority(PolarStereographicB.STANDARD_PARALLEL, Citations.ESRI,
builder)
+                ESRI.copyNames(builder, PolarStereographicB.STANDARD_PARALLEL)
                 .createBounded(Latitude.MIN_VALUE, 0, Latitude.MIN_VALUE, Units.DEGREE);
 
         final ParameterDescriptor<?>[] parameters = {
             standardParallel,
-            ESRI.asPrimary(PolarStereographicB.LONGITUDE_OF_ORIGIN, builder),
+            ESRI.CENTRAL_MERIDIAN,
             PolarStereographicB.SCALE_FACTOR,                       // Not formally a parameter
of this projection.
             ESRI.FALSE_EASTING,
             ESRI.FALSE_NORTHING


Mime
View raw message