sis-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From desruisse...@apache.org
Subject svn commit: r1735454 - in /sis/branches/JDK8/core/sis-referencing/src: main/java/org/apache/sis/referencing/operation/transform/ test/java/org/apache/sis/referencing/cs/ test/java/org/apache/sis/referencing/operation/transform/ test/java/org/apache/sis...
Date Thu, 17 Mar 2016 16:32:51 GMT
Author: desruisseaux
Date: Thu Mar 17 16:32:51 2016
New Revision: 1735454

URL: http://svn.apache.org/viewvc?rev=1735454&view=rev
Log:
Replaced cylindrical <-> Cartesian conversions by polar <-> Cartesian conversions with a PassThroughTransform for the z value.
This allows SIS to leverage the optimization in PassThroughTransform when other MathTransform are concatenated.

Added:
    sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/CartesianToPolar.java
      - copied, changed from r1735402, sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/CartesianToCylindrical.java
    sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/PolarToCartesian.java
      - copied, changed from r1735402, sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/CylindricalToCartesian.java
    sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/cs/DefaultPolarCSTest.java
      - copied, changed from r1735402, sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/cs/DefaultCylindricalCSTest.java
    sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/transform/CartesianToPolarTest.java
      - copied, changed from r1735209, sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/transform/CartesianToCylindricalTest.java
    sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/transform/PolarToCartesianTest.java
      - copied, changed from r1735209, sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/transform/CylindricalToCartesianTest.java
Removed:
    sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/CartesianToCylindrical.java
    sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/CylindricalToCartesian.java
    sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/transform/CartesianToCylindricalTest.java
    sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/transform/CylindricalToCartesianTest.java
Modified:
    sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/CoordinateSystemTransform.java
    sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/EllipsoidToCentricTransform.java
    sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/cs/DefaultCylindricalCSTest.java
    sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/cs/HardCodedCS.java
    sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/transform/CartesianToSphericalTest.java
    sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/transform/CoordinateSystemTransformTest.java
    sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/transform/SphericalToCartesianTest.java
    sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/test/suite/ReferencingTestSuite.java

Copied: sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/CartesianToPolar.java (from r1735402, sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/CartesianToCylindrical.java)
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/CartesianToPolar.java?p2=sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/CartesianToPolar.java&p1=sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/CartesianToCylindrical.java&r1=1735402&r2=1735454&rev=1735454&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/CartesianToCylindrical.java [UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/CartesianToPolar.java [UTF-8] Thu Mar 17 16:32:51 2016
@@ -20,35 +20,41 @@ import java.util.Arrays;
 import java.io.Serializable;
 import org.opengis.referencing.operation.Matrix;
 import org.opengis.referencing.operation.MathTransform;
-import org.apache.sis.referencing.operation.matrix.Matrix3;
+import org.apache.sis.referencing.operation.matrix.Matrix2;
 import org.apache.sis.internal.util.DoubleDouble;
 
 import static java.lang.Math.*;
 
 
 /**
- * Conversions from three-dimensional Cartesian coordinates to spherical coordinates.
+ * Conversions from two-dimensional Cartesian coordinates to polar coordinates.
  * This conversion assumes that there is no datum change.
  *
- * <p>See {@link CylindricalToCartesian} for explanation on axes convention.
+ * <p>See {@link PolarToCartesian} for explanation on axes convention.
  * Axis order shall match the order defined by {@code Normalizer} in {@link org.apache.sis.referencing.cs} package.</p>
  *
+ * <div class="note"><b>Note:</b>
+ * We do not provide explicit {@code CartesianToCylindrical} implementation.  Instead, the cylindrical case is
+ * implemented by the polar case with a {@link PassThroughTransform} for the height. This allows Apache SIS to
+ * use the optimization implemented by {@code PassThroughTransform} when for example a concatenated transform
+ * is dropping the <var>z</var> axis.</div>
+ *
  * @author  Martin Desruisseaux (Geomatys)
  * @since   0.7
  * @version 0.7
  * @module
  */
-final class CartesianToCylindrical extends CoordinateSystemTransform implements Serializable {
+final class CartesianToPolar extends CoordinateSystemTransform implements Serializable {
     /**
      * For cross-version compatibility.
      */
-    private static final long serialVersionUID = -2619855017534519721L;
+    private static final long serialVersionUID = 7698079127743791414L;
 
     /**
      * The singleton instance computing output coordinates are in radians.
      * For the instance computing output coordinates in degrees, use {@link #completeTransform()} instead.
      */
-    static final CartesianToCylindrical INSTANCE = new CartesianToCylindrical();
+    static final CartesianToPolar INSTANCE = new CartesianToPolar();
 
     /**
      * Returns the singleton instance on deserialization.
@@ -61,8 +67,8 @@ final class CartesianToCylindrical exten
      * Creates the singleton instance.
      * Output coordinates are in radians.
      */
-    private CartesianToCylindrical() {
-        super("Cartesian to cylindrical", 3);
+    private CartesianToPolar() {
+        super("Cartesian to polar", 2);
         context.getMatrix(ContextualParameters.MatrixRole.DENORMALIZATION)
                .convertAfter(1, DoubleDouble.createRadiansToDegrees(), null);
     }
@@ -72,7 +78,7 @@ final class CartesianToCylindrical exten
      */
     @Override
     public MathTransform inverse() {
-        return CylindricalToCartesian.INSTANCE;
+        return PolarToCartesian.INSTANCE;
     }
 
     /**
@@ -85,20 +91,17 @@ final class CartesianToCylindrical exten
     {
         final double x  = srcPts[srcOff  ];
         final double y  = srcPts[srcOff+1];
-        final double z  = srcPts[srcOff+2];
         final double r  = hypot(x, y);
         if (dstPts != null) {
             dstPts[dstOff  ] = r;
             dstPts[dstOff+1] = atan2(y, x);
-            dstPts[dstOff+2] = z;
         }
         if (!derivate) {
             return null;
         }
         final double r2 = r*r;
-        return new Matrix3(x/r,   y/r,   0,
-                          -y/r2,  x/r2,  0,
-                           0,     0,     1);
+        return new Matrix2(x/r,   y/r,
+                          -y/r2,  x/r2);
     }
 
     /**
@@ -111,19 +114,19 @@ final class CartesianToCylindrical exten
         int srcInc = 0;
         int dstInc = 0;
         if (srcPts == dstPts) {
-            switch (IterationStrategy.suggest(srcOff, 3, dstOff, 3, numPts)) {
+            switch (IterationStrategy.suggest(srcOff, 2, dstOff, 2, numPts)) {
                 case ASCENDING: {
                     break;
                 }
                 case DESCENDING: {
-                    srcOff += 3 * (numPts - 1);
-                    dstOff += 3 * (numPts - 1);
-                    srcInc = -6;
-                    dstInc = -6;
+                    srcOff += 2 * (numPts - 1);
+                    dstOff += 2 * (numPts - 1);
+                    srcInc = -4;
+                    dstInc = -4;
                     break;
                 }
                 default: {
-                    srcPts = Arrays.copyOfRange(srcPts, srcOff, srcOff + numPts*3);
+                    srcPts = Arrays.copyOfRange(srcPts, srcOff, srcOff + numPts*2);
                     srcOff = 0;
                     break;
                 }
@@ -132,10 +135,8 @@ final class CartesianToCylindrical exten
         while (--numPts >= 0) {
             final double x  = srcPts[srcOff++];
             final double y  = srcPts[srcOff++];
-            final double z  = srcPts[srcOff++];
             dstPts[dstOff++] = hypot(x, y);
             dstPts[dstOff++] = atan2(y, x);
-            dstPts[dstOff++] = z;
             srcOff += srcInc;
             dstOff += dstInc;
         }
@@ -145,7 +146,7 @@ final class CartesianToCylindrical exten
      * NOTE: we do not bother to override the methods expecting a 'float' array because those methods should
      *       be rarely invoked. Since there is usually LinearTransforms before and after this transform, the
      *       conversion between float and double will be handled by those LinearTransforms.  If nevertheless
-     *       this CartesianToCylindrical is at the beginning or the end of a transformation chain,
+     *       this CartesianToPolar is at the beginning or the end of a transformation chain,
      *       the methods inherited from the subclass will work (but may be slightly slower).
      */
 }

Modified: sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/CoordinateSystemTransform.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/CoordinateSystemTransform.java?rev=1735454&r1=1735453&r2=1735454&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/CoordinateSystemTransform.java [UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/CoordinateSystemTransform.java [UTF-8] Thu Mar 17 16:32:51 2016
@@ -25,6 +25,7 @@ import org.opengis.referencing.cs.Cartes
 import org.opengis.referencing.cs.CoordinateSystem;
 import org.opengis.referencing.cs.CylindricalCS;
 import org.opengis.referencing.cs.SphericalCS;
+import org.opengis.referencing.cs.PolarCS;
 import org.opengis.referencing.operation.MathTransform;
 import org.opengis.referencing.operation.MathTransformFactory;
 import org.opengis.referencing.operation.OperationNotFoundException;
@@ -63,8 +64,18 @@ abstract class CoordinateSystemTransform
 
     /**
      * The complete transform, including conversion between degrees and radians.
+     *
+     * @see #completeTransform(MathTransformFactory)
      */
-    private volatile MathTransform complete;
+    private transient volatile MathTransform complete;
+
+    /**
+     * The {@link #complete} transform in a {@link PassThroughTransform} with a 1 trailing ordinate.
+     * This is used for supporting the cylindrical case on top the polar case.
+     *
+     * @see #passthrough(MathTransformFactory)
+     */
+    private transient volatile MathTransform passthrough;
 
     /**
      * Creates a new conversion between two types of coordinate system.
@@ -82,11 +93,30 @@ abstract class CoordinateSystemTransform
     /**
      * Returns the complete transform, including conversion between degrees and radians units.
      */
-    final MathTransform completeTransform() throws FactoryException {
+    final MathTransform completeTransform(final MathTransformFactory factory) throws FactoryException {
         MathTransform tr = complete;
         if (tr == null) {
-            // No need to synchronize since DefaultMathTransformFactory returns unique instances.
-            complete = tr = context.completeTransform(DefaultFactories.forBuildin(MathTransformFactory.class), this);
+            tr = context.completeTransform(factory, this);
+            if (DefaultFactories.isDefaultInstance(MathTransformFactory.class, factory)) {
+                // No need to synchronize since DefaultMathTransformFactory returns unique instances.
+                complete = tr;
+            }
+        }
+        return tr;
+    }
+
+    /**
+     * Returns the cylindrical, including conversion between degrees and radians units.
+     * This method is legal only for {@link PolarToCartesian} or {@link CartesianToPolar}.
+     */
+    final MathTransform passthrough(final MathTransformFactory factory) throws FactoryException {
+        MathTransform tr = passthrough;
+        if (tr == null) {
+            tr = factory.createPassThroughTransform(0, completeTransform(factory), 1);
+            if (DefaultFactories.isDefaultInstance(MathTransformFactory.class, factory)) {
+                // No need to synchronize since DefaultMathTransformFactory returns unique instances.
+                passthrough = tr;
+            }
         }
         return tr;
     }
@@ -135,31 +165,39 @@ abstract class CoordinateSystemTransform
     static MathTransform create(final MathTransformFactory factory, final CoordinateSystem source,
             final CoordinateSystem target) throws FactoryException
     {
-        CoordinateSystemTransform tr = null;
+        int passthrough = 0;
+        CoordinateSystemTransform kernel = null;
         if (source instanceof CartesianCS) {
             if (target instanceof SphericalCS) {
-                tr = CartesianToSpherical.INSTANCE;
+                kernel = CartesianToSpherical.INSTANCE;
             } else if (target instanceof CylindricalCS) {
-                tr = CartesianToCylindrical.INSTANCE;
-            }
-        } else if (source instanceof SphericalCS) {
-            if (target instanceof CartesianCS) {
-                tr = SphericalToCartesian.INSTANCE;
+                passthrough = 1;
+                kernel = CartesianToPolar.INSTANCE;
+            } else if (target instanceof PolarCS) {
+                kernel = CartesianToPolar.INSTANCE;
             }
-        } else if (source instanceof CylindricalCS) {
-            if (target instanceof CartesianCS) {
-                tr = CylindricalToCartesian.INSTANCE;
+        } else if (target instanceof CartesianCS) {
+            if (source instanceof SphericalCS) {
+                kernel = SphericalToCartesian.INSTANCE;
+            } else if (source instanceof CylindricalCS) {
+                passthrough = 1;
+                kernel = PolarToCartesian.INSTANCE;
+            } else if (source instanceof PolarCS) {
+                kernel = PolarToCartesian.INSTANCE;
             }
         }
         Exception cause = null;
         try {
-            if (tr == null) {
+            if (kernel == null) {
                 return factory.createAffineTransform(CoordinateSystems.swapAndScaleAxes(source, target));
-            } else if (tr.getSourceDimensions() == source.getDimension() &&
-                       tr.getTargetDimensions() == target.getDimension())
+            } else if (source.getDimension() == kernel.getSourceDimensions() + passthrough &&
+                       target.getDimension() == kernel.getTargetDimensions() + passthrough)
             {
+                final MathTransform tr = (passthrough == 0)
+                        ? kernel.completeTransform(factory)
+                        : kernel.passthrough(factory);
                 return factory.createConcatenatedTransform(normalize(factory, source, false),
-                       factory.createConcatenatedTransform(tr.completeTransform(), normalize(factory, target, true)));
+                       factory.createConcatenatedTransform(tr, normalize(factory, target, true)));
             }
         } catch (IllegalArgumentException | ConversionException e) {
             cause = e;

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=1735454&r1=1735453&r2=1735454&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] Thu Mar 17 16:32:51 2016
@@ -358,7 +358,7 @@ public class EllipsoidToCentricTransform
             if (!withHeight) {
                 translate.setElement(3, 2, 1);
             }
-            final MathTransform tr = SphericalToCartesian.INSTANCE.completeTransform();
+            final MathTransform tr = SphericalToCartesian.INSTANCE.completeTransform(factory);
             return factory.createConcatenatedTransform(factory.createAffineTransform(translate), tr);
         }
         EllipsoidToCentricTransform tr = new EllipsoidToCentricTransform(semiMajor, semiMinor, unit, withHeight, target);

Copied: sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/PolarToCartesian.java (from r1735402, sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/CylindricalToCartesian.java)
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/PolarToCartesian.java?p2=sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/PolarToCartesian.java&p1=sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/CylindricalToCartesian.java&r1=1735402&r2=1735454&rev=1735454&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/CylindricalToCartesian.java [UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/PolarToCartesian.java [UTF-8] Thu Mar 17 16:32:51 2016
@@ -20,20 +20,20 @@ import java.util.Arrays;
 import java.io.Serializable;
 import org.opengis.referencing.operation.Matrix;
 import org.opengis.referencing.operation.MathTransform;
-import org.apache.sis.referencing.operation.matrix.Matrix3;
+import org.apache.sis.referencing.operation.matrix.Matrix2;
 import org.apache.sis.internal.util.DoubleDouble;
 
 import static java.lang.Math.*;
 
 
 /**
- * Conversions from cylindrical coordinates to three-dimensional Cartesian coordinates.
+ * Conversions from polar coordinates to two-dimensional Cartesian coordinates.
  * This conversion assumes that there is no datum change. Source axis order is:
  *
  * <ul>
  *   <li>Radius (r)</li>
  *   <li>Angle  (θ)</li>
- *   <li>Height (z)</li>
+ *   <li>Height (z) in the cylindrical case (see below)</li>
  * </ul>
  *
  * Target axis order is:
@@ -41,27 +41,33 @@ import static java.lang.Math.*;
  * <ul>
  *   <li><var>x</var> in the direction of θ = 0°</li>
  *   <li><var>y</var> in the direction of θ = 90°</li>
- *   <li><var>z</var> in the some direction than the source</li>
+ *   <li><var>z</var> in the same direction than the source (cylindrical case only - see below)</li>
  * </ul>
  *
  * Axis order shall match the order defined by {@code Normalizer} in {@link org.apache.sis.referencing.cs} package.
  *
+ * <div class="note"><b>Note:</b>
+ * We do not provide explicit {@code CylindricalToCartesian} implementation.  Instead, the cylindrical case is
+ * implemented by the polar case with a {@link PassThroughTransform} for the height. This allows Apache SIS to
+ * use the optimization implemented by {@code PassThroughTransform} when for example a concatenated transform
+ * is dropping the <var>z</var> axis.</div>
+ *
  * @author  Martin Desruisseaux (Geomatys)
  * @since   0.7
  * @version 0.7
  * @module
  */
-final class CylindricalToCartesian extends CoordinateSystemTransform implements Serializable {
+final class PolarToCartesian extends CoordinateSystemTransform implements Serializable {
     /**
      * For cross-version compatibility.
      */
-    private static final long serialVersionUID = 3447323620543409532L;
+    private static final long serialVersionUID = 8026743046661603837L;
 
     /**
      * The singleton instance expecting input coordinates in radians.
      * For the instance expecting input coordinates in degrees, use {@link #completeTransform()} instead.
      */
-    static final CylindricalToCartesian INSTANCE = new CylindricalToCartesian();
+    static final PolarToCartesian INSTANCE = new PolarToCartesian();
 
     /**
      * Returns the singleton instance on deserialization.
@@ -74,8 +80,8 @@ final class CylindricalToCartesian exten
      * Creates the singleton instance.
      * Input coordinates are in radians.
      */
-    private CylindricalToCartesian() {
-        super("Cylindrical to Cartesian", 3);
+    private PolarToCartesian() {
+        super("Polar to Cartesian", 2);
         context.getMatrix(ContextualParameters.MatrixRole.NORMALIZATION)
                .convertBefore(1, DoubleDouble.createDegreesToRadians(), null);
     }
@@ -85,7 +91,7 @@ final class CylindricalToCartesian exten
      */
     @Override
     public MathTransform inverse() {
-        return CartesianToCylindrical.INSTANCE;
+        return CartesianToPolar.INSTANCE;
     }
 
     /**
@@ -98,20 +104,17 @@ final class CylindricalToCartesian exten
     {
         final double r = srcPts[srcOff  ];
         final double θ = srcPts[srcOff+1];
-        final double z = srcPts[srcOff+2];
         final double cosθ = cos(θ);
         final double sinθ = sin(θ);
         if (dstPts != null) {
             dstPts[dstOff  ] = r*cosθ;
             dstPts[dstOff+1] = r*sinθ;
-            dstPts[dstOff+2] = z;
         }
         if (!derivate) {
             return null;
         }
-        return new Matrix3(cosθ, -r*sinθ,  0,
-                           sinθ,  r*cosθ,  0,
-                              0,       0,  1);
+        return new Matrix2(cosθ, -r*sinθ,
+                           sinθ,  r*cosθ);
     }
 
     /**
@@ -124,19 +127,19 @@ final class CylindricalToCartesian exten
         int srcInc = 0;
         int dstInc = 0;
         if (srcPts == dstPts) {
-            switch (IterationStrategy.suggest(srcOff, 3, dstOff, 3, numPts)) {
+            switch (IterationStrategy.suggest(srcOff, 2, dstOff, 2, numPts)) {
                 case ASCENDING: {
                     break;
                 }
                 case DESCENDING: {
-                    srcOff += 3 * (numPts - 1);
-                    dstOff += 3 * (numPts - 1);
-                    srcInc = -6;
-                    dstInc = -6;
+                    srcOff += 2 * (numPts - 1);
+                    dstOff += 2 * (numPts - 1);
+                    srcInc = -4;
+                    dstInc = -4;
                     break;
                 }
                 default: {
-                    srcPts = Arrays.copyOfRange(srcPts, srcOff, srcOff + numPts*3);
+                    srcPts = Arrays.copyOfRange(srcPts, srcOff, srcOff + numPts*2);
                     srcOff = 0;
                     break;
                 }
@@ -145,10 +148,8 @@ final class CylindricalToCartesian exten
         while (--numPts >= 0) {
             final double r = srcPts[srcOff++];
             final double θ = srcPts[srcOff++];
-            final double z = srcPts[srcOff++];
             dstPts[dstOff++] = r*cos(θ);
             dstPts[dstOff++] = r*sin(θ);
-            dstPts[dstOff++] = z;
             srcOff += srcInc;
             dstOff += dstInc;
         }
@@ -158,7 +159,7 @@ final class CylindricalToCartesian exten
      * NOTE: we do not bother to override the methods expecting a 'float' array because those methods should
      *       be rarely invoked. Since there is usually LinearTransforms before and after this transform, the
      *       conversion between float and double will be handled by those LinearTransforms.  If nevertheless
-     *       this CylindricalToCartesian is at the beginning or the end of a transformation chain,
+     *       this PolarToCartesian is at the beginning or the end of a transformation chain,
      *       the methods inherited from the subclass will work (but may be slightly slower).
      */
 }

Modified: sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/cs/DefaultCylindricalCSTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/cs/DefaultCylindricalCSTest.java?rev=1735454&r1=1735453&r2=1735454&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/cs/DefaultCylindricalCSTest.java [UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/cs/DefaultCylindricalCSTest.java [UTF-8] Thu Mar 17 16:32:51 2016
@@ -36,7 +36,7 @@ import static org.opengis.test.Assert.*;
  * @version 0.7
  * @module
  */
-@DependsOn(AbstractCSTest.class)
+@DependsOn(DefaultPolarCSTest.class)
 public final strictfp class DefaultCylindricalCSTest extends TestCase {
     /**
      * Tests {@link DefaultCylindricalCS#forConvention(AxesConvention)}

Copied: sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/cs/DefaultPolarCSTest.java (from r1735402, sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/cs/DefaultCylindricalCSTest.java)
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/cs/DefaultPolarCSTest.java?p2=sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/cs/DefaultPolarCSTest.java&p1=sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/cs/DefaultCylindricalCSTest.java&r1=1735402&r2=1735454&rev=1735454&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/cs/DefaultCylindricalCSTest.java [UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/cs/DefaultPolarCSTest.java [UTF-8] Thu Mar 17 16:32:51 2016
@@ -29,7 +29,7 @@ import static org.opengis.test.Assert.*;
 
 
 /**
- * Tests {@link DefaultCylindricalCS}.
+ * Tests {@link DefaultPolarCS}.
  *
  * @author  Martin Desruisseaux (Geomatys)
  * @since   0.7
@@ -37,24 +37,23 @@ import static org.opengis.test.Assert.*;
  * @module
  */
 @DependsOn(AbstractCSTest.class)
-public final strictfp class DefaultCylindricalCSTest extends TestCase {
+public final strictfp class DefaultPolarCSTest extends TestCase {
     /**
-     * Tests {@link DefaultCylindricalCS#forConvention(AxesConvention)}
+     * Tests {@link DefaultPolarCS#forConvention(AxesConvention)}
      * with a change from clockwise to counterclockwise axis orientation.
      */
     @Test
     public void testChangeClockwiseOrientation() {
-        final DefaultCylindricalCS cs = HardCodedCS.CYLINDRICAL;
-        final DefaultCylindricalCS normalized = cs.forConvention(AxesConvention.CONVENTIONALLY_ORIENTED);
+        final DefaultPolarCS cs = HardCodedCS.POLAR;
+        final DefaultPolarCS normalized = cs.forConvention(AxesConvention.CONVENTIONALLY_ORIENTED);
         assertNotSame("Should create a new CoordinateSystem.", cs, normalized);
         assertAxisDirectionsEqual("Normalized", normalized,
                 AxisDirections.AWAY_FROM,
-                AxisDirections.COUNTER_CLOCKWISE,
-                AxisDirection.UP);
+                AxisDirections.COUNTER_CLOCKWISE);
     }
 
     /**
-     * Tests {@link DefaultCylindricalCS#forConvention(AxesConvention)} with a change of axis order.
+     * Tests {@link DefaultPolarCS#forConvention(AxesConvention)} with a change of axis order.
      * This test uses a (r) axis oriented toward South instead than "awayFrom".
      */
     @Test
@@ -62,24 +61,21 @@ public final strictfp class DefaultCylin
         final DefaultCoordinateSystemAxis radius = HardCodedAxes.create("Radius", "r",
                 AxisDirection.SOUTH, SI.METRE, 0, Double.POSITIVE_INFINITY, RangeMeaning.EXACT);
 
-        final DefaultCylindricalCS cs = new DefaultCylindricalCS(
-                Collections.singletonMap(DefaultCylindricalCS.NAME_KEY, "Cylindrical"),
+        final DefaultPolarCS cs = new DefaultPolarCS(
+                Collections.singletonMap(DefaultPolarCS.NAME_KEY, "Polar"),
                 HardCodedAxes.BEARING,
-                HardCodedAxes.Z,
                 radius);
 
-        DefaultCylindricalCS normalized = cs.forConvention(AxesConvention.RIGHT_HANDED);
+        DefaultPolarCS normalized = cs.forConvention(AxesConvention.RIGHT_HANDED);
         assertNotSame("Should create a new CoordinateSystem.", cs, normalized);
         assertAxisDirectionsEqual("Right-handed", normalized,
                 AxisDirections.CLOCKWISE,                       // Interchanged (r,θ) order for making right handed.
-                AxisDirection.SOUTH,
-                AxisDirection.UP);
+                AxisDirection.SOUTH);
 
         normalized = cs.forConvention(AxesConvention.NORMALIZED);
         assertNotSame("Should create a new CoordinateSystem.", cs, normalized);
         assertAxisDirectionsEqual("Normalized", normalized,
                 AxisDirection.SOUTH,                            // Not modified to North because radius can not be negative.
-                AxisDirections.COUNTER_CLOCKWISE,
-                AxisDirection.UP);
+                AxisDirections.COUNTER_CLOCKWISE);
     }
 }

Modified: sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/cs/HardCodedCS.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/cs/HardCodedCS.java?rev=1735454&r1=1735453&r2=1735454&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/cs/HardCodedCS.java [UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/cs/HardCodedCS.java [UTF-8] Thu Mar 17 16:32:51 2016
@@ -140,6 +140,19 @@ public final strictfp class HardCodedCS
             HardCodedAxes.Z);
 
     /**
+     * A three-dimensional polar CS with
+     * <var>{@linkplain HardCodedAxes#DISTANCE distance}</var>,
+     * <var>{@link HardCodedAxes#BEARING bearing}</var> axes.
+     * Note that this is not a right-handed system.
+     *
+     * @since 0.7
+     */
+    public static final DefaultPolarCS POLAR = new DefaultPolarCS(
+            singletonMap(NAME_KEY, "Polar"),
+            HardCodedAxes.DISTANCE,
+            HardCodedAxes.BEARING);
+
+    /**
      * A two-dimensional Cartesian CS with
      * <var>{@linkplain HardCodedAxes#EASTING Easting}</var>,
      * <var>{@linkplain HardCodedAxes#NORTHING Northing}</var>

Copied: sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/transform/CartesianToPolarTest.java (from r1735209, sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/transform/CartesianToCylindricalTest.java)
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/transform/CartesianToPolarTest.java?p2=sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/transform/CartesianToPolarTest.java&p1=sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/transform/CartesianToCylindricalTest.java&r1=1735209&r2=1735454&rev=1735454&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/transform/CartesianToCylindricalTest.java [UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/transform/CartesianToPolarTest.java [UTF-8] Thu Mar 17 16:32:51 2016
@@ -28,53 +28,102 @@ import org.junit.Test;
 
 
 /**
- * Tests {@link CartesianToCylindrical}.
+ * Tests {@link CartesianToPolar}.
  *
  * @author  Martin Desruisseaux (Geomatys)
  * @since   0.7
  * @version 0.7
  * @module
  */
-@DependsOn(CylindricalToCartesianTest.class)
-public final strictfp class CartesianToCylindricalTest extends TransformTestCase {
+@DependsOn(PolarToCartesianTest.class)
+public final strictfp class CartesianToPolarTest extends TransformTestCase {
     /**
-     * Tests coordinate conversions.
+     * Tests coordinate conversions in the polar case.
      *
      * @throws FactoryException if the transform can not be created.
      * @throws TransformException if a coordinate can not be transformed.
      */
     @Test
     public void testConversion() throws FactoryException, TransformException {
-        transform = CartesianToCylindrical.INSTANCE.completeTransform();
+        transform = CartesianToPolar.INSTANCE.completeTransform(PolarToCartesianTest.factory());
         tolerance = 1E-12;
-        final double[][] data = CylindricalToCartesianTest.testData();
+        final double[][] data = PolarToCartesianTest.testData(false);
         verifyTransform(data[1], data[0]);
     }
 
     /**
-     * Tests calculation of a transform derivative.
+     * Tests coordinate conversions in the cylindrical case.
      *
      * @throws FactoryException if the transform can not be created.
      * @throws TransformException if a coordinate can not be transformed.
      */
     @Test
+    @DependsOnMethod("testConversion")
+    public void testCylindricalConversion() throws FactoryException, TransformException {
+        transform = CartesianToPolar.INSTANCE.passthrough(PolarToCartesianTest.factory());
+        tolerance = 1E-12;
+        final double[][] data = PolarToCartesianTest.testData(true);
+        verifyTransform(data[1], data[0]);
+    }
+
+    /**
+     * Tests calculation of a transform derivative in the polar case.
+     *
+     * @throws FactoryException if the transform can not be created.
+     * @throws TransformException if a coordinate can not be transformed.
+     */
+    @Test
+    @DependsOnMethod("testConversion")
     public void testDerivative() throws FactoryException, TransformException {
-        transform = CartesianToCylindrical.INSTANCE.completeTransform();
+        transform = CartesianToPolar.INSTANCE.completeTransform(PolarToCartesianTest.factory());
+        derivativeDeltas = new double[] {1E-6, 1E-6};
+        tolerance = 1E-7;
+        verifyDerivative(30, 60);
+    }
+
+    /**
+     * Tests calculation of a transform derivative in the cylindrical case.
+     *
+     * @throws FactoryException if the transform can not be created.
+     * @throws TransformException if a coordinate can not be transformed.
+     */
+    @Test
+    @DependsOnMethod("testDerivative")
+    public void testCylindricalDerivative() throws FactoryException, TransformException {
+        transform = CartesianToPolar.INSTANCE.passthrough(PolarToCartesianTest.factory());
         derivativeDeltas = new double[] {1E-6, 1E-6, 1E-6};
         tolerance = 1E-7;
         verifyDerivative(30, 60, 100);
     }
 
     /**
-     * Tests calculation of a transform derivative.
+     * Tests calculation of a transform derivative in the polar case.
      *
      * @throws FactoryException if the transform can not be created.
      * @throws TransformException if a coordinate can not be transformed.
      */
     @Test
-    @DependsOnMethod({"testConversion", "testDerivative"})
+    @DependsOnMethod("testDerivative")
     public void testConsistency() throws FactoryException, TransformException {
-        transform = CartesianToCylindrical.INSTANCE.completeTransform();
+        transform = CartesianToPolar.INSTANCE.completeTransform(PolarToCartesianTest.factory());
+        derivativeDeltas = new double[] {1E-6, 1E-6};
+        tolerance = 2E-7;
+        verifyInDomain(new double[] {-100, -100},      // Minimal coordinates
+                       new double[] {+100, +100},      // Maximal coordinates
+                       new int[]    {  10,   10},
+                       TestUtilities.createRandomNumberGenerator());
+    }
+
+    /**
+     * Tests calculation of a transform derivative in the cylindrical case.
+     *
+     * @throws FactoryException if the transform can not be created.
+     * @throws TransformException if a coordinate can not be transformed.
+     */
+    @Test
+    @DependsOnMethod("testCylindricalDerivative")
+    public void testCylindricalConsistency() throws FactoryException, TransformException {
+        transform = CartesianToPolar.INSTANCE.passthrough(PolarToCartesianTest.factory());
         derivativeDeltas = new double[] {1E-6, 1E-6, 1E-6};
         tolerance = 2E-7;
         verifyInDomain(new double[] {-100, -100, -100},      // Minimal coordinates

Modified: sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/transform/CartesianToSphericalTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/transform/CartesianToSphericalTest.java?rev=1735454&r1=1735453&r2=1735454&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/transform/CartesianToSphericalTest.java [UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/transform/CartesianToSphericalTest.java [UTF-8] Thu Mar 17 16:32:51 2016
@@ -45,7 +45,7 @@ public final strictfp class CartesianToS
      */
     @Test
     public void testConversion() throws FactoryException, TransformException {
-        transform = CartesianToSpherical.INSTANCE.completeTransform();
+        transform = CartesianToSpherical.INSTANCE.completeTransform(SphericalToCartesianTest.factory());
         tolerance = 1E-12;
         final double[][] data = SphericalToCartesianTest.testData();
         verifyTransform(data[1], data[0]);
@@ -59,7 +59,7 @@ public final strictfp class CartesianToS
      */
     @Test
     public void testDerivative() throws FactoryException, TransformException {
-        transform = CartesianToSpherical.INSTANCE.completeTransform();
+        transform = CartesianToSpherical.INSTANCE.completeTransform(SphericalToCartesianTest.factory());
         derivativeDeltas = new double[] {1E-6, 1E-6, 1E-6};
         tolerance = 1E-7;
         verifyDerivative(30, 60, 100);
@@ -74,7 +74,7 @@ public final strictfp class CartesianToS
     @Test
     @DependsOnMethod({"testConversion", "testDerivative"})
     public void testConsistency() throws FactoryException, TransformException {
-        transform = CartesianToSpherical.INSTANCE.completeTransform();
+        transform = CartesianToSpherical.INSTANCE.completeTransform(SphericalToCartesianTest.factory());
         derivativeDeltas = new double[] {1E-6, 1E-6, 1E-6};
         tolerance = 1E-6;
         verifyInDomain(new double[] {-100, -100, -100},      // Minimal coordinates

Modified: sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/transform/CoordinateSystemTransformTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/transform/CoordinateSystemTransformTest.java?rev=1735454&r1=1735453&r2=1735454&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/transform/CoordinateSystemTransformTest.java [UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/transform/CoordinateSystemTransformTest.java [UTF-8] Thu Mar 17 16:32:51 2016
@@ -165,13 +165,14 @@ public final strictfp class CoordinateSy
     }
 
     /**
-     * Returns {@link CylindricalToCartesianTest#testData()} modified for the source and target
+     * Returns {@link PolarToCartesianTest#testData(boolean)} modified for the source and target
      * coordinate systems used in this class.
      */
-    private static double[][] cylindricalTestData() {
-        final double[][] data = CylindricalToCartesianTest.testData();
+    private static double[][] polarTestData(final boolean withHeight) {
+        final int dimension = withHeight ? 3 : 2;
+        final double[][] data = PolarToCartesianTest.testData(withHeight);
         final double[] source = data[0];
-        for (int i=1; i<source.length; i += 3) {
+        for (int i=1; i<source.length; i += dimension) {
             source[i] = -source[i];                 // Change counterclockwise direction into clockwise direction.
         }
         final double[] target = data[1];
@@ -192,7 +193,7 @@ public final strictfp class CoordinateSy
     public void testCylindricalToCartesian() throws FactoryException, TransformException {
         tolerance = 1E-9;
         transform = CoordinateSystemTransform.create(factory, HardCodedCS.CYLINDRICAL, toCentimetres(HardCodedCS.CARTESIAN_3D));
-        final double[][] data = cylindricalTestData();
+        final double[][] data = polarTestData(true);
         verifyTransform(data[0], data[1]);
     }
 
@@ -207,7 +208,37 @@ public final strictfp class CoordinateSy
     public void testCartesianToCylindrical() throws FactoryException, TransformException {
         tolerance = 1E-9;
         transform = CoordinateSystemTransform.create(factory, toCentimetres(HardCodedCS.CARTESIAN_3D), HardCodedCS.CYLINDRICAL);
-        final double[][] data = cylindricalTestData();
+        final double[][] data = polarTestData(true);
+        verifyTransform(data[1], data[0]);
+    }
+
+    /**
+     * Tests {@link CoordinateSystemTransform#create(MathTransformFactory, CoordinateSystem, CoordinateSystem)}.
+     * for a conversion from polar to Cartesian coordinates.
+     *
+     * @throws FactoryException if an error occurred while creating the transform.
+     * @throws TransformException if an error occurred while transforming the test point.
+     */
+    @Test
+    public void testPolarToCartesian() throws FactoryException, TransformException {
+        tolerance = 1E-9;
+        transform = CoordinateSystemTransform.create(factory, HardCodedCS.POLAR, toCentimetres(HardCodedCS.CARTESIAN_2D));
+        final double[][] data = polarTestData(false);
+        verifyTransform(data[0], data[1]);
+    }
+
+    /**
+     * Tests {@link CoordinateSystemTransform#create(MathTransformFactory, CoordinateSystem, CoordinateSystem)}.
+     * for a conversion from Cartesian to polar coordinates.
+     *
+     * @throws FactoryException if an error occurred while creating the transform.
+     * @throws TransformException if an error occurred while transforming the test point.
+     */
+    @Test
+    public void testCartesianToPolar() throws FactoryException, TransformException {
+        tolerance = 1E-9;
+        transform = CoordinateSystemTransform.create(factory, toCentimetres(HardCodedCS.CARTESIAN_2D), HardCodedCS.POLAR);
+        final double[][] data = polarTestData(false);
         verifyTransform(data[1], data[0]);
     }
 }

Copied: sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/transform/PolarToCartesianTest.java (from r1735209, sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/transform/CylindricalToCartesianTest.java)
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/transform/PolarToCartesianTest.java?p2=sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/transform/PolarToCartesianTest.java&p1=sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/transform/CylindricalToCartesianTest.java&r1=1735209&r2=1735454&rev=1735454&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/transform/CylindricalToCartesianTest.java [UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/transform/PolarToCartesianTest.java [UTF-8] Thu Mar 17 16:32:51 2016
@@ -18,6 +18,8 @@ package org.apache.sis.referencing.opera
 
 import org.opengis.util.FactoryException;
 import org.opengis.referencing.operation.TransformException;
+import org.opengis.referencing.operation.MathTransformFactory;
+import org.apache.sis.internal.system.DefaultFactories;
 
 import static java.lang.StrictMath.*;
 
@@ -29,25 +31,25 @@ import org.junit.Test;
 
 
 /**
- * Tests {@link CylindricalToCartesian}.
+ * Tests {@link PolarToCartesian}.
  *
  * @author  Martin Desruisseaux (Geomatys)
  * @since   0.7
  * @version 0.7
  * @module
  */
-public final strictfp class CylindricalToCartesianTest extends TransformTestCase {
+public final strictfp class PolarToCartesianTest extends TransformTestCase {
     /**
-     * Returns coordinate points in spherical coordinates and their equivalent in Cartesian coordinates.
+     * Returns coordinate points in polar or cylindrical coordinates and their equivalent in Cartesian coordinates.
      */
-    static double[][] testData() {
+    static double[][] testData(final boolean withHeight) {
         final double z     = 20;
         final double r     = 1000;
         final double cos30 = r*sqrt(0.75);      // cos(30°) = √¾
         final double cos60 = r/2;               // cos(60°) =  ½
         final double sin60 = cos30;
         final double sin30 = cos60;
-        return new double[][] {
+        double data[][] = new double[][] {
             new double[] {                      // (r,θ,z) coordinates
                  0,       0,       0,
                  r,       0,       z,
@@ -64,46 +66,115 @@ public final strictfp class CylindricalT
                  cos30,   sin30,   z
             }
         };
+        if (!withHeight) {
+            // Drop the height component.
+            for (int i=0; i<data.length; i++) {
+                final double[] source = data[i];
+                final double[] target = new double[source.length * 2/3];
+                for (int s=0, t=0; t<target.length; t++) {
+                    source[s++] = target[t++];
+                    source[s++] = target[t++];
+                }
+                data[i] = target;
+            }
+        }
+        return data;
+    }
+
+    /**
+     * Returns the factory to use for testing purpose.
+     */
+    static MathTransformFactory factory() {
+        return DefaultFactories.forBuildin(MathTransformFactory.class);
     }
 
     /**
-     * Tests coordinate conversions.
+     * Tests coordinate conversions in the polar case.
      *
      * @throws FactoryException if the transform can not be created.
      * @throws TransformException if a coordinate can not be transformed.
      */
     @Test
     public void testConversion() throws FactoryException, TransformException {
-        transform = CylindricalToCartesian.INSTANCE.completeTransform();
+        transform = PolarToCartesian.INSTANCE.completeTransform(factory());
         tolerance = 1E-12;
-        final double[][] data = testData();
+        final double[][] data = testData(false);
         verifyTransform(data[0], data[1]);
     }
 
     /**
-     * Tests calculation of a transform derivative.
+     * Tests coordinate conversions in the cylindrical case.
      *
      * @throws FactoryException if the transform can not be created.
      * @throws TransformException if a coordinate can not be transformed.
      */
     @Test
+    @DependsOnMethod("testConversion")
+    public void testCylindricalConversion() throws FactoryException, TransformException {
+        transform = PolarToCartesian.INSTANCE.passthrough(factory());
+        tolerance = 1E-12;
+        final double[][] data = testData(true);
+        verifyTransform(data[0], data[1]);
+    }
+
+    /**
+     * Tests calculation of a transform derivative in the polar case.
+     *
+     * @throws FactoryException if the transform can not be created.
+     * @throws TransformException if a coordinate can not be transformed.
+     */
+    @Test
+    @DependsOnMethod("testConversion")
     public void testDerivative() throws FactoryException, TransformException {
-        transform = CylindricalToCartesian.INSTANCE.completeTransform();
+        transform = PolarToCartesian.INSTANCE.completeTransform(factory());
+        derivativeDeltas = new double[] {1E-6, 1E-6};
+        tolerance = 1E-7;
+        verifyDerivative(100, 60);
+    }
+
+    /**
+     * Tests calculation of a transform derivative in the cylindrical case.
+     *
+     * @throws FactoryException if the transform can not be created.
+     * @throws TransformException if a coordinate can not be transformed.
+     */
+    @Test
+    @DependsOnMethod("testDerivative")
+    public void testCylindricalDerivative() throws FactoryException, TransformException {
+        transform = PolarToCartesian.INSTANCE.passthrough(factory());
         derivativeDeltas = new double[] {1E-6, 1E-6, 1E-6};
         tolerance = 1E-7;
         verifyDerivative(100, 60, 25);
     }
 
     /**
-     * Tests calculation of a transform derivative.
+     * Tests calculation of a transform derivative in the polar case.
      *
      * @throws FactoryException if the transform can not be created.
      * @throws TransformException if a coordinate can not be transformed.
      */
     @Test
-    @DependsOnMethod({"testConversion", "testDerivative"})
+    @DependsOnMethod("testDerivative")
     public void testConsistency() throws FactoryException, TransformException {
-        transform = CylindricalToCartesian.INSTANCE.completeTransform();
+        transform = PolarToCartesian.INSTANCE.completeTransform(factory());
+        derivativeDeltas = new double[] {1E-6, 1E-6};
+        tolerance = 1E-7;
+        verifyInDomain(new double[] {  0, -180},      // Minimal coordinates
+                       new double[] {+20, +180},      // Maximal coordinates
+                       new int[]    { 10,   10},
+                       TestUtilities.createRandomNumberGenerator());
+    }
+
+    /**
+     * Tests calculation of a transform derivative in the cylindrical case.
+     *
+     * @throws FactoryException if the transform can not be created.
+     * @throws TransformException if a coordinate can not be transformed.
+     */
+    @Test
+    @DependsOnMethod("testCylindricalDerivative")
+    public void testCylindricalConsistency() throws FactoryException, TransformException {
+        transform = PolarToCartesian.INSTANCE.passthrough(factory());
         derivativeDeltas = new double[] {1E-6, 1E-6, 1E-6};
         tolerance = 1E-7;
         verifyInDomain(new double[] {  0, -180, -100},      // Minimal coordinates

Modified: sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/transform/SphericalToCartesianTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/transform/SphericalToCartesianTest.java?rev=1735454&r1=1735453&r2=1735454&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/transform/SphericalToCartesianTest.java [UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/transform/SphericalToCartesianTest.java [UTF-8] Thu Mar 17 16:32:51 2016
@@ -18,6 +18,8 @@ package org.apache.sis.referencing.opera
 
 import org.opengis.util.FactoryException;
 import org.opengis.referencing.operation.TransformException;
+import org.opengis.referencing.operation.MathTransformFactory;
+import org.apache.sis.internal.system.DefaultFactories;
 
 import static java.lang.StrictMath.*;
 
@@ -74,6 +76,13 @@ public final strictfp class SphericalToC
     }
 
     /**
+     * Returns the factory to use for testing purpose.
+     */
+    static MathTransformFactory factory() {
+        return DefaultFactories.forBuildin(MathTransformFactory.class);
+    }
+
+    /**
      * Tests coordinate conversions.
      *
      * @throws FactoryException if the transform can not be created.
@@ -81,7 +90,7 @@ public final strictfp class SphericalToC
      */
     @Test
     public void testConversion() throws FactoryException, TransformException {
-        transform = SphericalToCartesian.INSTANCE.completeTransform();
+        transform = SphericalToCartesian.INSTANCE.completeTransform(factory());
         tolerance = 1E-12;
         final double[][] data = testData();
         verifyTransform(data[0], data[1]);
@@ -95,7 +104,7 @@ public final strictfp class SphericalToC
      */
     @Test
     public void testDerivative() throws FactoryException, TransformException {
-        transform = SphericalToCartesian.INSTANCE.completeTransform();
+        transform = SphericalToCartesian.INSTANCE.completeTransform(factory());
         derivativeDeltas = new double[] {1E-6, 1E-6, 1E-6};
         tolerance = 1E-7;
         verifyDerivative(30, 60, 100);
@@ -110,7 +119,7 @@ public final strictfp class SphericalToC
     @Test
     @DependsOnMethod({"testConversion", "testDerivative"})
     public void testConsistency() throws FactoryException, TransformException {
-        transform = SphericalToCartesian.INSTANCE.completeTransform();
+        transform = SphericalToCartesian.INSTANCE.completeTransform(factory());
         derivativeDeltas = new double[] {1E-6, 1E-6, 1E-6};
         tolerance = 1E-7;
         verifyInDomain(new double[] {-180, -90,   0},       // Minimal coordinates

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=1735454&r1=1735453&r2=1735454&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] Thu Mar 17 16:32:51 2016
@@ -91,6 +91,7 @@ import org.junit.BeforeClass;
     org.apache.sis.referencing.cs.DefaultCartesianCSTest.class,
     org.apache.sis.referencing.cs.DefaultEllipsoidalCSTest.class,
     org.apache.sis.referencing.cs.DefaultSphericalCSTest.class,
+    org.apache.sis.referencing.cs.DefaultPolarCSTest.class,
     org.apache.sis.referencing.cs.DefaultCylindricalCSTest.class,
     org.apache.sis.referencing.cs.DefaultCompoundCSTest.class,
     org.apache.sis.referencing.cs.CoordinateSystemsTest.class,
@@ -124,8 +125,8 @@ import org.junit.BeforeClass;
     org.apache.sis.referencing.operation.transform.MolodenskyTransformTest.class,
     org.apache.sis.referencing.operation.transform.SphericalToCartesianTest.class,
     org.apache.sis.referencing.operation.transform.CartesianToSphericalTest.class,
-    org.apache.sis.referencing.operation.transform.CylindricalToCartesianTest.class,
-    org.apache.sis.referencing.operation.transform.CartesianToCylindricalTest.class,
+    org.apache.sis.referencing.operation.transform.PolarToCartesianTest.class,
+    org.apache.sis.referencing.operation.transform.CartesianToPolarTest.class,
     org.apache.sis.referencing.operation.transform.CoordinateSystemTransformTest.class,
     org.apache.sis.referencing.operation.DefaultFormulaTest.class,
     org.apache.sis.referencing.operation.DefaultOperationMethodTest.class,



Mime
View raw message