You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sis.apache.org by de...@apache.org on 2020/04/11 21:18:25 UTC

[sis] 02/03: Check for spherical case in Modified Azimuthal Equidistant projection.

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 be8e094dec6076216c2c085fda72cbca9838c4e3
Author: Martin Desruisseaux <ma...@geomatys.com>
AuthorDate: Sat Apr 11 16:30:29 2020 +0200

    Check for spherical case in Modified Azimuthal Equidistant projection.
---
 .../operation/projection/AzimuthalEquidistant.java |  9 ++++++++
 .../projection/ModifiedAzimuthalEquidistant.java   | 24 ++++++++++++++++++++++
 2 files changed, 33 insertions(+)

diff --git a/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/projection/AzimuthalEquidistant.java b/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/projection/AzimuthalEquidistant.java
index 987ac81..0b81153 100644
--- a/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/projection/AzimuthalEquidistant.java
+++ b/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/projection/AzimuthalEquidistant.java
@@ -125,6 +125,15 @@ public class AzimuthalEquidistant extends NormalizedProjection {
     }
 
     /**
+     * Creates a new projection initialized to the same parameters than the given one.
+     */
+    AzimuthalEquidistant(final AzimuthalEquidistant other) {
+        super(other);
+        cosφ0 = other.cosφ0;
+        sinφ0 = other.sinφ0;
+    }
+
+    /**
      * Returns the names of additional internal parameters which need to be taken in account when
      * comparing two {@code AzimuthalEquidistant} projections or formatting them in debug mode.
      *
diff --git a/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/projection/ModifiedAzimuthalEquidistant.java b/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/projection/ModifiedAzimuthalEquidistant.java
index 811eb49..a711f66 100644
--- a/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/projection/ModifiedAzimuthalEquidistant.java
+++ b/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/projection/ModifiedAzimuthalEquidistant.java
@@ -17,7 +17,10 @@
 package org.apache.sis.referencing.operation.projection;
 
 import java.util.EnumMap;
+import org.opengis.util.FactoryException;
 import org.opengis.referencing.operation.Matrix;
+import org.opengis.referencing.operation.MathTransform;
+import org.opengis.referencing.operation.MathTransformFactory;
 import org.opengis.referencing.operation.OperationMethod;
 import org.opengis.parameter.ParameterDescriptor;
 import org.apache.sis.parameter.Parameters;
@@ -124,6 +127,27 @@ public class ModifiedAzimuthalEquidistant extends AzimuthalEquidistant {
     }
 
     /**
+     * Returns the sequence of <cite>normalization</cite> → {@code this} → <cite>denormalization</cite> transforms
+     * as a whole. The transform returned by this method expects (<var>longitude</var>, <var>latitude</var>)
+     * coordinates in <em>degrees</em> and returns (<var>x</var>,<var>y</var>) coordinates in <em>metres</em>.
+     *
+     * <p>The non-linear part of the returned transform will be {@code this} transform, except if the ellipsoid
+     * is spherical. In the later case, {@code this} transform will be replaced by a simplified implementation.</p>
+     *
+     * @param  factory  the factory to use for creating the transform.
+     * @return the map projection from (λ,φ) to (<var>x</var>,<var>y</var>) coordinates.
+     * @throws FactoryException if an error occurred while creating a transform.
+     */
+    @Override
+    public MathTransform createMapProjection(final MathTransformFactory factory) throws FactoryException {
+        AzimuthalEquidistant kernel = this;
+        if (eccentricity == 0) {
+            kernel = new AzimuthalEquidistant(this);
+        }
+        return context.completeTransform(factory, kernel);
+    }
+
+    /**
      * Converts the specified (λ,φ) coordinate and stores the (<var>x</var>,<var>y</var>) result in {@code dstPts}.
      *
      * @return the matrix of the projection derivative at the given source position,