sis-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From desruisse...@apache.org
Subject svn commit: r1709564 - in /sis/branches/JDK8/core/sis-referencing/src: main/java/org/apache/sis/internal/referencing/provider/ main/java/org/apache/sis/parameter/ main/java/org/apache/sis/referencing/operation/ main/java/org/apache/sis/referencing/oper...
Date Tue, 20 Oct 2015 10:34:13 GMT
Author: desruisseaux
Date: Tue Oct 20 10:34:13 2015
New Revision: 1709564

URL: http://svn.apache.org/viewvc?rev=1709564&view=rev
Log:
Allow ObliqueStereographic to delegate to PolarStereographic when the latitude of origin is
a pole.
Register the ObliqueStereographic projection on the list of supported projections.

Modified:
    sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/PolarStereographicA.java
    sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/parameter/MapProjectionParameters.java
    sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/DefaultCoordinateOperationFactory.java
    sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/projection/NormalizedProjection.java
    sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/projection/ObliqueStereographic.java
    sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/projection/PolarStereographic.java
    sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/ContextualParameters.java
    sis/branches/JDK8/core/sis-referencing/src/main/resources/META-INF/services/org.opengis.referencing.operation.OperationMethod
    sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/projection/ObliqueStereographicTest.java

Modified: sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/PolarStereographicA.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/PolarStereographicA.java?rev=1709564&r1=1709563&r2=1709564&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/PolarStereographicA.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/PolarStereographicA.java
[UTF-8] Tue Oct 20 10:34:13 2015
@@ -29,7 +29,7 @@ import org.apache.sis.parameter.Paramete
  * @author  Rueben Schulz (UBC)
  * @author  Martin Desruisseaux (Geomatys)
  * @since   0.6
- * @version 0.6
+ * @version 0.7
  * @module
  *
  * @see <a href="http://www.remotesensing.org/geotiff/proj_list/polar_stereographic.html">Polar
Stereographic on RemoteSensing.org</a>
@@ -42,6 +42,11 @@ public final class PolarStereographicA e
     private static final long serialVersionUID = 538262714055500925L;
 
     /**
+     * The EPSG name for this projection.
+     */
+    public static final String NAME = "Polar Stereographic (variant A)";
+
+    /**
      * The EPSG identifier, to be preferred to the name when available.
      */
     public static final String IDENTIFIER = "9810";
@@ -70,7 +75,7 @@ public final class PolarStereographicA e
 
         PARAMETERS = builder
             .addIdentifier(             IDENTIFIER)
-            .addName(                   "Polar Stereographic (variant A)")
+            .addName(                   NAME)
             .addName(Citations.OGC,     "Polar_Stereographic")
             .addName(Citations.GEOTIFF, "CT_PolarStereographic")
             .addName(Citations.PROJ4,   "stere")

Modified: sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/parameter/MapProjectionParameters.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/parameter/MapProjectionParameters.java?rev=1709564&r1=1709563&r2=1709564&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/parameter/MapProjectionParameters.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/parameter/MapProjectionParameters.java
[UTF-8] Tue Oct 20 10:34:13 2015
@@ -371,7 +371,7 @@ final class MapProjectionParameters exte
          * This is not a standard parameter.
          */
         static final ParameterDescriptor<Boolean> DESCRIPTOR = new DefaultParameterDescriptor<>(
-                InverseFlattening.toMap(Constants.IS_IVF_DEFINITIVE), 0, 1, Boolean.class,
null, null, null);
+                InverseFlattening.toMap(Constants.IS_IVF_DEFINITIVE), 0, 1, Boolean.class,
null, null, Boolean.FALSE);
 
         /**
          * The parameters for the inverse flattening factor.

Modified: sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/DefaultCoordinateOperationFactory.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/DefaultCoordinateOperationFactory.java?rev=1709564&r1=1709563&r2=1709564&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/DefaultCoordinateOperationFactory.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/DefaultCoordinateOperationFactory.java
[UTF-8] Tue Oct 20 10:34:13 2015
@@ -175,12 +175,12 @@ public class DefaultCoordinateOperationF
      */
     @Override
     public OperationMethod getOperationMethod(String name) throws FactoryException {
+        name = CharSequences.trimWhitespaces(name);
+        ArgumentChecks.ensureNonEmpty("name", name);
         final MathTransformFactory mtFactory = getMathTransformFactory();
         if (mtFactory instanceof DefaultMathTransformFactory) {
             return ((DefaultMathTransformFactory) mtFactory).getOperationMethod(name);
         }
-        name = CharSequences.trimWhitespaces(name);
-        ArgumentChecks.ensureNonEmpty("name", name);
         final OperationMethod method = ReferencingServices.getInstance().getOperationMethod(
                 mtFactory.getAvailableMethods(SingleOperation.class), name);
         if (method != null) {

Modified: sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/projection/NormalizedProjection.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/projection/NormalizedProjection.java?rev=1709564&r1=1709563&r2=1709564&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/projection/NormalizedProjection.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/projection/NormalizedProjection.java
[UTF-8] Tue Oct 20 10:34:13 2015
@@ -27,6 +27,7 @@ import org.opengis.parameter.ParameterDe
 import org.opengis.referencing.operation.Matrix;
 import org.opengis.referencing.operation.MathTransform;
 import org.opengis.referencing.operation.MathTransform2D;
+import org.opengis.referencing.operation.SingleOperation;
 import org.opengis.referencing.operation.OperationMethod;
 import org.opengis.referencing.operation.TransformException;
 import org.opengis.referencing.operation.MathTransformFactory;
@@ -41,11 +42,15 @@ import org.apache.sis.referencing.operat
 import org.apache.sis.referencing.operation.matrix.MatrixSIS;
 import org.apache.sis.referencing.operation.transform.AbstractMathTransform2D;
 import org.apache.sis.referencing.operation.transform.ContextualParameters;
+import org.apache.sis.referencing.operation.transform.DefaultMathTransformFactory;
+import org.apache.sis.referencing.operation.transform.MathTransformProvider;
+import org.apache.sis.internal.metadata.ReferencingServices;
 import org.apache.sis.internal.referencing.Formulas;
 import org.apache.sis.internal.util.CollectionsExt;
 import org.apache.sis.internal.util.Constants;
 import org.apache.sis.internal.util.Utilities;
 import org.apache.sis.internal.util.Numerics;
+import org.apache.sis.util.resources.Errors;
 
 import static java.lang.Math.*;
 
@@ -481,6 +486,43 @@ public abstract class NormalizedProjecti
     }
 
     /**
+     * If this map projection can not handle the parameters given by the user but an other
projection could, delegates
+     * to the other projection. This method can be invoked by some {@link #createMapProjection(MathTransformFactory)}
+     * implementations when the other projection can be seen as a special case.
+     *
+     * <div class="note"><b>Example:</b>
+     * the {@link ObliqueStereographic} formulas do not work anymore when the latitude of
origin is 90°N or 90°S,
+     * because some internal coefficients become infinite. However the {@link PolarStereographic}
implementation
+     * is designed especially for those special cases. So the {@code ObliqueStereographic.createMapProjection(…)}
+     * method can redirect to {@code PolarStereographic.createMapProjection(…)} when it
detects such cases.</div>
+     *
+     * It is caller's responsibility to choose an alternative method that can understand
the parameters which were
+     * given to this original projection.
+     *
+     * @param  factory The factory given to {@link #createMapProjection(MathTransformFactory)}.
+     * @param  name    The name of the alternative map projection to use.
+     * @return The alternative projection.
+     * @throws FactoryException if an error occurred while creating the alternative projection.
+     *
+     * @since 0.7
+     */
+    final MathTransform delegate(final MathTransformFactory factory, final String name) throws
FactoryException {
+        final OperationMethod method;
+        if (factory instanceof DefaultMathTransformFactory) {
+            method = ((DefaultMathTransformFactory) factory).getOperationMethod(name);
+        } else {
+            method = ReferencingServices.getInstance().getOperationMethod(
+                    factory.getAvailableMethods(SingleOperation.class), name);
+        }
+        if (method instanceof MathTransformProvider) {
+            return ((MathTransformProvider) method).createMathTransform(factory, context);
+        } else {
+            throw new FactoryException(Errors.format(Errors.Keys.UnsupportedImplementation_1,
+                    (method != null ? method : factory).getClass()));
+        }
+    }
+
+    /**
      * Returns the parameters used for creating the complete map projection. Those parameters
describe a sequence of
      * <cite>normalize</cite> → {@code this} → <cite>denormalize</cite>
transforms, <strong>not</strong> including
      * {@linkplain org.apache.sis.referencing.cs.CoordinateSystems#swapAndScaleAxes axis
swapping}.

Modified: sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/projection/ObliqueStereographic.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/projection/ObliqueStereographic.java?rev=1709564&r1=1709563&r2=1709564&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/projection/ObliqueStereographic.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/projection/ObliqueStereographic.java
[UTF-8] Tue Oct 20 10:34:13 2015
@@ -24,10 +24,12 @@ import org.opengis.referencing.operation
 import org.opengis.referencing.operation.MathTransformFactory;
 import org.opengis.util.FactoryException;
 import org.apache.sis.parameter.Parameters;
-import org.apache.sis.util.Workaround;
 import org.apache.sis.referencing.operation.matrix.Matrix2;
 import org.apache.sis.referencing.operation.matrix.MatrixSIS;
+import org.apache.sis.internal.referencing.provider.PolarStereographicA;
+import org.apache.sis.internal.referencing.Formulas;
 import org.apache.sis.util.resources.Errors;
+import org.apache.sis.util.Workaround;
 
 import static java.lang.Math.*;
 import static org.apache.sis.internal.referencing.provider.ObliqueStereographic.*;
@@ -84,7 +86,7 @@ public class ObliqueStereographic extend
      * More precisely <var>g</var> and <var>h</var> are used to compute
intermediate parameters <var>i</var>
      * and <var>j</var>, which are themselves used to compute conformal latitude
and longitude.
      */
-    private final double g, h;
+    final double g, h;
 
     /**
      * Creates an Oblique Stereographic projection from the given parameters.
@@ -121,12 +123,10 @@ public class ObliqueStereographic extend
      */
     private ObliqueStereographic(final Initializer initializer) {
         super(initializer);
-        final double φ0      = toRadians(initializer.getAndStore(LATITUDE_OF_ORIGIN));
-        final double sinφ0   = sin(φ0);
-        final double cosφ0   = cos(φ0);
-        final double cos4_φ0 = pow(cosφ0, 4);
-        final double ℯsinφ0  = excentricity * sinφ0;
-        n = sqrt(1 + ((excentricitySquared * cos4_φ0) / (1 - excentricitySquared)));
+        final double φ0     = toRadians(initializer.getAndStore(LATITUDE_OF_ORIGIN));
+        final double sinφ0  = sin(φ0);
+        final double ℯsinφ0 = excentricity * sinφ0;
+        n = sqrt(1 + ((excentricitySquared * pow(cos(φ0), 4)) / (1 - excentricitySquared)));
         /*
          * Following variables use upper-case because they are written that way in the EPSG
guide.
          */
@@ -221,6 +221,17 @@ public class ObliqueStereographic extend
      */
     @Override
     public MathTransform createMapProjection(final MathTransformFactory factory) throws FactoryException
{
+        if (Double.isNaN(χ0)) {
+            /*
+             * The oblique stereographic formulas can not handle the polar case.
+             * If the user gave us a latitude of origin of ±90°, delegate to the
+             * polar stereographic which is designed especially for those cases.
+             */
+            final Double φ0 = context.getValue(LATITUDE_OF_ORIGIN);
+            if (φ0 != null && abs(φ0 - 90) < Formulas.ANGULAR_TOLERANCE) {
+                return delegate(factory, PolarStereographicA.NAME);
+            }
+        }
         ObliqueStereographic kernel = this;
         if (excentricity == 0) {
             kernel = new Spherical(this);
@@ -272,10 +283,10 @@ public class ObliqueStereographic extend
          */
         final double sinχsinχ0 = sinχ * sinχ0;
         final double cosχcosχ0 = cosχ * cosχ0;
-        final double B = 1 + sinχsinχ0 + cosχcosχ0 * cosΛ;
+        final double B = 1 + sinχsinχ0 + cosχcosχ0*cosΛ;
         if (dstPts != null) {
-            dstPts[dstOff  ] = cosχ * sinΛ / B;                             // Easting
(x)
-            dstPts[dstOff+1] = (sinχ * cosχ0 - cosχ * sinχ0 * cosΛ) / B;    // Northing
(y)
+            dstPts[dstOff  ] = cosχ*sinΛ / B;                           // Easting (x)
+            dstPts[dstOff+1] = (sinχ*cosχ0 - cosχ*sinχ0*cosΛ) / B;      // Northing
(y)
         }
         if (!derivate) {
             return null;
@@ -294,7 +305,10 @@ public class ObliqueStereographic extend
          */
         final double cosφ = cos(φ);
         final double dχ_dφ = (1/cosφ - cosφ*excentricitySquared/(1 - ℯsinφ*ℯsinφ))
* 2*n*sqrt(w) / (w + 1);
-
+        /*
+         * Above ∂χ/∂φ is equals to 1 in the spherical case.
+         * Remaining formulas below are the same than in the spherical case.
+         */
         final double B2 = B * B;
         final double d = (cosχcosχ0 + cosΛ * (sinχsinχ0 + 1)) / B2;     // Matrix diagonal
         final double t = sinΛ * (sinχ + sinχ0) / B2;                    // Matrix anti-diagonal
@@ -315,7 +329,10 @@ public class ObliqueStereographic extend
      * @throws ProjectionException if the point can not be converted.
      */
     @Override
-    protected void inverseTransform(double[] srcPts, int srcOff, double[] dstPts, int dstOff)
throws ProjectionException {
+    protected void inverseTransform(final double[] srcPts, final int srcOff,
+                                    final double[] dstPts, final int dstOff)
+            throws ProjectionException
+    {
         final double x = srcPts[srcOff  ];
         final double y = srcPts[srcOff+1];
         final double i = atan(x / (h + y));
@@ -333,17 +350,20 @@ public class ObliqueStereographic extend
         final double sinχ = sin(χ0 + 2*atan(y - x*tan(j/2)));
         final double ψ = log((1 + sinχ) / ((1 - sinχ)*c)) / (2*n);
         double φ = 2*atan(exp(ψ)) - PI/2;                               // First approximation
-        for (int it = 0; it < MAXIMUM_ITERATIONS; it++) {
+        final double he = excentricity/2;
+        final double me = 1 - excentricitySquared;
+        int r = MAXIMUM_ITERATIONS;
+        do {
             final double ℯsinφ = excentricity * sin(φ);
-            final double ψi = log(tan(φ/2 + PI/4) * pow((1 - ℯsinφ) / (1 + ℯsinφ),
excentricity/2));
-            final double Δφ = (ψ - ψi) * cos(φ) * (1 - ℯsinφ*ℯsinφ) / (1 - excentricitySquared);
+            final double ψi = log(tan(φ/2 + PI/4) * pow((1 - ℯsinφ) / (1 + ℯsinφ),
he));
+            final double Δφ = (ψ - ψi) * cos(φ) * (1 - ℯsinφ*ℯsinφ) / me;
             φ += Δφ;
-            if (abs(Δφ) <= ITERATION_TOLERANCE) {
+            if (!(abs(Δφ) > ITERATION_TOLERANCE)) {     // Use '!' for accepting NaN.
                 dstPts[dstOff  ] = λ;
                 dstPts[dstOff+1] = φ;
                 return;
             }
-        }
+        } while (--r != 0);
         throw new ProjectionException(Errors.Keys.NoConvergence);
     }
 
@@ -376,11 +396,17 @@ public class ObliqueStereographic extend
          * {@inheritDoc}
          */
         @Override
-        public Matrix transform(double[] srcPts, int srcOff, double[] dstPts, int dstOff,
boolean derivate) throws ProjectionException {
+        public Matrix transform(final double[] srcPts, final int srcOff,
+                                final double[] dstPts, final int dstOff,
+                                final boolean derivate) throws ProjectionException
+        {
             final double λ = srcPts[srcOff  ];
             final double φ = srcPts[srcOff+1];
             /*
-             * In the spherical case,  φ = χ  and  λ = Λ.
+             * Formulas below are the same than the elliptical formulas after the geodetic
coordinates
+             * have been converted to conformal coordinates.  In this spherical case we do
not need to
+             * perform such conversion. Instead we have directly   χ = φ  and  Λ = λ.
  The simplified
+             * EPSG formulas then become the same than Synder formulas for the spherical
case.
              */
             final double sinφ      = sin(φ);
             final double cosφ      = cos(φ);
@@ -389,10 +415,10 @@ public class ObliqueStereographic extend
             final double sinφsinφ0 = sinφ * sinχ0;
             final double cosφcosφ0 = cosφ * cosχ0;
             final double cosφsinλ  = cosφ * sinλ;
-            final double B = 1 + sinφsinφ0 + cosφcosφ0 * cosλ;
+            final double B = 1 + sinφsinφ0 + cosφcosφ0*cosλ;            // Synder 21-4
             if (dstPts != null) {
-                dstPts[dstOff  ] = cosφsinλ / B;
-                dstPts[dstOff+1] = (sinφ*cosχ0 - cosφ*sinχ0 *cosλ) / B;
+                dstPts[dstOff  ] = cosφsinλ / B;                        // Synder 21-2
+                dstPts[dstOff+1] = (sinφ*cosχ0 - cosφ*sinχ0*cosλ) / B;  // Synder 21-3
             }
             if (!derivate) {
                 return null;
@@ -408,7 +434,10 @@ public class ObliqueStereographic extend
          * {@inheritDoc}
          */
         @Override
-        protected void inverseTransform(double[] srcPts, int srcOff, double[] dstPts, int
dstOff) throws ProjectionException {
+        protected void inverseTransform(final double[] srcPts, final int srcOff,
+                                        final double[] dstPts, final int dstOff)
+                throws ProjectionException
+        {
             final double x = srcPts[srcOff  ];
             final double y = srcPts[srcOff+1];
             final double ρ = hypot(x, y);

Modified: sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/projection/PolarStereographic.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/projection/PolarStereographic.java?rev=1709564&r1=1709563&r2=1709564&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/projection/PolarStereographic.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/projection/PolarStereographic.java
[UTF-8] Tue Oct 20 10:34:13 2015
@@ -313,9 +313,9 @@ public class PolarStereographic extends
         if (!derivate) {
             return null;
         }
-        //
-        // End of map projection. Now compute the derivative.
-        //
+        /*
+         * End of map projection. Now compute the derivative.
+         */
         final double dt = t * dy_dφ(sinφ, cos(φ));
         return new Matrix2(y, dt*sinθ,   // ∂x/∂λ , ∂x/∂φ
                           -x, dt*cosθ);  // ∂y/∂λ , ∂y/∂φ

Modified: sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/ContextualParameters.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/ContextualParameters.java?rev=1709564&r1=1709563&r2=1709564&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/ContextualParameters.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/ContextualParameters.java
[UTF-8] Tue Oct 20 10:34:13 2015
@@ -479,7 +479,7 @@ public class ContextualParameters extend
          * more parameters than what it declared at ContextualParameteres construction time,
or that some
          * ParameterDescriptor instances changed.
          */
-        throw new IllegalStateException(Errors.format(Errors.Keys.UnexpectedChange_1, descriptor.getName()));
+        throw new ParameterNotFoundException(Errors.format(Errors.Keys.UnexpectedChange_1,
descriptor.getName()), name);
     }
 
     /**

Modified: sis/branches/JDK8/core/sis-referencing/src/main/resources/META-INF/services/org.opengis.referencing.operation.OperationMethod
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/main/resources/META-INF/services/org.opengis.referencing.operation.OperationMethod?rev=1709564&r1=1709563&r2=1709564&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/main/resources/META-INF/services/org.opengis.referencing.operation.OperationMethod
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/main/resources/META-INF/services/org.opengis.referencing.operation.OperationMethod
[UTF-8] Tue Oct 20 10:34:13 2015
@@ -21,3 +21,4 @@ org.apache.sis.internal.referencing.prov
 org.apache.sis.internal.referencing.provider.PolarStereographicC
 org.apache.sis.internal.referencing.provider.PolarStereographicNorth
 org.apache.sis.internal.referencing.provider.PolarStereographicSouth
+org.apache.sis.internal.referencing.provider.ObliqueStereographic

Modified: sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/projection/ObliqueStereographicTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/projection/ObliqueStereographicTest.java?rev=1709564&r1=1709563&r2=1709564&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/projection/ObliqueStereographicTest.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/projection/ObliqueStereographicTest.java
[UTF-8] Tue Oct 20 10:34:13 2015
@@ -21,11 +21,13 @@ import org.opengis.parameter.ParameterVa
 import org.opengis.referencing.operation.Matrix;
 import org.opengis.referencing.operation.OperationMethod;
 import org.opengis.referencing.operation.TransformException;
+import org.opengis.referencing.operation.MathTransformFactory;
 import org.opengis.util.FactoryException;
 import org.apache.sis.parameter.Parameters;
 import org.apache.sis.referencing.operation.transform.ContextualParameters;
 import org.apache.sis.referencing.operation.matrix.Matrix2;
 import org.apache.sis.internal.referencing.Formulas;
+import org.apache.sis.internal.system.DefaultFactories;
 import org.apache.sis.test.DependsOnMethod;
 import org.apache.sis.test.DependsOn;
 import org.junit.Test;
@@ -343,7 +345,7 @@ public final strictfp class ObliqueStere
     /**
      * Creates a projection and derivates a few points.
      *
-     * @throws TransformException Should never happen.
+     * @throws TransformException if an error occurred while computing the derivative.
      */
     @Test
     public void testDerivative() throws TransformException {
@@ -356,4 +358,27 @@ public final strictfp class ObliqueStere
         verifyDerivative(toRadians(-3), toRadians(30));
         verifyDerivative(toRadians(+6), toRadians(60));
     }
+
+    /**
+     * Tests the delegation to {@link PolarStereographic} implementation when the latitude
of origin is ±90°.
+     *
+     * @throws FactoryException if an error occurred while creating the map projection.
+     * @throws TransformException if an error occurred while projecting a coordinate.
+     */
+    @Test
+    public void testPolarStereographic() throws FactoryException, TransformException {
+        final OperationMethod op = new org.apache.sis.internal.referencing.provider.ObliqueStereographic();
+        final ParameterValueGroup p = op.getParameters().createValue();
+        p.parameter("semi_major")                    .setValue(6378137);
+        p.parameter("inverse_flattening")            .setValue(298.2572236);
+        p.parameter("Latitude of natural origin")    .setValue(90);
+        p.parameter("Scale factor at natural origin").setValue(0.994);
+        p.parameter("False easting")                 .setValue(2000000);
+        p.parameter("False northing")                .setValue(2000000);
+
+        transform = new ObliqueStereographic(op, (Parameters) p).createMapProjection(
+                DefaultFactories.forBuildin(MathTransformFactory.class));
+        tolerance = 0.01;
+        verifyTransform(new double[] {44, 73}, new double[] {3320416.75, 632668.43});
+    }
 }



Mime
View raw message