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

svn commit: r1714911 - in /sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform: EllipsoidToCentricTransform.java InterpolatedGeocentricTransform.java MolodenskyFormula.java MolodenskyTransform.java

Author: desruisseaux
Date: Wed Nov 18 00:02:17 2015
New Revision: 1714911

URL: http://svn.apache.org/viewvc?rev=1714911&view=rev
Log:
Remove the flexibility on the number of dimension of 'derivative(DirectPosition)' where is was not needed (MolodenskyTransform).
Keep that flexibility only where it was really needed (EllipsoidToGeocentricTransform) and add a comment explaining why that
flexibility is needed in that particular transform.

Modified:
    sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/EllipsoidToCentricTransform.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/MolodenskyFormula.java
    sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/MolodenskyTransform.java

Modified: sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/EllipsoidToCentricTransform.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/EllipsoidToCentricTransform.java?rev=1714911&r1=1714910&r2=1714911&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/EllipsoidToCentricTransform.java [UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/EllipsoidToCentricTransform.java [UTF-8] Wed Nov 18 00:02:17 2015
@@ -436,6 +436,11 @@ public class EllipsoidToCentricTransform
      * This method relaxes a little bit the {@code MathTransform} contract by accepting two- or three-dimensional
      * points even if the number of dimensions does not match the {@link #getSourceDimensions()} value.
      *
+     * <div class="note"><b>Rational:</b>
+     * that flexibility on the number of dimensions is required for calculation of {@linkplain #inverse() inverse}
+     * transform derivative, because that calculation needs to inverse a square matrix with all terms in it before
+     * to drop the last row in the two-dimensional case.</div>
+     *
      * @param  point The coordinate point where to evaluate the derivative.
      * @return The derivative at the specified point (never {@code null}).
      * @throws TransformException if the derivative can not be evaluated at the specified point.

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=1714911&r1=1714910&r2=1714911&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] Wed Nov 18 00:02:17 2015
@@ -151,7 +151,7 @@ public class InterpolatedGeocentricTrans
         final double λ = srcPts[srcOff];
         final double φ = srcPts[srcOff+1];
         grid.offsetAt(Math.toDegrees(λ), Math.toDegrees(φ), offset);    // TODO: avoid conversion to degrees.
-        return transform(λ, φ, isSource3D ? srcPts[srcOff+2] : 0, isSource3D,
-                dstPts, dstOff, isTarget3D, offset[0], offset[1], offset[2], derivate);
+        return transform(λ, φ, isSource3D ? srcPts[srcOff+2] : 0,
+                dstPts, dstOff, offset[0], offset[1], offset[2], derivate);
     }
 }

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=1714911&r1=1714910&r2=1714911&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] Wed Nov 18 00:02:17 2015
@@ -288,9 +288,6 @@ abstract class MolodenskyFormula extends
      * fields have the same value, except if some special circumstances:
      *
      * <ul>
-     *   <li>{@code isSource3D} and {@code isTarget3D} parameters have the same values than {@link #isSource3D} and
-     *       {@link #isTarget3D} fields respectively, except when the user explicitly requested the derivative of a
-     *       point with a different number of dimensions (this should be very rare).</li>
      *   <li>{@code tX}, {@code tY} and {@code tZ} parameters always have the values of {@link #tX}, {@link #tY}
      *       and {@link #tZ} fields when this method is invoked by {@link MolodenskyTransform}. But those values
      *       may be slightly different when this method is invoked by {@link InterpolatedGeocentricTransform}.</li>
@@ -299,20 +296,16 @@ abstract class MolodenskyFormula extends
      * @param λ           Longitude (radians).
      * @param φ           Latitude (radians).
      * @param h           Height above the ellipsoid in unit of semi-major axis.
-     * @param isSource3D  The {@link #isSource3D} field value (except when computing derivative).
      * @param dstPts      The array into which the transformed coordinate is returned, or {@code null}.
      * @param dstOff      The offset to the location of the transformed point that is stored in the destination array.
-     * @param isTarget3D  The {@link #isTarget3D} field value (except when computing derivative).
      * @param tX          The {@link #tX} field value (or a slightly different value during geocentric interpolation).
      * @param tY          The {@link #tY} field value (or a slightly different value during geocentric interpolation).
      * @param tZ          The {@link #tZ} field value (or a slightly different value during geocentric interpolation).
      * @param derivate    {@code true} for computing the derivative, or {@code false} if not needed.
      * @throws TransformException if a point can not be transformed.
      */
-    final Matrix transform(final double λ, final double φ, final double h, final boolean isSource3D,
-                           final double[] dstPts, int dstOff, final boolean isTarget3D,
-                           double tX, double tY, double tZ,
-                           final boolean derivate) throws TransformException
+    final Matrix transform(final double λ, final double φ, final double h, final double[] dstPts, int dstOff,
+                           double tX, double tY, double tZ, final boolean derivate) throws TransformException
     {
         /*
          * Abridged Molodensky formulas from EPSG guidance note:

Modified: sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/MolodenskyTransform.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/MolodenskyTransform.java?rev=1714911&r1=1714910&r2=1714911&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/MolodenskyTransform.java [UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/MolodenskyTransform.java [UTF-8] Wed Nov 18 00:02:17 2015
@@ -19,7 +19,6 @@ package org.apache.sis.referencing.opera
 import java.util.Arrays;
 import javax.measure.unit.Unit;
 import org.opengis.util.FactoryException;
-import org.opengis.geometry.DirectPosition;
 import org.opengis.parameter.ParameterDescriptorGroup;
 import org.opengis.referencing.datum.Ellipsoid;
 import org.opengis.referencing.operation.Matrix;
@@ -222,29 +221,6 @@ public class MolodenskyTransform extends
     }
 
     /**
-     * Computes the derivative at the given location.
-     * This method relaxes a little bit the {@code MathTransform} contract by accepting two- or three-dimensional
-     * points even if the number of dimensions does not match the {@link #getSourceDimensions()} or
-     * {@link #getTargetDimensions()} values.
-     *
-     * @param  point The coordinate point where to evaluate the derivative.
-     * @return The derivative at the specified point (never {@code null}).
-     * @throws TransformException if the derivative can not be evaluated at the specified point.
-     */
-    @Override
-    public Matrix derivative(final DirectPosition point) throws TransformException {
-        final int dim = point.getDimension();
-        final boolean withHeight;
-        final double h;
-        switch (dim) {
-            default: throw mismatchedDimension("point", getSourceDimensions(), dim);
-            case 3:  withHeight = true;  h = point.getOrdinate(2); break;
-            case 2:  withHeight = false; h = 0; break;
-        }
-        return transform(point.getOrdinate(0), point.getOrdinate(1), h, withHeight, null, 0, withHeight, tX, tY, tZ, true);
-    }
-
-    /**
      * Transforms the (λ,φ) or (λ,φ,<var>h</var>) coordinates between two geographic CRS,
      * and optionally returns the derivative at that location.
      *
@@ -258,7 +234,7 @@ public class MolodenskyTransform extends
                             final boolean derivate) throws TransformException
     {
         return transform(srcPts[srcOff], srcPts[srcOff+1], isSource3D ? srcPts[srcOff+2] : 0,
-                         isSource3D, dstPts, dstOff, isTarget3D, tX, tY, tZ, derivate);
+                         dstPts, dstOff, tX, tY, tZ, derivate);
     }
 
     /**