sis-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From desruisse...@apache.org
Subject svn commit: r1719703 - in /sis/branches/JDK8/core/sis-referencing/src: main/java/org/apache/sis/referencing/datum/ main/java/org/apache/sis/referencing/operation/matrix/ main/java/org/apache/sis/referencing/operation/transform/ test/java/org/apache/sis...
Date Sat, 12 Dec 2015 15:41:02 GMT
Author: desruisseaux
Date: Sat Dec 12 15:41:02 2015
New Revision: 1719703

URL: http://svn.apache.org/viewvc?rev=1719703&view=rev
Log:
Consolidation of DatumShiftTransform.

Modified:
    sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/DatumShiftGrid.java
    sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/matrix/GeneralMatrix.java
    sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/matrix/MatrixSIS.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/java/org/apache/sis/referencing/operation/transform/DatumShiftTransform.java
    sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/InterpolatedGeocentricTransform.java
    sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/InterpolatedMolodenskyTransform.java
    sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/InterpolatedTransform.java
    sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/MolodenskyFormula.java
    sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/formulas.html
    sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/transform/InterpolatedGeocentricTransformTest.java
    sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/transform/InterpolatedTransformTest.java

Modified: sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/DatumShiftGrid.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/DatumShiftGrid.java?rev=1719703&r1=1719702&r2=1719703&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/DatumShiftGrid.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/DatumShiftGrid.java
[UTF-8] Sat Dec 12 15:41:02 2015
@@ -108,12 +108,12 @@ import java.util.Objects;
  * following method signatures:
  *
  * <ul>
- *   <li>{@link #interpolateAtNormalized(double, double, double[])}
- *       where the two first {@code double} values are (<var>x</var>,<var>y</var>)
normalized ordinates.</li>
  *   <li>{@link #interpolateInCell(double, double, double[])}
  *       where the two first {@code double} values are (<var>x</var>,<var>y</var>)
grid indices.</li>
  *   <li>{@link #getCellValue(int, int, int)}
  *       where the two last {@code int} values are (<var>x</var>,<var>y</var>)
grid indices.</li>
+ *   <li>{@link #derivativeInCell(double, double)}
+ *       where the values are (<var>x</var>,<var>y</var>) grid indices.</li>
  * </ul>
  *
  * Note that the above restriction does not prevent {@code DatumShiftGrid} to interpolate
translation vectors
@@ -134,6 +134,8 @@ import java.util.Objects;
  * @since   0.7
  * @version 0.7
  * @module
+ *
+ * @see org.apache.sis.referencing.operation.transform.DatumShiftTransform
  */
 public abstract class DatumShiftGrid<C extends Quantity, T extends Quantity> implements
Serializable {
     /**

Modified: sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/matrix/GeneralMatrix.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/matrix/GeneralMatrix.java?rev=1719703&r1=1719702&r2=1719703&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/matrix/GeneralMatrix.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/matrix/GeneralMatrix.java
[UTF-8] Sat Dec 12 15:41:02 2015
@@ -36,7 +36,7 @@ import org.apache.sis.internal.referenci
  *
  * @author  Martin Desruisseaux (IRD, Geomatys)
  * @since   0.4
- * @version 0.5
+ * @version 0.7
  * @module
  *
  * @see Matrices#createDiagonal(int, int)
@@ -458,6 +458,32 @@ class GeneralMatrix extends MatrixSIS im
     }
 
     /**
+     * Sets this matrix to the values of another matrix. This method overrides the default
implementation with a more
+     * efficient implementation in the particular case where the other matrix is an instance
of {@code GeneralMatrix}.
+     *
+     * @param matrix  The matrix to copy.
+     * @throws MismatchedMatrixSizeException if the given matrix has a different size than
this matrix.
+     *
+     * @since 0.7
+     */
+    @Override
+    public void setMatrix(final Matrix matrix) throws MismatchedMatrixSizeException {
+        if (matrix instanceof GeneralMatrix) {
+            final GeneralMatrix gm = (GeneralMatrix) matrix;
+            ensureSizeMatch(numRow, numCol, matrix);
+            final int length = gm.elements.length;
+            if (elements.length <= length) {
+                System.arraycopy(gm.elements, 0, elements, 0, elements.length);
+            } else {
+                System.arraycopy(gm.elements, 0, elements, 0, length);
+                inferErrors(elements);
+            }
+        } else {
+            super.setMatrix(matrix);
+        }
+    }
+
+    /**
      * {@inheritDoc}
      *
      * <p>This method does not check the error terms, because those terms are not visible
to the user

Modified: sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/matrix/MatrixSIS.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/matrix/MatrixSIS.java?rev=1719703&r1=1719702&r2=1719703&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/matrix/MatrixSIS.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/matrix/MatrixSIS.java
[UTF-8] Sat Dec 12 15:41:02 2015
@@ -20,6 +20,7 @@ import java.util.Arrays;
 import java.io.Serializable;
 import java.awt.geom.AffineTransform;   // For javadoc
 import org.opengis.referencing.operation.Matrix;
+import org.apache.sis.internal.referencing.ExtendedPrecisionMatrix;
 import org.apache.sis.internal.util.DoubleDouble;
 import org.apache.sis.internal.util.Numerics;
 import org.apache.sis.util.ArgumentChecks;
@@ -261,8 +262,30 @@ public abstract class MatrixSIS implemen
         final int numRow = getNumRow();
         final int numCol = getNumCol();
         ensureSizeMatch(numRow, numCol, matrix);
-        final double[] elements = new double[numRow * numCol];
-        getElements(matrix, numRow, numCol, elements);
+        final int count = numRow * numCol;
+        final double[] elements;
+        /*
+         * If both matrices use extended precision, the elements array will have twice the
expected length
+         * with the matrix values in the first half and the error terms in the second half.
 If we want to
+         * preserve the extended precision, we have to transfer the values between the two
matrices with a
+         * DoubleDouble object.
+         */
+        if (isExtendedPrecision() && matrix instanceof ExtendedPrecisionMatrix) {
+            elements = ((ExtendedPrecisionMatrix) matrix).getExtendedElements();
+            if (elements.length > count) {
+                final DoubleDouble t = new DoubleDouble();
+                for (int i=0; i<count; i++) {
+                    t.value = elements[i];
+                    t.error = elements[i + count];
+                    set(i / numCol, i % numCol, t);
+                }
+                return;
+            }
+        } else {
+            // Fallback for matrices that do not use extended precision.
+            elements = new double[count];
+            getElements(matrix, numRow, numCol, elements);
+        }
         setElements(elements);
     }
 

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=1719703&r1=1719702&r2=1719703&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] Sat Dec 12 15:41:02 2015
@@ -158,7 +158,7 @@ public class ContextualParameters extend
          * Inverse of the {@link #NORMALIZATION} matrix.
          * For example in a map projection, this matrix is typically (but not necessarily)
as below:
          *
-         * <center>{@include formulas.html#DeormalizeGeographic}</center>
+         * <center>{@include formulas.html#DenormalizeGeographic}</center>
          */
         INVERSE_NORMALIZATION,
 
@@ -475,7 +475,7 @@ public class ContextualParameters extend
      * the denormalization matrix with the following matrix. This will have the effect of
applying the conversion
      * described above after the non-linear kernel operation:</p>
      *
-     * <center>{@include formulas.html#DeormalizeGeographic}</center>
+     * <center>{@include formulas.html#DenormalizeGeographic}</center>
      *
      * @param  λ0 Longitude of the central meridian, in degrees.
      * @return The denormalization affine transform as a matrix.

Modified: sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/DatumShiftTransform.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/DatumShiftTransform.java?rev=1719703&r1=1719702&r2=1719703&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/DatumShiftTransform.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/DatumShiftTransform.java
[UTF-8] Sat Dec 12 15:41:02 2015
@@ -35,13 +35,45 @@ import java.util.Objects;
 
 
 /**
- * Base class of transforms performing datum shifts.
- * Some implementations are backed by a {@link DatumShiftGrid}.
+ * Transforms between two CRS (usually geographic) based on different datum. A datum shift
may be needed when two CRS
+ * use different {@linkplain org.apache.sis.referencing.datum.DefaultEllipsoid ellipsoids}
as approximation of the
+ * shape of the Earth. Sometime two CRS use the same ellipsoid but with different anchor
point (i.e. their coordinate
+ * systems have their origin in different locations).
+ *
+ * <p>There is many different datum shift methods, ranging from transformations as
simple as adding a constant offset
+ * to geographic coordinates, to more complex transformations involving conversions to geocentric
coordinates and/or
+ * interpolations in a {@linkplain DatumShiftGrid datum shift grid}. The simple cases like
adding a constant offset
+ * are handled by other {@code MathTransform} implementations like {@link LinearTransform}.
+ * This {@code DatumShiftTransform} base class is only for transformation methods that can
not be represented
+ * by a concatenation of other {@code MathTransform} implementations.</p>
+ *
+ * <div class="section">Datum shift methods overview</div>
+ * The two CRS's ellipsoids have slightly different scale and rotation in space, and their
center are located in
+ * a slightly different position. Consequently geodetic datum shifts are often approximated
by a constant scale,
+ * rotation and translation applied on geocentric coordinates. Those approximations are handled
in SIS
+ * by concatenations of {@link EllipsoidToCentricTransform} with {@link LinearTransform}
instead than a specific
+ * {@code DatumShiftTransform} subclass.
+ *
+ * <p>If the geodetic datum shifts is approximated only by a geocentric translation
without any scale or rotation,
+ * and if an error of a few centimetres it acceptable, then the {@link MolodenskyTransform}
subclass can be used
+ * as an approximation of the above method. The Molodensky method requires less floating
point operations since
+ * it applies directly on geographic coordinates, without conversions to geocentric coordinates.</p>
+ *
+ * <p>Some countries go one step further and allow the above geocentric translations
to be non-constant.
+ * Instead, a different geocentric translation is interpolated for each geographic input
coordinates.
+ * This case is handled by the {@link InterpolatedGeocentricTransform} subclass, or its
+ * {@link InterpolatedMolodenskyTransform} variant if a few centimetres accuracy lost can
be afforded.</p>
+ *
+ * <p>A simpler alternative to the above is to interpolate translations to apply directly
on geographic coordinates.
+ * This is the approach taken by NADCON and NTv2 grids.
+ * SIS handles those datum shifts with the {@link InterpolatedTransform} subclass.</p>
  *
  * @author  Martin Desruisseaux (Geomatys)
  * @since   0.7
  * @version 0.7
  * @module
+ *
+ * @see DatumShiftGrid
  */
 public abstract class DatumShiftTransform extends AbstractMathTransform implements Serializable
{
     /**
@@ -50,8 +82,9 @@ public abstract class DatumShiftTransfor
     private static final long serialVersionUID = -4492222496475405226L;
 
     /**
-     * The parameters used for creating this transformation.
-     * They are used for formatting <cite>Well Known Text</cite> (WKT) and error
messages.
+     * The parameters used for creating this datum shift. They are used for formatting <cite>Well
Known Text</cite> (WKT)
+     * and error messages. Subclasses shall not use the values defined in this object for
computation purpose, except at
+     * construction time.
      *
      * @see #getContextualParameters()
      */
@@ -63,13 +96,31 @@ public abstract class DatumShiftTransfor
     final DatumShiftGrid<?,?> grid;
 
     /**
-     * Creates a datum shift transform. It is caller responsibility to initialize the {@link
#context} parameters.
+     * Creates a datum shift transform for direct interpolations in a grid.
+     * It is caller responsibility to initialize the {@link #context} parameters.
+     *
+     * @param descriptor  The contextual parameter descriptor.
+     * @param grid        Interpolation grid.
+     */
+    DatumShiftTransform(ParameterDescriptorGroup descriptor, final DatumShiftGrid<?,?>
grid) {
+        final int size = grid.getTranslationDimensions() + 1;
+        context = new ContextualParameters(descriptor, size, size);
+        this.grid = grid;
+    }
+
+    /**
+     * Creates a datum shift transform for interpolations in geocentric domain.
+     * It is caller responsibility to initialize the {@link #context} parameters.
      *
      * @param descriptor  The contextual parameter descriptor.
      * @param grid        Interpolation grid in geocentric coordinates, or {@code null} if
none.
+     * @param isSource3D  {@code true} if the source coordinates have a height.
+     * @param isTarget3D  {@code true} if the target coordinates have a height.
      */
-    DatumShiftTransform(ParameterDescriptorGroup descriptor, int srcSize, int tgtSize, final
DatumShiftGrid<?,?> grid) {
-        context = new ContextualParameters(descriptor, srcSize, tgtSize);
+    DatumShiftTransform(final ParameterDescriptorGroup descriptor,
+            final boolean isSource3D, final boolean isTarget3D, final DatumShiftGrid<?,?>
grid)
+    {
+        context = new ContextualParameters(descriptor, isSource3D ? 4 : 3, isTarget3D ? 4
: 3);
         this.grid = grid;
     }
 
@@ -115,11 +166,37 @@ public abstract class DatumShiftTransfor
     }
 
     /**
-     * Returns the internal parameter values of this transform.
-     * This method is mostly for {@linkplain org.apache.sis.io.wkt.Convention#INTERNAL debugging
purposes}
-     * since the isolation of non-linear parameters in this class is highly implementation
dependent.
-     * Most GIS applications will instead be interested in the {@linkplain #getContextualParameters()
-     * contextual parameters}.
+     * Returns the internal parameter values of this {@code DatumShiftTransform} instance
(ignoring context).
+     * The parameters returned by this method do not necessarily describe the whole datum
shift process,
+     * because {@code DatumShiftTransform} instances are often preceeded and followed by
linear conversions.
+     * It may be conversions between degrees and radians units, or conversions from geodetic
coordinates to grid indices.
+     *
+     * <div class="note"><b>Example:</b>
+     * The chain of transforms of an {@link InterpolatedGeocentricTransform} is:
+     * <center>
+     *   <table class="compact" style="td {vertical-align: middle}" summary="Decomposition
of a datum shift">
+     *     <tr style="text-align: center">
+     *       <th>Degrees to radians</th><th></th>
+     *       <th>{@code DatumShiftTransform} work</th><th></th>
+     *       <th>Radians to degrees</th>
+     *     </tr><tr>
+     *       <td>{@include formulas.html#NormalizeGeographic}</td>
+     *       <td>→</td>
+     *       <td style="vertical-align: top"><ol style="padding-left: 15px">
+     *         <li>Geographic to geocentric conversion</li>
+     *         <li>Geocentric interpolation</li>
+     *         <li>Geocentric to geographic conversion</li>
+     *       </ol></td>
+     *       <td>→</td>
+     *       <td>{@include formulas.html#DenormalizeGeographic}</td>
+     *     </tr>
+     *   </table>
+     * </center></div>
+     *
+     * This method returns the parameters for the part in the middle of above example.
+     * The content of this part is highly implementation-dependent and used mostly for
+     * {@linkplain org.apache.sis.io.wkt.Convention#INTERNAL debugging purposes}.
+     * The parameters that describe the process as a whole are rather given by {@link #getContextualParameters()}.
      *
      * @return The internal parameter values for this transform.
      */

Modified: sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/InterpolatedGeocentricTransform.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/InterpolatedGeocentricTransform.java?rev=1719703&r1=1719702&r2=1719703&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/InterpolatedGeocentricTransform.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/InterpolatedGeocentricTransform.java
[UTF-8] Sat Dec 12 15:41:02 2015
@@ -36,7 +36,6 @@ import org.apache.sis.metadata.iso.citat
 import org.apache.sis.parameter.ParameterBuilder;
 import org.apache.sis.referencing.datum.DatumShiftGrid;
 import org.apache.sis.referencing.operation.matrix.Matrices;
-import org.apache.sis.referencing.operation.matrix.Matrix3;
 import org.apache.sis.util.ArgumentChecks;
 
 
@@ -99,7 +98,7 @@ public class InterpolatedGeocentricTrans
      * The {@code DESCRIPTOR} defined here is non-standard, but allows this class to be used
      * for other geographic areas than France.
      */
-    private static final ParameterDescriptorGroup DESCRIPTOR;
+    static final ParameterDescriptorGroup DESCRIPTOR;
 
     /**
      * Parameter descriptor to use with the contextual parameters for the inverse transformation.
@@ -219,9 +218,10 @@ public class InterpolatedGeocentricTrans
                                             final DatumShiftGrid<?,?> grid,
                                             InterpolatedGeocentricTransform inverse)
     {
-        super((inverse != null) ? INVERSE : DESCRIPTOR, isSource3D ? 4 : 3, isTarget3D ?
4 : 3, grid);
+        super((inverse != null) ? INVERSE : DESCRIPTOR, isSource3D, isTarget3D, grid);
         ArgumentChecks.ensureNonNull("source", source);
         ArgumentChecks.ensureNonNull("target", target);
+        ArgumentChecks.ensureNonNull("grid",   grid);
         final Unit<Length> unit = source.getAxisUnit();
         ensureGeocentricTranslation(grid, unit);
         /*
@@ -326,7 +326,6 @@ public class InterpolatedGeocentricTrans
             final Ellipsoid target, final boolean isTarget3D,
             final DatumShiftGrid<Angle,Length> grid) throws FactoryException
     {
-        ArgumentChecks.ensureNonNull("grid", grid);
         final InterpolatedGeocentricTransform tr;
         if (isSource3D || isTarget3D) {
             tr = new InterpolatedGeocentricTransform(source, isSource3D, target, isTarget3D,
grid);
@@ -401,18 +400,34 @@ public class InterpolatedGeocentricTrans
         if (m1 == null || m2 == null) {
             return null;
         }
-        /*
-         * We could improve a little bit the precision by computing the derivative in the
interpolation grid:
-         *
-         *     grid.derivativeInCell(grid.normalizedToGridX(λ), grid.normalizedToGridY(φ));
-         *
-         * But this is a little bit complicated (need to convert to normalized units and
divide by the grid
-         * cell size) for a very small difference. For now we neglect that part.
-         */
-        final Matrix3 t = new Matrix3();
-        t.m00 = scale;
-        t.m11 = scale;
-        return Matrices.multiply(m2, Matrices.multiply(t, m1));
+        return concatenate(m1, m2);
+    }
+
+    /**
+     * Computes the derivative by concatenating the "geographic to geocentric" and "geocentric
to geographic" matrix,
+     * with the {@linkplain #scale} factor between them.
+     *
+     * <div class="note"><b>Note:</b>
+     * we could improve a little bit the precision by computing the derivative in the interpolation
grid:
+     *
+     * {@preformat java
+     *     grid.derivativeInCell(grid.normalizedToGridX(λ), grid.normalizedToGridY(φ));
+     * }
+     *
+     * But this is a little bit complicated (need to convert to normalized units and divide
by the grid
+     * cell size) for a very small difference. For now we neglect that part.</div>
+     *
+     * @param m1 The derivative computed by the "geographic to geocentric" conversion.
+     * @param m2 The derivative computed by the "geocentric to geographic" conversion.
+     * @return The derivative for the "interpolated geocentric" transformation.
+     */
+    final Matrix concatenate(final Matrix m1, final Matrix m2) {
+        for (int i = m1.getNumCol(); --i >= 0;) {   // Number of columns can be 2 or 3.
+            for (int j = 3; --j >= 0;) {            // Number of rows can not be anything
else than 3.
+                m1.setElement(j, i, m1.getElement(j, i) * scale);
+            }
+        }
+        return Matrices.multiply(m2, m1);
     }
 
     /**
@@ -519,10 +534,7 @@ public class InterpolatedGeocentricTrans
             if (m1 == null || m2 == null) {
                 return null;
             }
-            final Matrix3 t = new Matrix3();
-            t.m00 = scale;
-            t.m11 = scale;
-            return Matrices.multiply(m2, Matrices.multiply(t, m1));
+            return concatenate(m1, m2);
         }
     }
 }

Modified: sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/InterpolatedMolodenskyTransform.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/InterpolatedMolodenskyTransform.java?rev=1719703&r1=1719702&r2=1719703&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/InterpolatedMolodenskyTransform.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/InterpolatedMolodenskyTransform.java
[UTF-8] Sat Dec 12 15:41:02 2015
@@ -82,16 +82,10 @@ public class InterpolatedMolodenskyTrans
     static {
         final ParameterBuilder builder = new ParameterBuilder()
                 .setRequired(true).setCodeSpace(Citations.SIS, Constants.SIS);
-        final ParameterDescriptor<?>[] param = new ParameterDescriptor<?>[] {
-                Molodensky.DIMENSION,
-                Molodensky.SRC_SEMI_MAJOR,
-                Molodensky.SRC_SEMI_MINOR,
-                Molodensky.TGT_SEMI_MAJOR,
-                Molodensky.TGT_SEMI_MINOR,
-                FranceGeocentricInterpolation.FILE
-        };
-        DESCRIPTOR = builder.addName("Molodensky interpolation").createGroup(param);
-        INVERSE = builder.addName("Molodensky inverse interpolation").createGroup(param);
+        DESCRIPTOR = builder.addName("Molodensky interpolation")
+                .createGroupWithSameParameters(InterpolatedGeocentricTransform.DESCRIPTOR);
+        INVERSE = builder.addName("Molodensky inverse interpolation")
+                .createGroupWithSameParameters(InterpolatedGeocentricTransform.DESCRIPTOR);
     }
 
     /**

Modified: sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/InterpolatedTransform.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/InterpolatedTransform.java?rev=1719703&r1=1719702&r2=1719703&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/InterpolatedTransform.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/InterpolatedTransform.java
[UTF-8] Sat Dec 12 15:41:02 2015
@@ -17,14 +17,12 @@
 package org.apache.sis.referencing.operation.transform;
 
 import java.util.Arrays;
-import java.io.Serializable;
 import javax.measure.unit.Unit;
 import javax.measure.unit.NonSI;
 import javax.measure.quantity.Quantity;
 import javax.measure.converter.UnitConverter;
 import javax.measure.converter.LinearConverter;
 import org.opengis.util.FactoryException;
-import org.opengis.parameter.ParameterValueGroup;
 import org.opengis.referencing.operation.Matrix;
 import org.opengis.referencing.operation.MathTransform;
 import org.opengis.referencing.operation.MathTransformFactory;
@@ -79,7 +77,7 @@ import java.util.Objects;
  * @version 0.7
  * @module
  */
-public class InterpolatedTransform extends AbstractMathTransform implements Serializable
{
+public class InterpolatedTransform extends DatumShiftTransform {
     /**
      * Serial number for inter-operability with different versions.
      */
@@ -93,24 +91,11 @@ public class InterpolatedTransform exten
     private static final int GRID_DIMENSION = 2;
 
     /**
-     * The grid of datum shifts from source datum to target datum.
-     */
-    protected final DatumShiftGrid<?,?> grid;
-
-    /**
      * The value of {@link DatumShiftGrid#getTranslationDimensions()}, stored for efficiency.
      */
     private final int dimension;
 
     /**
-     * The parameters used for creating this conversion.
-     * They are used for formatting <cite>Well Known Text</cite> (WKT) and error
messages.
-     *
-     * @see #getContextualParameters()
-     */
-    private final ContextualParameters context;
-
-    /**
      * The inverse of this interpolated transform.
      *
      * @see #inverse()
@@ -149,7 +134,11 @@ public class InterpolatedTransform exten
     protected <T extends Quantity> InterpolatedTransform(final DatumShiftGrid<T,T>
grid)
             throws NoninvertibleMatrixException
     {
-        ArgumentChecks.ensureNonNull("grid", grid);
+        /*
+         * Create the contextual parameters using the descriptor of the provider that created
the datum shift grid.
+         * If that provider is unknown, default (for now) to NTv2. This default may change
in any future SIS version.
+         */
+        super((grid instanceof DatumShiftGridFile<?,?>) ? ((DatumShiftGridFile<?,?>)
grid).descriptor : NTv2.PARAMETERS, grid);
         if (!grid.isCellValueRatio()) {
             throw new IllegalArgumentException(Errors.format(
                     Errors.Keys.IllegalParameterValue_2, "isCellValueRatio", Boolean.FALSE));
@@ -158,14 +147,7 @@ public class InterpolatedTransform exten
         if (unit != grid.getCoordinateUnit()) {
             throw new IllegalArgumentException(Errors.format(Errors.Keys.IllegalUnitFor_2,
"translation", unit));
         }
-        this.grid = grid;
         dimension = grid.getTranslationDimensions();
-        /*
-         * Create the contextual parameters using the descriptor of the provider that created
the datum shift grid.
-         * If that provider is unknown, default (for now) to NTv2. This default may change
in any future SIS version.
-         */
-        context = new ContextualParameters((grid instanceof DatumShiftGridFile<?,?>)
-                ? ((DatumShiftGridFile<?,?>) grid).descriptor : NTv2.PARAMETERS, dimension
+ 1, dimension + 1);
         if (grid instanceof DatumShiftGridFile<?,?>) {
             ((DatumShiftGridFile<?,?>) grid).setFileParameters(context);
         }
@@ -269,30 +251,6 @@ public class InterpolatedTransform exten
     }
 
     /**
-     * Returns the parameter values of this transform.
-     *
-     * @return The parameter values for this transform.
-     */
-    @Override
-    public ParameterValueGroup getParameterValues() {
-        return context;
-    }
-
-    /**
-     * Returns the parameters used for creating the complete transformation. 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}.
-     * Those parameters are used for formatting <cite>Well Known Text</cite>
(WKT) and error messages.
-     *
-     * @return The parameters values for the sequence of
-     *         <cite>normalize</cite> → {@code this} → <cite>denormalize</cite>
transforms.
-     */
-    @Override
-    protected ContextualParameters getContextualParameters() {
-        return context;
-    }
-
-    /**
      * Applies the datum shift on a coordinate and optionally returns the derivative at that
location.
      *
      * @return {@inheritDoc}

Modified: sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/MolodenskyFormula.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/MolodenskyFormula.java?rev=1719703&r1=1719702&r2=1719703&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/MolodenskyFormula.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/MolodenskyFormula.java
[UTF-8] Sat Dec 12 15:41:02 2015
@@ -175,7 +175,7 @@ abstract class MolodenskyFormula extends
                       final DatumShiftGrid<?,?> grid, final boolean isAbridged,
                       final ParameterDescriptorGroup descriptor)
     {
-        super(descriptor, isSource3D ? 4 : 3, isTarget3D ? 4 : 3, grid);
+        super(descriptor, isSource3D, isTarget3D, grid);
         ArgumentChecks.ensureNonNull("source", source);
         ArgumentChecks.ensureNonNull("target", target);
         final DefaultEllipsoid src = DefaultEllipsoid.castOrCopy(source);

Modified: sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/formulas.html
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/formulas.html?rev=1719703&r1=1719702&r2=1719703&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/formulas.html
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/formulas.html
[UTF-8] Sat Dec 12 15:41:02 2015
@@ -169,7 +169,7 @@
 
 
 
-    <h2>DeormalizeGeographic</h2>
+    <h2>DenormalizeGeographic</h2>
     <math display="block" alttext="MathML capable browser required">
       <mfenced open="[" close="]">
         <mtable>

Modified: sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/transform/InterpolatedGeocentricTransformTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/transform/InterpolatedGeocentricTransformTest.java?rev=1719703&r1=1719702&r2=1719703&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/transform/InterpolatedGeocentricTransformTest.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/transform/InterpolatedGeocentricTransformTest.java
[UTF-8] Sat Dec 12 15:41:02 2015
@@ -127,7 +127,7 @@ public strictfp class InterpolatedGeocen
      */
     @Test
     @DependsOnMethod("testForwardTransform")
-    public void testDerivative() throws FactoryException, TransformException {
+    public void testForwardDerivative() throws FactoryException, TransformException {
         createGeodeticTransformation();
         transform = transform.inverse();
         final double delta = (100.0 / 60) / 1852;      // Approximatively 100 metres.
@@ -137,6 +137,23 @@ public strictfp class InterpolatedGeocen
     }
 
     /**
+     * Tests the derivatives at the sample point. This method compares the derivatives computed
by
+     * the transform with an estimation of derivatives computed by the finite differences
method.
+     *
+     * @throws FactoryException if an error occurred while loading the grid.
+     * @throws TransformException if an error occurred while transforming the coordinate.
+     */
+    @Test
+    @DependsOnMethod("testInverseTransform")
+    public void testInverseDerivative() throws FactoryException, TransformException {
+        createGeodeticTransformation();
+        final double delta = (100.0 / 60) / 1852;      // Approximatively 100 metres.
+        derivativeDeltas = new double[] {delta, delta};
+        tolerance = 1E-5;   // Empirical value.
+        verifyDerivative(FranceGeocentricInterpolationTest.samplePoint(3));
+    }
+
+    /**
      * Tests the Well Known Text (version 1) formatting.
      * The result is what we show to users, but may quite different than what SIS has in
memory.
      *

Modified: sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/transform/InterpolatedTransformTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/transform/InterpolatedTransformTest.java?rev=1719703&r1=1719702&r2=1719703&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/transform/InterpolatedTransformTest.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/transform/InterpolatedTransformTest.java
[UTF-8] Sat Dec 12 15:41:02 2015
@@ -142,7 +142,7 @@ public final strictfp class Interpolated
      */
     @Test
     @DependsOnMethod("testForwardTransform")
-    public void testDerivative() throws FactoryException, TransformException {
+    public void testForwardDerivative() throws FactoryException, TransformException {
         createRGF93();
         final double delta = 0.2;
         derivativeDeltas = new double[] {delta, delta};
@@ -151,6 +151,24 @@ public final strictfp class Interpolated
     }
 
     /**
+     * Tests the derivatives at the sample point. This method compares the derivatives computed
by
+     * the transform with an estimation of derivatives computed by the finite differences
method.
+     *
+     * @throws FactoryException if an error occurred while loading the grid.
+     * @throws TransformException if an error occurred while transforming the coordinate.
+     */
+    @Test
+    @DependsOnMethod("testInverseTransform")
+    public void testInverseDerivative() throws FactoryException, TransformException {
+        createRGF93();
+        transform = transform.inverse();
+        final double delta = 0.2;
+        derivativeDeltas = new double[] {delta, delta};
+        tolerance = 5E-6;   // Empirical value.
+        verifyDerivative(FranceGeocentricInterpolationTest.samplePoint(3));
+    }
+
+    /**
      * Tests the Well Known Text (version 1) formatting.
      * The result is what we show to users, but may quite different than what SIS has in
memory.
      *




Mime
View raw message