sis-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From desruisse...@apache.org
Subject svn commit: r1691249 - in /sis/branches/JDK8/core: sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/ sis-referencing/src/main/java/org/apache/sis/referencing/operation/projection/ sis-referencing/src/test/java/org/apache/sis/r...
Date Wed, 15 Jul 2015 16:46:08 GMT
Author: desruisseaux
Date: Wed Jul 15 16:46:08 2015
New Revision: 1691249

URL: http://svn.apache.org/r1691249
Log:
Initial version of a TransverseMercator projection rewritten from scratch.
We did not port the Geotk code, both for more legal safety and because the formulas changed
anyway.
The Geotk version use the USGS formulas, while Geomatics Guidance Note recommends the JHS
formulas.

Added:
    sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/TransverseMercator.java
  (with props)
    sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/projection/TransverseMercator.java
  (with props)
    sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/projection/TransverseMercatorTest.java
  (with props)
Modified:
    sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/AbstractMercator.java
    sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/projection/LambertConformal.java
    sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/test/suite/ReferencingTestSuite.java
    sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/math/MathFunctions.java
    sis/branches/JDK8/core/sis-utility/src/test/java/org/apache/sis/math/MathFunctionsTest.java

Modified: sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/AbstractMercator.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/AbstractMercator.java?rev=1691249&r1=1691248&r2=1691249&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/AbstractMercator.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/AbstractMercator.java
[UTF-8] Wed Jul 15 16:46:08 2015
@@ -87,7 +87,7 @@ class AbstractMercator extends MapProjec
      * @return The map projection created from the given parameter values.
      */
     @Override
-    protected final NormalizedProjection createProjection(final Parameters parameters) {
+    protected NormalizedProjection createProjection(final Parameters parameters) {
         return new Mercator(this, parameters);
     }
 }

Added: sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/TransverseMercator.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/TransverseMercator.java?rev=1691249&view=auto
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/TransverseMercator.java
(added)
+++ sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/TransverseMercator.java
[UTF-8] Wed Jul 15 16:46:08 2015
@@ -0,0 +1,119 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.sis.internal.referencing.provider;
+
+import org.opengis.parameter.ParameterDescriptor;
+import org.opengis.parameter.ParameterDescriptorGroup;
+import org.apache.sis.parameter.ParameterBuilder;
+import org.apache.sis.metadata.iso.citation.Citations;
+import org.apache.sis.parameter.Parameters;
+import org.apache.sis.referencing.operation.projection.NormalizedProjection;
+
+
+/**
+ * The provider for <cite>Transverse Mercator</cite> projection (EPSG codes 9807).
+ *
+ * @author  Martin Desruisseaux (MPO, IRD, Geomatys)
+ * @author  Rueben Schulz (UBC)
+ * @since   0.6
+ * @version 0.6
+ * @module
+ *
+ * @see <a href="http://www.remotesensing.org/geotiff/proj_list/transverse_mercator.html">Transverse
Mercator on RemoteSensing.org</a>
+ */
+public final class TransverseMercator extends AbstractMercator {
+    /**
+     * For cross-version compatibility.
+     */
+    private static final long serialVersionUID = -3386587506686432398L;
+
+    /**
+     * The operation parameter descriptor for the <cite>Latitude of natural origin</cite>
(φ₀) parameter value.
+     * Valid values range is [-90 … 90]° and default value is 0°.
+     */
+    public static final ParameterDescriptor<Double> LATITUDE_OF_ORIGIN;
+
+    /**
+     * The operation parameter descriptor for the <cite>Longitude of natural origin</cite>
(λ₀) parameter value.
+     * Valid values range is [-180 … 180]° and default value is 0°.
+     */
+    public static final ParameterDescriptor<Double> LONGITUDE_OF_ORIGIN;
+
+    /**
+     * The operation parameter descriptor for the <cite>Scale factor at natural origin</cite>
(k₀) parameter value.
+     * Valid values range is (0 … ∞) and default value is 1.
+     */
+    public static final ParameterDescriptor<Double> SCALE_FACTOR;
+
+    /**
+     * The group of all parameters expected by this coordinate operation.
+     */
+    static final ParameterDescriptorGroup PARAMETERS;
+    static {
+        final ParameterBuilder builder = builder();
+        LATITUDE_OF_ORIGIN = createLatitude(builder
+                .addNamesAndIdentifiers(Mercator1SP.LATITUDE_OF_ORIGIN), true);
+
+        LONGITUDE_OF_ORIGIN = createLongitude(builder.addNamesAndIdentifiers(Mercator1SP.CENTRAL_MERIDIAN)
+                .rename(Citations.NETCDF, "longitude_of_central_meridian"));
+
+        SCALE_FACTOR = createScale(builder
+                .addNamesAndIdentifiers(Mercator1SP.SCALE_FACTOR)
+                .rename(Citations.NETCDF, "scale_factor_at_central_meridian"));
+
+        PARAMETERS = builder
+            .addIdentifier(              "9807")
+            .addName(                    "Transverse Mercator")
+            .addName(Citations.OGC,      "Transverse_Mercator")
+            .addName(Citations.ESRI,     "Transverse_Mercator")
+            .addName(Citations.NETCDF,   "TransverseMercator")
+            .addName(Citations.GEOTIFF,  "CT_TransverseMercator")
+            .addName(Citations.S57,      "Transverse Mercator")
+            .addName(Citations.PROJ4,    "tmerc")
+            .addName(                    "Gauss-Kruger")
+            .addName(Citations.ESRI,     "Gauss_Kruger")
+            .addName(                    "Gauss-Boaga")
+            .addName(                    "TM")
+            .addName(Citations.S57,      "TME")
+            .addIdentifier(Citations.GEOTIFF,  "1")
+            .addIdentifier(Citations.MAP_INFO, "8")
+            .addIdentifier(Citations.S57,     "13")
+            .createGroupForMapProjection(
+                    LATITUDE_OF_ORIGIN,
+                    LONGITUDE_OF_ORIGIN,
+                    SCALE_FACTOR,
+                    FALSE_EASTING,
+                    FALSE_NORTHING);
+    }
+
+    /**
+     * Constructs a new provider.
+     */
+    public TransverseMercator() {
+        super(PARAMETERS);
+    }
+
+    /**
+     * {@inheritDoc}
+     *
+     * @return The map projection created from the given parameter values.
+     */
+    @Override
+    protected NormalizedProjection createProjection(final Parameters parameters) {
+        return new org.apache.sis.referencing.operation.projection.TransverseMercator(this,
parameters);
+    }
+}

Propchange: sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/TransverseMercator.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/TransverseMercator.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain;charset=UTF-8

Modified: sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/projection/LambertConformal.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/projection/LambertConformal.java?rev=1691249&r1=1691248&r2=1691249&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/projection/LambertConformal.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/projection/LambertConformal.java
[UTF-8] Wed Jul 15 16:46:08 2015
@@ -347,9 +347,8 @@ public class LambertConformal extends Ab
     }
 
     /**
-     * Converts the specified (θ,φ) coordinate (units in radians) and stores the result
in {@code dstPts}
-     * (linear distance on a unit sphere). In addition, opportunistically computes the projection
derivative
-     * if {@code derivate} is {@code true}.
+     * Converts the specified (θ,φ) coordinate (units in radians) and stores the result
in {@code dstPts}.
+     * In addition, opportunistically computes the projection derivative if {@code derivate}
is {@code true}.
      *
      * @return The matrix of the projection derivative at the given source position,
      *         or {@code null} if the {@code derivate} argument is {@code false}.
@@ -404,8 +403,7 @@ public class LambertConformal extends Ab
     }
 
     /**
-     * Transforms the specified (<var>x</var>,<var>y</var>) coordinates
-     * and stores the result in {@code dstPts} (angles in radians).
+     * Transforms the specified (<var>x</var>,<var>y</var>) coordinates
and stores the (θ,φ) result in {@code dstPts}.
      *
      * @throws ProjectionException if the point can not be converted.
      */

Added: sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/projection/TransverseMercator.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/projection/TransverseMercator.java?rev=1691249&view=auto
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/projection/TransverseMercator.java
(added)
+++ sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/projection/TransverseMercator.java
[UTF-8] Wed Jul 15 16:46:08 2015
@@ -0,0 +1,252 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.sis.referencing.operation.projection;
+
+import java.util.Map;
+import java.util.EnumMap;
+import org.opengis.parameter.ParameterDescriptor;
+import org.opengis.referencing.operation.Matrix;
+import org.opengis.referencing.operation.OperationMethod;
+import org.apache.sis.referencing.operation.matrix.MatrixSIS;
+import org.apache.sis.internal.referencing.provider.MapProjection;
+import org.apache.sis.internal.util.DoubleDouble;
+import org.apache.sis.parameter.Parameters;
+
+import org.apache.sis.util.resources.Errors;
+import static java.lang.Math.*;
+import static org.apache.sis.math.MathFunctions.asinh;
+import static org.apache.sis.math.MathFunctions.atanh;
+
+
+/**
+ * <cite>Transverse Mercator</cite> projection (EPSG codes 9807).
+ * This class implements the "JHS formulas" reproduced in
+ * IOGP Publication 373-7-2 – Geomatics Guidance Note number 7, part 2 – April 2015.
+ *
+ * <div class="section">Description</div>
+ * This is a cylindrical projection, in which the cylinder has been rotated 90°.
+ * Instead of being tangent to the equator (or to an other standard latitude), it is tangent
to a central meridian.
+ * Deformation are more important as we are going further from the central meridian.
+ * The Transverse Mercator projection is appropriate for region which have a greater extent
north-south than east-west.
+ *
+ * <p>There are a number of versions of the Transverse Mercator projection including
the Universal (UTM)
+ * and Modified (MTM) Transverses Mercator projections. In these cases the earth is divided
into zones.
+ * For the UTM the zones are 6 degrees wide, numbered from 1 to 60 proceeding east from 180
degrees longitude,
+ * and between latitude 84 degrees North and 80 degrees South. The central meridian is taken
as the center of the zone
+ * and the latitude of origin is the equator. A scale factor of 0.9996 and false easting
of 500000 metres is used for
+ * all zones and a false northing of 10000000 metres is used for zones in the southern hemisphere.
+ *
+ * @author  Martin Desruisseaux (Geomatys)
+ * @since   0.6
+ * @version 0.6
+ * @module
+ *
+ * @see Mercator
+ * @see ObliqueMercator
+ */
+public class TransverseMercator extends NormalizedProjection {
+    /**
+     * For cross-version compatibility.
+     */
+    private static final long serialVersionUID = -4717976245811852528L;
+
+    /**
+     * Internal coefficients for computation, depending only on values of standards parallels.
+     * Defined in §1.3.5.1 of IOGP Publication 373-7-2 – Geomatics Guidance Note number
7, part 2 – April 2015.
+     */
+    private final double h1, h2, h3, h4, ih1, ih2, ih3, ih4;
+
+    /**
+     * Returns the (<var>role</var> → <var>parameter</var>) associations
for a Transverse Mercator projection.
+     *
+     * @return The roles map to give to super-class constructor.
+     */
+    private static Map<ParameterRole, ParameterDescriptor<Double>> roles() {
+        final EnumMap<ParameterRole, ParameterDescriptor<Double>> roles = new
EnumMap<>(ParameterRole.class);
+        roles.put(ParameterRole.CENTRAL_MERIDIAN, org.apache.sis.internal.referencing.provider.TransverseMercator.LONGITUDE_OF_ORIGIN);
+        roles.put(ParameterRole.SCALE_FACTOR,     org.apache.sis.internal.referencing.provider.TransverseMercator.SCALE_FACTOR);
+        roles.put(ParameterRole.FALSE_EASTING,    org.apache.sis.internal.referencing.provider.TransverseMercator.FALSE_EASTING);
+        roles.put(ParameterRole.FALSE_NORTHING,   org.apache.sis.internal.referencing.provider.TransverseMercator.FALSE_NORTHING);
+        return roles;
+    }
+
+    /**
+     * Creates a Transverse Mercator projection from the given parameters.
+     * The {@code method} argument can be the description of one of the following:
+     *
+     * <ul>
+     *   <li><cite>"Transverse Mercator"</cite>.</li>
+     * </ul>
+     *
+     * @param method     Description of the projection parameters.
+     * @param parameters The parameter values of the projection to create.
+     */
+    public TransverseMercator(final OperationMethod method, final Parameters parameters)
{
+        super(method, parameters, roles());
+        final double φ0 = toRadians(getAndStore(parameters,
+                org.apache.sis.internal.referencing.provider.TransverseMercator.LATITUDE_OF_ORIGIN));
+        final double rs = parameters.doubleValue(MapProjection.SEMI_MINOR)
+                        / parameters.doubleValue(MapProjection.SEMI_MAJOR);
+
+        final double n  = (1 - rs) / (1 + rs);       // Rewrite of n = f / (2-f)
+        final double n2 = n  * n;
+        final double n3 = n2 * n;
+        final double n4 = n2 * n2;
+        /*
+         * Computes B  =  (n4/64 + n2/4 + 1) / (1 + n)
+         * Opportunistically uses double-double arithmetic since we use it anyway for denormalization
matrix.
+         */
+        final DoubleDouble B = new DoubleDouble(n);
+        B.add(1);
+        B.inverseDivide(n4/64 + n2/4 + 1, 0);
+        /*
+         * Coefficients for direct projection.
+         * Add the smallest values first in order to reduce rounding errors.
+         */
+        h1 = (   41. /    180)*n4  +  ( 5. /  16)*n3  +  (-2. /  3)*n2  +  n/2;
+        h2 = (  557. /   1440)*n4  +  (-3. /   5)*n3  +  (13. / 48)*n2;
+        h3 = ( -103. /    140)*n4  +  (61. / 240)*n3;
+        h4 = (49561. / 161280)*n4;
+        /*
+         * Coefficients for inverse projection.
+         * Add the smallest values first in order to reduce rounding errors.
+         */
+        ih1 = (  -1. /    360)*n4  +  (37. /  96)*n3  +  (-2. /  3)*n2  +  n/2;
+        ih2 = (-437. /   1440)*n4  +  ( 1. /  15)*n3  +  ( 1. / 48)*n2;
+        ih3 = ( -37. /    840)*n4  +  (17. / 480)*n3;
+        ih4 = (4397. / 161280)*n4;
+        /*
+         * Computes M₀ = B⋅(ξ₁ + ξ₂ + ξ₃ + ξ₄), and negate in anticipation
for what
+         * will be needed in the denormalization matrix.
+         */
+        final double Q  = asinh(tan(φ0)) - excentricity * atanh(excentricity * sin(φ0));
+        final double β = atan(sinh(Q));
+        final DoubleDouble M0 = new DoubleDouble(β, 0);
+        M0.add(h1 * sin(2*β), 0);
+        M0.add(h2 * sin(4*β), 0);
+        M0.add(h3 * sin(6*β), 0);
+        M0.add(h4 * sin(8*β), 0);
+        M0.multiply(B);
+        M0.negate();
+        /*
+         * At this point, all parameters have been processed. Now store
+         * the linear operations in the (de)normalize affine transforms:
+         *
+         * Normalization:
+         *   - Subtract central meridian to longitudes (done by the super-class constructor).
+         *   - Convert longitudes and latitudes from degrees to radians (done by the super-class
constructor)
+         *
+         * Denormalization
+         *   - Scale x and y by B.
+         *   - Subtract M0 to the northing.
+         *   - Multiply by the scale factor (done by the super-class constructor).
+         *   - Add false easting and false northing (done by the super-class constructor).
+         */
+        final MatrixSIS denormalize = context.getMatrix(false);
+        denormalize.convertBefore(0, B, null);
+        denormalize.convertBefore(1, B, M0);
+    }
+
+    /**
+     * Converts the specified (λ,φ) coordinate (units in radians) and stores the result
in {@code dstPts}.
+     * In addition, opportunistically computes the projection derivative if {@code derivate}
is {@code true}.
+     *
+     * @return The matrix of the projection derivative at the given source position,
+     *         or {@code null} if the {@code derivate} argument is {@code false}.
+     * @throws ProjectionException if the coordinate can not be converted.
+     */
+    @Override
+    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];
+        final double Q  = asinh(tan(φ)) - atanh(sin(φ)*excentricity)*excentricity;
+        final double β  = atan(sinh(Q));
+
+        // TODO: sin(atan(x)) = x / sqrt(1+x²)
+        //       cos(atan(x)) = 1 / sqrt(1+x²)
+        final double η0 = atanh(cos(β) * sin(λ));
+        final double ξ0 = asin(sin(β) * cosh(η0));
+
+        final double ξ = h4 * sin(8*ξ0) * cosh(8*η0)
+                       + h3 * sin(6*ξ0) * cosh(6*η0)
+                       + h2 * sin(4*ξ0) * cosh(4*η0)
+                       + h1 * sin(2*ξ0) * cosh(2*η0)
+                       + ξ0;
+
+        final double η = h4 * cos(8*ξ0) * sinh(8*η0)
+                       + h3 * cos(6*ξ0) * sinh(6*η0)
+                       + h2 * cos(4*ξ0) * sinh(4*η0)
+                       + h1 * cos(2*ξ0) * sinh(2*η0)
+                       + η0;
+
+        if (dstPts != null) {
+            dstPts[dstOff    ] = η;
+            dstPts[dstOff + 1] = ξ;
+        }
+        if (!derivate) {
+            return null;
+        }
+
+        // TODO
+        return null;
+    }
+
+    /**
+     * Transforms the specified (η,ξ) coordinates and stores the result in {@code dstPts}
(angles in radians).
+     *
+     * @throws ProjectionException if the point can not be converted.
+     */
+    @Override
+    protected void inverseTransform(final double[] srcPts, final int srcOff,
+                                    final double[] dstPts, final int dstOff)
+            throws ProjectionException
+    {
+        final double η = srcPts[srcOff    ];
+        final double ξ = srcPts[srcOff + 1];
+
+        final double ξ0 = ξ - (ih4 * sin(8*ξ) * cosh(8*η)
+                             + ih3 * sin(6*ξ) * cosh(6*η)
+                             + ih2 * sin(4*ξ) * cosh(4*η)
+                             + ih1 * sin(2*ξ) * cosh(2*η));
+
+        final double η0 = η - (ih4 * cos(8*ξ) * sinh(8*η)
+                             + ih3 * cos(6*ξ) * sinh(6*η)
+                             + ih2 * cos(4*ξ) * sinh(4*η)
+                             + ih1 * cos(2*ξ) * sinh(2*η));
+
+        final double β = asin(sin(ξ0) / cosh(η0));
+        final double Q = asinh(tan(β));
+        /*
+         * Following usually converges in 4 iterations.
+         */
+        double Qp = Q, p = 0;
+        for (int i=0; i<MAXIMUM_ITERATIONS; i++) {
+            final double c = excentricity * atanh(excentricity * tanh(Qp));
+            Qp = Q + c;
+            if (abs(c - p) <= ITERATION_TOLERANCE) {
+                dstPts[dstOff    ] = asin(tanh(η0) / cos(β));
+                dstPts[dstOff + 1] = atan(sinh(Qp));
+                return;
+            }
+            p = c;
+        }
+        throw new ProjectionException(Errors.Keys.NoConvergence);
+    }
+}

Propchange: sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/projection/TransverseMercator.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/projection/TransverseMercator.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain;charset=UTF-8

Added: sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/projection/TransverseMercatorTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/projection/TransverseMercatorTest.java?rev=1691249&view=auto
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/projection/TransverseMercatorTest.java
(added)
+++ sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/projection/TransverseMercatorTest.java
[UTF-8] Wed Jul 15 16:46:08 2015
@@ -0,0 +1,103 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.sis.referencing.operation.projection;
+
+import org.opengis.util.FactoryException;
+import org.opengis.referencing.operation.TransformException;
+import org.apache.sis.parameter.Parameters;
+import org.apache.sis.test.DependsOn;
+import org.junit.Test;
+
+import static java.lang.StrictMath.toRadians;
+
+
+/**
+ * Tests the {@link TransverseMercator} class.
+ *
+ * @author  Martin Desruisseaux (Geomatys)
+ * @since   0.6
+ * @version 0.6
+ * @module
+ */
+@DependsOn(NormalizedProjectionTest.class)
+public final strictfp class TransverseMercatorTest extends MapProjectionTestCase {
+    /**
+     * Creates a new instance of {@link TransverseMercator}.
+     *
+     * @param ellipse {@code false} for a sphere, or {@code true} for WGS84 ellipsoid.
+     */
+    private void initialize(final boolean ellipse, final double latitudeOfOrigin) {
+        final org.apache.sis.internal.referencing.provider.TransverseMercator method =
+                new org.apache.sis.internal.referencing.provider.TransverseMercator();
+        final Parameters parameters = parameters(method, ellipse);
+        parameters.getOrCreate(org.apache.sis.internal.referencing.provider.TransverseMercator.LATITUDE_OF_ORIGIN).setValue(latitudeOfOrigin);
+        transform = new TransverseMercator(method, parameters);
+        tolerance = NORMALIZED_TOLERANCE;
+        validate();
+    }
+
+    /**
+     * Tests the <cite>Transverse Mercator</cite> case (EPSG:9807).
+     * This test is defined in GeoAPI conformance test suite.
+     *
+     * @throws FactoryException if an error occurred while creating the map projection.
+     * @throws TransformException if an error occurred while projecting a coordinate.
+     *
+     * @see org.opengis.test.referencing.ParameterizedTransformTest#testTransverseMercator()
+     */
+    @Test
+    @org.junit.Ignore("Missing implementation of the projection derivative.")
+    public void testTransverseMercator() throws FactoryException, TransformException {
+        createGeoApiTest(new org.apache.sis.internal.referencing.provider.TransverseMercator()).testTransverseMercator();
+    }
+
+    /**
+     * Creates a projection and derivates a few points.
+     *
+     * @throws TransformException Should never happen.
+     */
+    @Test
+    @org.junit.Ignore("Missing implementation of the projection derivative.")
+    public void testSphericalDerivative() throws TransformException {
+        initialize(false, 0);
+        tolerance = 1E-9;
+
+        final double delta = toRadians(100.0 / 60) / 1852; // Approximatively 100 metres.
+        derivativeDeltas = new double[] {delta, delta};
+        verifyDerivative(toRadians( 0), toRadians( 0));
+        verifyDerivative(toRadians(-3), toRadians(30));
+        verifyDerivative(toRadians(+6), toRadians(60));
+    }
+
+    /**
+     * Creates a projection and derivates a few points.
+     *
+     * @throws TransformException Should never happen.
+     */
+    @Test
+    @org.junit.Ignore("Missing implementation of the projection derivative.")
+    public void testEllipsoidalDerivative() throws TransformException {
+        initialize(true, 0);
+        tolerance = 1E-9;
+
+        final double delta = toRadians(100.0 / 60) / 1852; // Approximatively 100 metres.
+        derivativeDeltas = new double[] {delta, delta};
+        verifyDerivative(toRadians( 0), toRadians( 0));
+        verifyDerivative(toRadians(-3), toRadians(30));
+        verifyDerivative(toRadians(+6), toRadians(60));
+    }
+}

Propchange: sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/projection/TransverseMercatorTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/projection/TransverseMercatorTest.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain;charset=UTF-8

Modified: sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/test/suite/ReferencingTestSuite.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/test/suite/ReferencingTestSuite.java?rev=1691249&r1=1691248&r2=1691249&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/test/suite/ReferencingTestSuite.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/test/suite/ReferencingTestSuite.java
[UTF-8] Wed Jul 15 16:46:08 2015
@@ -104,6 +104,7 @@ import org.junit.BeforeClass;
     org.apache.sis.referencing.operation.projection.AbstractLambertConformalTest.class,
     org.apache.sis.referencing.operation.projection.MercatorTest.class,
     org.apache.sis.referencing.operation.projection.LambertConformalTest.class,
+    org.apache.sis.referencing.operation.projection.TransverseMercatorTest.class,
 
     // Coordinate Reference System components.
     org.apache.sis.referencing.datum.BursaWolfParametersTest.class,

Modified: sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/math/MathFunctions.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/math/MathFunctions.java?rev=1691249&r1=1691248&r2=1691249&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/math/MathFunctions.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/math/MathFunctions.java
[UTF-8] Wed Jul 15 16:46:08 2015
@@ -57,7 +57,7 @@ import static org.apache.sis.internal.ut
  *
  * @author  Martin Desruisseaux (MPO, IRD, Geomatys)
  * @since   0.3
- * @version 0.4
+ * @version 0.6
  * @module
  *
  * @see DecimalFunctions
@@ -312,8 +312,38 @@ public final class MathFunctions extends
     }
 
     /**
+     * Returns the inverse hyperbolic sine of the given value.
+     * This is the inverse of the {@link Math#sinh(double)} method.
+     *
+     * @param  x The value for which to compute the inverse hyperbolic sine.
+     * @return The inverse hyperbolic sine of the given value.
+     *
+     * @see Math#sinh(double)
+     *
+     * @since 0.6
+     */
+    public static double asinh(final double x) {
+        return Math.log(x + Math.sqrt(x*x + 1));
+    }
+
+    /**
+     * Returns the inverse hyperbolic cosine of the given value.
+     * This is the inverse of the {@link Math#cosh(double)} method.
+     *
+     * @param  x The value for which to compute the inverse hyperbolic cosine.
+     * @return The inverse hyperbolic cosine of the given value.
+     *
+     * @see Math#cosh(double)
+     *
+     * @since 0.6
+     */
+    public static double acosh(final double x) {
+        return Math.log(x + Math.sqrt(x*x - 1));
+    }
+
+    /**
      * Returns the inverse hyperbolic tangent of the given value.
-     * This is the inverse of the {@linkplain Math#tanh(double) tanh} method.
+     * This is the inverse of the {@link Math#tanh(double)} method.
      * The range of input values shall be in the [-1 … 1].
      * Special cases:
      *

Modified: sis/branches/JDK8/core/sis-utility/src/test/java/org/apache/sis/math/MathFunctionsTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-utility/src/test/java/org/apache/sis/math/MathFunctionsTest.java?rev=1691249&r1=1691248&r2=1691249&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-utility/src/test/java/org/apache/sis/math/MathFunctionsTest.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-utility/src/test/java/org/apache/sis/math/MathFunctionsTest.java
[UTF-8] Wed Jul 15 16:46:08 2015
@@ -146,6 +146,30 @@ public final strictfp class MathFunction
     }
 
     /**
+     * Tests the {@link MathFunctions#asinh(double)} method in the [-10 … +10] range.
+     */
+    @Test
+    public void testAsinh() {
+        for (int i=-100; i<=100; i++) {
+            final double x = 0.1 * i;
+            final double y = asinh(x);
+            assertEquals(x, StrictMath.sinh(y), EPS);
+        }
+    }
+
+    /**
+     * Tests the {@link MathFunctions#acosh(double)} method in the [1 … +10] range.
+     */
+    @Test
+    public void testAcosh() {
+        for (int i=10; i<=100; i++) {
+            final double x = 0.1 * i;
+            final double y = acosh(x);
+            assertEquals(x, StrictMath.cosh(y), EPS);
+        }
+    }
+
+    /**
      * Tests the {@link MathFunctions#atanh(double)} method in the [-1 … +1] range.
      */
     @Test



Mime
View raw message