sis-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From desruisse...@apache.org
Subject svn commit: r1735177 - in /sis/branches/JDK8/core: sis-metadata/src/main/java/org/apache/sis/internal/metadata/ sis-referencing/src/main/java/org/apache/sis/referencing/operation/ sis-referencing/src/main/java/org/apache/sis/referencing/operation/trans...
Date Tue, 15 Mar 2016 23:14:39 GMT
Author: desruisseaux
Date: Tue Mar 15 23:14:39 2016
New Revision: 1735177

URL: http://svn.apache.org/viewvc?rev=1735177&view=rev
Log:
Add conversion between cylindrical and Cartesian coordinate systems.

Added:
    sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/CartesianToCylindrical.java
      - copied, changed from r1735066, sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/CartesianToSpherical.java
    sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/CylindricalToCartesian.java
      - copied, changed from r1735066, sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/SphericalToCartesian.java
    sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/transform/CartesianToCylindricalTest.java
      - copied, changed from r1735066, 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/CylindricalToCartesianTest.java
      - copied, changed from r1735066, sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/transform/SphericalToCartesianTest.java
Modified:
    sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/internal/metadata/AxisDirections.java
    sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/CoordinateOperationInference.java
    sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/CartesianToSpherical.java
    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/SphericalToCartesian.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

Modified: sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/internal/metadata/AxisDirections.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/internal/metadata/AxisDirections.java?rev=1735177&r1=1735176&r2=1735177&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/internal/metadata/AxisDirections.java [UTF-8] (original)
+++ sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/internal/metadata/AxisDirections.java [UTF-8] Tue Mar 15 23:14:39 2016
@@ -16,6 +16,8 @@
  */
 package org.apache.sis.internal.metadata;
 
+import java.util.Map;
+import java.util.HashMap;
 import javax.measure.unit.Unit;
 import javax.measure.quantity.Angle;
 import org.opengis.referencing.cs.AxisDirection;
@@ -36,7 +38,7 @@ import static org.apache.sis.util.CharSe
  *
  * @author  Martin Desruisseaux (Geomatys)
  * @since   0.4
- * @version 0.6
+ * @version 0.7
  * @module
  */
 public final class AxisDirections extends Static {
@@ -59,9 +61,26 @@ public final class AxisDirections extend
     public static final int DISPLAY_COUNT = 4;
 
     /**
+     * Direction of geographic angles (azimuths).
+     * Specified in ISO 19162 but not yet in ISO 19111.
+     *
+     * @since 0.7
+     */
+    public static final AxisDirection CLOCKWISE = AxisDirection.valueOf("CLOCKWISE");
+
+    /**
+     * Direction of arithmetic angles. Used in polar coordinate systems.
+     * Specified in ISO 19162 but not yet in ISO 19111.
+     *
+     * @since 0.7
+     */
+    public static final AxisDirection COUNTERCLOCKWISE = AxisDirection.valueOf("COUNTERCLOCKWISE");
+
+    /**
      * For each direction, the opposite direction.
+     * This map shall be immutable after construction.
      */
-    private static final AxisDirection[] OPPOSITES = new AxisDirection[DISPLAY_DOWN.ordinal() + 1];
+    private static final Map<AxisDirection,AxisDirection> OPPOSITES = new HashMap<>(20);
     static {
         put(OTHER,            OTHER);
         put(NORTH,            SOUTH);
@@ -78,14 +97,15 @@ public final class AxisDirections extend
         put(ROW_POSITIVE,     ROW_NEGATIVE);
         put(DISPLAY_RIGHT,    DISPLAY_LEFT);
         put(DISPLAY_UP,       DISPLAY_DOWN);
+        put(COUNTERCLOCKWISE, CLOCKWISE);
     }
 
     /**
      * Stores the given directions in the {@link #OPPOSITES} array.
      */
     private static void put(final AxisDirection dir, final AxisDirection opposite) {
-        OPPOSITES[dir.ordinal()] = opposite;
-        OPPOSITES[opposite.ordinal()] = dir;
+        OPPOSITES.put(dir, opposite);
+        OPPOSITES.put(opposite, dir);
     }
 
     /**
@@ -114,24 +134,25 @@ public final class AxisDirections extend
      *     <th style="width: 50%">Direction</th>
      *     <th style="width: 50%">Absolute value</th>
      *   </tr>
-     *   <tr><td>{@code NORTH}</td> <td>{@code NORTH}</td> </tr>
-     *   <tr><td>{@code SOUTH}</td> <td>{@code NORTH}</td> </tr>
-     *   <tr><td>{@code EAST}</td>  <td>{@code EAST}</td>  </tr>
-     *   <tr><td>{@code WEST}</td>  <td>{@code EAST}</td>  </tr>
-     *   <tr><td>{@code UP}</td>    <td>{@code UP}</td>    </tr>
-     *   <tr><td>{@code DOWN}</td>  <td>{@code UP}</td>    </tr>
+     *   <tr><td>{@code NORTH}</td> <td>{@code NORTH}</td></tr>
+     *   <tr><td>{@code SOUTH}</td> <td>{@code NORTH}</td></tr>
+     *   <tr><td>{@code EAST}</td>  <td>{@code EAST}</td></tr>
+     *   <tr><td>{@code WEST}</td>  <td>{@code EAST}</td></tr>
+     *   <tr><td>{@code UP}</td>    <td>{@code UP}</td></tr>
+     *   <tr><td>{@code DOWN}</td>  <td>{@code UP}</td></tr>
      * </table></td>
      * <td><table class="sis" summary="Other directions">
      *   <tr>
      *     <th style="width: 50%">Direction</th>
      *     <th style="width: 50%">Absolute value</th>
      *   </tr>
-     *   <tr><td>{@code DISPLAY_RIGHT}</td> <td>{@code DISPLAY_RIGHT}</td> </tr>
-     *   <tr><td>{@code DISPLAY_LEFT}</td>  <td>{@code DISPLAY_RIGHT}</td> </tr>
-     *   <tr><td>{@code DISPLAY_UP}</td>    <td>{@code DISPLAY_UP}</td>    </tr>
-     *   <tr><td>{@code DISPLAY_DOWN}</td>  <td>{@code DISPLAY_UP}</td>    </tr>
-     *   <tr><td>{@code FUTURE}</td>        <td>{@code FUTURE}</td>        </tr>
-     *   <tr><td>{@code PAST}</td>          <td>{@code FUTURE}</td>        </tr>
+     *   <tr><td>{@code DISPLAY_RIGHT}</td> <td>{@code DISPLAY_RIGHT}</td></tr>
+     *   <tr><td>{@code DISPLAY_LEFT}</td>  <td>{@code DISPLAY_RIGHT}</td></tr>
+     *   <tr><td>{@code DISPLAY_UP}</td>    <td>{@code DISPLAY_UP}</td></tr>
+     *   <tr><td>{@code DISPLAY_DOWN}</td>  <td>{@code DISPLAY_UP}</td></tr>
+     *   <tr><td>{@code FUTURE}</td>        <td>{@code FUTURE}</td></tr>
+     *   <tr><td>{@code PAST}</td>          <td>{@code FUTURE}</td></tr>
+     *   <tr><td>{@code CLOCKWISE}</td>     <td>{@code COUNTERCLOCKWISE}</td></tr>
      * </table></td></tr>
      *   <tr align="center"><td>{@code OTHER}</td><td>{@code OTHER}</td></tr>
      * </table>
@@ -159,13 +180,7 @@ public final class AxisDirections extend
      * @return The opposite direction, or {@code null} if none or unknown.
      */
     public static AxisDirection opposite(AxisDirection dir) {
-        if (dir != null) {
-            final int ordinal = dir.ordinal();
-            if (ordinal >= 0 && ordinal < OPPOSITES.length) {
-                dir = OPPOSITES[ordinal];
-            }
-        }
-        return dir;
+        return OPPOSITES.get(dir);
     }
 
     /**
@@ -291,7 +306,7 @@ public final class AxisDirections extend
             final int tgt = target.ordinal() - base;
             if (tgt >= 0 && tgt < GEOCENTRIC_COUNT) {
                 int n = (tgt - src);
-                n -= GEOCENTRIC_COUNT * (n/2); // If -2 add 3.  If +2 subtract 3.  Otherwise do nothing.
+                n -= GEOCENTRIC_COUNT * (n/2);      // If -2 add 3.  If +2 subtract 3.  Otherwise do nothing.
                 return n;
             }
         }
@@ -376,12 +391,12 @@ public final class AxisDirections extend
         if (cs != null) {
             for (int i = cs.getDimension(); --i>=0;) {
                 final CoordinateSystemAxis axis = cs.getAxis(i);
-                if (axis != null) {  // Paranoiac check.
+                if (axis != null) {                                                     // Paranoiac check.
                     final Unit<?> candidate = axis.getUnit();
                     if (Units.isAngular(candidate)) {
                         unit = candidate.asType(Angle.class);
                         if (AxisDirection.EAST.equals(absolute(axis.getDirection()))) {
-                            break; // Found the longitude axis.
+                            break;                                                      // Found the longitude axis.
                         }
                     }
                 }
@@ -434,7 +449,7 @@ public final class AxisDirections extend
             if (dim + i > cs.getDimension()) {
                 return -1;
             }
-            while (--i > 0) { // Intentionally exclude 0.
+            while (--i > 0) {               // Intentionally exclude 0.
                 if (!absolute(subCS.getAxis(i).getDirection()).equals(
                      absolute(cs.getAxis(i + dim).getDirection())))
                 {
@@ -505,12 +520,12 @@ public final class AxisDirections extend
                 int s = name.indexOf('/', d);
                 if (s < 0) {
                     if (equalsIgnoreCase(name, d, length, "north pole")) {
-                        return GEOCENTRIC_Z; // "Geocentre > north pole"
+                        return GEOCENTRIC_Z;                                // "Geocentre > north pole"
                     }
                 } else if (equalsIgnoreCase(name, d, skipTrailingWhitespaces(name, d, s), "equator")) {
                     s = skipLeadingWhitespaces(name, s+1, length);
                     if (equalsIgnoreCase(name, s, length, "PM")) {
-                        return GEOCENTRIC_X; // "Geocentre > equator/PM"
+                        return GEOCENTRIC_X;                                // "Geocentre > equator/PM"
                     }
                     /*
                      * At this point, the name may be "Geocentre > equator/0°E",
@@ -527,8 +542,8 @@ public final class AxisDirections extend
                             i = skipLeadingWhitespaces(name, i, length);
                             if (equalsIgnoreCase(name, i, length, "°E") || equalsIgnoreCase(name, i, length, "dE")) {
                                 switch (n) {
-                                    case  0: return GEOCENTRIC_X; // "Geocentre > equator/0°E"
-                                    case 90: return GEOCENTRIC_Y; // "Geocentre > equator/90°E"
+                                    case  0: return GEOCENTRIC_X;           // "Geocentre > equator/0°E"
+                                    case 90: return GEOCENTRIC_Y;           // "Geocentre > equator/90°E"
                                 }
                             }
                             break;
@@ -569,7 +584,7 @@ public final class AxisDirections extend
      */
     public static String suggestAbbreviation(final String name, final AxisDirection direction, final Unit<?> unit) {
         if (name.length() == 1) {
-            return name;  // Most common cases are "x", "y", "z", "t", "i" and "j".
+            return name;                    // Most common cases are "x", "y", "z", "t", "i" and "j".
         }
         if (isCompass(direction)) {
             /*
@@ -612,7 +627,7 @@ public final class AxisDirections extend
             } else if (DISPLAY_UP.equals(a)) {
                 return "y";
             } else if (OTHER.equals(a)) {
-                return "z";  // Arbitrary abbreviation, may change in any future SIS version.
+                return "z";                     // Arbitrary abbreviation, may change in any future SIS version.
             }
         }
         final String id = direction.identifier();   // UML identifier, or null if none.

Modified: sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/CoordinateOperationInference.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/CoordinateOperationInference.java?rev=1735177&r1=1735176&r2=1735177&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/CoordinateOperationInference.java [UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/CoordinateOperationInference.java [UTF-8] Tue Mar 15 23:14:39 2016
@@ -350,6 +350,20 @@ public class CoordinateOperationInferenc
          */
         Matrix datumShift = null;
         Identifier identifier = DATUM_SHIFT;
+        final GeodeticDatum datum = null;//TemporaryDatum.unwrap(sourceDatum);
+//        if (datum instanceof DefaultGeodeticDatum) {
+//            datumShift = ((DefaultGeodeticDatum) datum).getPositionVectorTransformation(
+//                    TemporaryDatum.unwrap(targetDatum), null);
+//        }
+//        if (datumShift == null) {
+//            if (lenientDatumShift) {
+//                datumShift = new Matrix4(); // Identity transform.
+//                identifier = ELLIPSOID_CHANGE;
+//            } else {
+//                throw new OperationNotFoundException(Errors.format(
+//                            Errors.Keys.BursaWolfParametersRequired));
+//            }
+//        }
         MatrixSIS matrix;
         final CartesianCS standard = (CartesianCS) CommonCRS.WGS84.geocentric().getCoordinateSystem();
         final Matrix normalizeSource = swapAndScaleAxes(sourceCS, standard);

Copied: sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/CartesianToCylindrical.java (from r1735066, sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/CartesianToSpherical.java)
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/CartesianToCylindrical.java?p2=sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/CartesianToCylindrical.java&p1=sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/CartesianToSpherical.java&r1=1735066&r2=1735177&rev=1735177&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/CartesianToSpherical.java [UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/CartesianToCylindrical.java [UTF-8] Tue Mar 15 23:14:39 2016
@@ -18,43 +18,37 @@ package org.apache.sis.referencing.opera
 
 import java.util.Arrays;
 import java.io.Serializable;
-import org.opengis.referencing.cs.CartesianCS;
-import org.opengis.referencing.cs.CoordinateSystem;
 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.CommonCRS;
+import org.apache.sis.internal.util.DoubleDouble;
 
 import static java.lang.Math.*;
 
 
 /**
  * Conversions from three-dimensional Cartesian coordinates to spherical coordinates.
+ * This class is also used for polar conversions by just dropping the <var>z</var> ordinate.
  * This conversion assumes that there is no datum change.
  *
- * <p>See {@link SphericalToCartesian} for explanation on axes convention.</p>
+ * <p>See {@link CylindricalToCartesian} for explanation on axes convention.</p>
  *
  * @author  Martin Desruisseaux (Geomatys)
  * @since   0.7
  * @version 0.7
  * @module
  */
-final class CartesianToSpherical extends CoordinateSystemTransform implements Serializable {
+final class CartesianToCylindrical extends CoordinateSystemTransform implements Serializable {
     /**
      * For cross-version compatibility.
      */
-    private static final long serialVersionUID = 7174557821232512348L;
-
-    /**
-     * The source coordinate system.
-     */
-    static final CartesianCS SOURCE = (CartesianCS) CommonCRS.WGS84.geocentric().getCoordinateSystem();
+    private static final long serialVersionUID = -2619855017534519721L;
 
     /**
      * The singleton instance computing output coordinates are in radians.
      * For the instance computing output coordinates in degrees, use {@link #completeTransform()} instead.
      */
-    static final CartesianToSpherical INSTANCE = new CartesianToSpherical();
+    static final CartesianToCylindrical INSTANCE = new CartesianToCylindrical();
 
     /**
      * Returns the singleton instance on deserialization.
@@ -67,9 +61,10 @@ final class CartesianToSpherical extends
      * Creates the singleton instance.
      * Output coordinates are in radians.
      */
-    private CartesianToSpherical() {
-        super("Cartesian to Spherical", 3);
-        context.denormalizeGeographicOutputs(0);                // Convert (θ,Ω) from radians to degrees.
+    private CartesianToCylindrical() {
+        super("Cartesian to cylindrical");
+        context.getMatrix(ContextualParameters.MatrixRole.DENORMALIZATION)
+               .convertAfter(1, DoubleDouble.createRadiansToDegrees(), null);
     }
 
     /**
@@ -77,25 +72,7 @@ final class CartesianToSpherical extends
      */
     @Override
     public MathTransform inverse() {
-        return SphericalToCartesian.INSTANCE;
-    }
-
-    /**
-     * Returns the source coordinate system of the complete math transform.
-     * Angular units shall be degrees.
-     */
-    @Override
-    final CoordinateSystem getSourceCS() {
-        return SOURCE;
-    }
-
-    /**
-     * Returns the target coordinate system of the complete math transform.
-     * Angular units shall be degrees.
-     */
-    @Override
-    final CoordinateSystem getTargetCS() {
-        return SphericalToCartesian.SOURCE;
+        return CylindricalToCartesian.INSTANCE;
     }
 
     /**
@@ -106,24 +83,22 @@ final class CartesianToSpherical extends
                             final double[] dstPts, final int dstOff,
                             final boolean derivate)
     {
-        final double X  = srcPts[srcOff  ];
-        final double Y  = srcPts[srcOff+1];
-        final double Z  = srcPts[srcOff+2];
-        final double ρ2 = X*X + Y*Y;
-        final double r2 = Z*Z + ρ2;
-        final double r  = sqrt(r2);
+        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  ] = atan2(Y, X);                     // Spherical longitude (θ)
-            dstPts[dstOff+1] = (r == 0) ? Z : asin(Z / r);      // Spherical latitude  (Ω). If (X,Y,Z) is (0,0,0) take the sign of Z.
-            dstPts[dstOff+2] = r;
+            dstPts[dstOff  ] = r;
+            dstPts[dstOff+1] = atan2(y, x);
+            dstPts[dstOff+2] = z;
         }
         if (!derivate) {
             return null;
         }
-        final double d  = r2 * sqrt(r2 - Z*Z);
-        return new Matrix3(-Y/ρ2,   X/ρ2,     0,        // ∂θ/∂X, ∂θ/∂Y, ∂θ/∂Z
-                           -X*Z/d, -Y*Z/d, ρ2/d,        // ∂Ω/∂X, ∂Ω/∂Y, ∂Ω/∂Z
-                            X/r,    Y/r,   Z/r);        // ∂r/∂X, ∂r/∂Y, ∂r/∂Z
+        final double r2 = r*r;
+        return new Matrix3(x/r,   y/r,   0,
+                          -y/r2,  x/r2,  0,
+                           0,     0,     1);
     }
 
     /**
@@ -155,13 +130,12 @@ final class CartesianToSpherical extends
             }
         }
         while (--numPts >= 0) {
-            final double X  = srcPts[srcOff++];
-            final double Y  = srcPts[srcOff++];
-            final double Z  = srcPts[srcOff++];
-            final double r  = sqrt(X*X + Y*Y + Z*Z);
-            dstPts[dstOff++] = atan2(Y, X);                     // Spherical longitude (θ)
-            dstPts[dstOff++] = (r == 0) ? Z : asin(Z / r);      // Spherical latitude  (Ω). If (X,Y,Z) is (0,0,0) take the sign of Z.
-            dstPts[dstOff++] = r;
+            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;
         }
@@ -171,7 +145,7 @@ final class CartesianToSpherical extends
      * 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 EllipsoidToCentricTransform is at the beginning or the end of a transformation chain,
+     *       this CartesianToCylindrical 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/CartesianToSpherical.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/CartesianToSpherical.java?rev=1735177&r1=1735176&r2=1735177&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/CartesianToSpherical.java [UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/CartesianToSpherical.java [UTF-8] Tue Mar 15 23:14:39 2016
@@ -18,12 +18,9 @@ package org.apache.sis.referencing.opera
 
 import java.util.Arrays;
 import java.io.Serializable;
-import org.opengis.referencing.cs.CartesianCS;
-import org.opengis.referencing.cs.CoordinateSystem;
 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.CommonCRS;
 
 import static java.lang.Math.*;
 
@@ -46,11 +43,6 @@ final class CartesianToSpherical extends
     private static final long serialVersionUID = 7174557821232512348L;
 
     /**
-     * The source coordinate system.
-     */
-    static final CartesianCS SOURCE = (CartesianCS) CommonCRS.WGS84.geocentric().getCoordinateSystem();
-
-    /**
      * The singleton instance computing output coordinates are in radians.
      * For the instance computing output coordinates in degrees, use {@link #completeTransform()} instead.
      */
@@ -68,7 +60,7 @@ final class CartesianToSpherical extends
      * Output coordinates are in radians.
      */
     private CartesianToSpherical() {
-        super("Cartesian to Spherical", 3);
+        super("Cartesian to spherical");
         context.denormalizeGeographicOutputs(0);                // Convert (θ,Ω) from radians to degrees.
     }
 
@@ -81,24 +73,6 @@ final class CartesianToSpherical extends
     }
 
     /**
-     * Returns the source coordinate system of the complete math transform.
-     * Angular units shall be degrees.
-     */
-    @Override
-    final CoordinateSystem getSourceCS() {
-        return SOURCE;
-    }
-
-    /**
-     * Returns the target coordinate system of the complete math transform.
-     * Angular units shall be degrees.
-     */
-    @Override
-    final CoordinateSystem getTargetCS() {
-        return SphericalToCartesian.SOURCE;
-    }
-
-    /**
      * Converts a single coordinate and optionally computes the derivative.
      */
     @Override
@@ -120,7 +94,7 @@ final class CartesianToSpherical extends
         if (!derivate) {
             return null;
         }
-        final double d  = r2 * sqrt(r2 - Z*Z);
+        final double d = r2 * sqrt(r2 - Z*Z);
         return new Matrix3(-Y/ρ2,   X/ρ2,     0,        // ∂θ/∂X, ∂θ/∂Y, ∂θ/∂Z
                            -X*Z/d, -Y*Z/d, ρ2/d,        // ∂Ω/∂X, ∂Ω/∂Y, ∂Ω/∂Z
                             X/r,    Y/r,   Z/r);        // ∂r/∂X, ∂r/∂Y, ∂r/∂Z
@@ -171,7 +145,7 @@ final class CartesianToSpherical extends
      * 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 EllipsoidToCentricTransform is at the beginning or the end of a transformation chain,
+     *       this CartesianToSpherical 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=1735177&r1=1735176&r2=1735177&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] Tue Mar 15 23:14:39 2016
@@ -23,6 +23,7 @@ import org.opengis.util.FactoryException
 import org.opengis.parameter.ParameterValueGroup;
 import org.opengis.referencing.cs.CartesianCS;
 import org.opengis.referencing.cs.CoordinateSystem;
+import org.opengis.referencing.cs.CylindricalCS;
 import org.opengis.referencing.cs.SphericalCS;
 import org.opengis.referencing.operation.MathTransform;
 import org.opengis.referencing.operation.MathTransformFactory;
@@ -33,6 +34,8 @@ import org.apache.sis.internal.util.Cons
 import org.apache.sis.metadata.iso.ImmutableIdentifier;
 import org.apache.sis.metadata.iso.citation.Citations;
 import org.apache.sis.parameter.DefaultParameterDescriptorGroup;
+import org.apache.sis.referencing.cs.AbstractCS;
+import org.apache.sis.referencing.cs.AxesConvention;
 import org.apache.sis.referencing.cs.CoordinateSystems;
 import org.apache.sis.referencing.operation.DefaultOperationMethod;
 import org.apache.sis.util.resources.Errors;
@@ -63,10 +66,10 @@ abstract class CoordinateSystemTransform
      * Subclasses may need to invoke {@link ContextualParameters#normalizeGeographicInputs(double)}
      * or {@link ContextualParameters#denormalizeGeographicOutputs(double)} after this constructor.
      */
-    CoordinateSystemTransform(final String method, final int dimension) {
+    CoordinateSystemTransform(final String method) {
         final Map<String,?> properties = Collections.singletonMap(DefaultOperationMethod.NAME_KEY,
                 new ImmutableIdentifier(Citations.SIS, Constants.SIS, method));
-        context = new ContextualParameters(new DefaultOperationMethod(properties, dimension, dimension,
+        context = new ContextualParameters(new DefaultOperationMethod(properties, 3, 3,
                 new DefaultParameterDescriptorGroup(properties, 1, 1)));
     }
 
@@ -83,24 +86,12 @@ abstract class CoordinateSystemTransform
     }
 
     /**
-     * Returns the source coordinate system of the complete math transform.
-     * Angular units shall be degrees.
-     */
-    abstract CoordinateSystem getSourceCS();
-
-    /**
-     * Returns the target coordinate system of the complete math transform.
-     * Angular units shall be degrees.
-     */
-    abstract CoordinateSystem getTargetCS();
-
-    /**
      * Returns the number of dimensions in the source coordinate points.
      * Shall be equals to {@code getSourceCS().getDimension()}.
      */
     @Override
     public final int getSourceDimensions() {
-        return getSourceCS().getDimension();
+        return 3;
     }
 
     /**
@@ -109,7 +100,7 @@ abstract class CoordinateSystemTransform
      */
     @Override
     public final int getTargetDimensions() {
-        return getTargetCS().getDimension();
+        return 3;
     }
 
     /**
@@ -142,11 +133,17 @@ abstract class CoordinateSystemTransform
         if (source instanceof CartesianCS) {
             if (target instanceof SphericalCS) {
                 tr = CartesianToSpherical.INSTANCE;
+            } else if (target instanceof CylindricalCS) {
+                tr = CartesianToCylindrical.INSTANCE;
             }
         } else if (source instanceof SphericalCS) {
             if (target instanceof CartesianCS) {
                 tr = SphericalToCartesian.INSTANCE;
             }
+        } else if (source instanceof CylindricalCS) {
+            if (target instanceof CartesianCS) {
+                tr = CylindricalToCartesian.INSTANCE;
+            }
         }
         Exception cause = null;
         try {
@@ -155,10 +152,8 @@ abstract class CoordinateSystemTransform
             } else if (tr.getSourceDimensions() == source.getDimension() &&
                        tr.getTargetDimensions() == target.getDimension())
             {
-                final MathTransform before = factory.createAffineTransform(CoordinateSystems.swapAndScaleAxes(source, tr.getSourceCS()));
-                final MathTransform after  = factory.createAffineTransform(CoordinateSystems.swapAndScaleAxes(tr.getTargetCS(), target));
-                return factory.createConcatenatedTransform(before,
-                       factory.createConcatenatedTransform(tr.completeTransform(), after));
+                return factory.createConcatenatedTransform(normalize(factory, source, false),
+                       factory.createConcatenatedTransform(tr.completeTransform(), normalize(factory, target, true)));
             }
         } catch (IllegalArgumentException | ConversionException e) {
             cause = e;
@@ -167,4 +162,20 @@ abstract class CoordinateSystemTransform
                 WKTUtilities.toType(CoordinateSystem.class, source.getClass()),
                 WKTUtilities.toType(CoordinateSystem.class, target.getClass())), cause);
     }
+
+    /**
+     * Returns the conversion between the given coordinate system and its normalized form.
+     */
+    private static MathTransform normalize(final MathTransformFactory factory, final CoordinateSystem cs,
+            final boolean inverse) throws FactoryException, ConversionException
+    {
+        AbstractCS source = AbstractCS.castOrCopy(cs);
+        AbstractCS target = source.forConvention(AxesConvention.NORMALIZED);
+        if (inverse) {
+            AbstractCS tmp = source;
+            source = target;
+            target = tmp;
+        }
+        return factory.createAffineTransform(CoordinateSystems.swapAndScaleAxes(source, target));
+    }
 }

Copied: sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/CylindricalToCartesian.java (from r1735066, sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/SphericalToCartesian.java)
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/CylindricalToCartesian.java?p2=sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/CylindricalToCartesian.java&p1=sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/SphericalToCartesian.java&r1=1735066&r2=1735177&rev=1735177&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/SphericalToCartesian.java [UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/CylindricalToCartesian.java [UTF-8] Tue Mar 15 23:14:39 2016
@@ -18,64 +18,49 @@ package org.apache.sis.referencing.opera
 
 import java.util.Arrays;
 import java.io.Serializable;
-import org.opengis.referencing.cs.SphericalCS;
-import org.opengis.referencing.cs.CoordinateSystem;
 import org.opengis.referencing.operation.Matrix;
 import org.opengis.referencing.operation.MathTransform;
-import org.apache.sis.referencing.CommonCRS;
-import org.apache.sis.referencing.cs.AxesConvention;
-import org.apache.sis.referencing.crs.DefaultGeocentricCRS;
 import org.apache.sis.referencing.operation.matrix.Matrix3;
+import org.apache.sis.internal.util.DoubleDouble;
 
 import static java.lang.Math.*;
 
 
 /**
- * Conversions from spherical coordinates to three-dimensional Cartesian coordinates.
- * This conversion assumes that there is no datum change. Axis order is:
+ * Conversions from cylindrical coordinates to three-dimensional Cartesian coordinates.
+ * This class is also used for polar conversions by just dropping the <var>z</var> ordinate.
+ * This conversion assumes that there is no datum change. Source axis order is:
  *
  * <ul>
- *   <li>Spherical longitude (θ), also noted Ω or λ.</li>
- *   <li>Spherical latitude (Ω), also noted θ or φ′ (confusing).</li>
- *   <li>Spherical radius (r), also noted <var>r</var> in ISO 19111.</li>
+ *   <li>Radius (r)</li>
+ *   <li>Angle  (θ)</li>
+ *   <li>Height (z)</li>
  * </ul>
- * <div class="note"><b>Note:</b>
- * the spherical latitude is related to geodetic latitude φ by {@literal Ω(φ) = atan((1-ℯ²)⋅tan(φ))}.</div>
  *
- * This order matches the {@link EllipsoidToCentricTransform} axis order.
- * Note that this is <strong>not</strong> the convention used neither in physics (ISO 80000-2:2009) or in mathematics.
+ * Target axis order is:
  *
- * <div class="note"><b>Relationship with the convention used in physics</b>
- * The ISO 80000-2 convention is (r,Ω,φ) where φ is like the spherical longitude, and Ω is measured from
- * the Z axis (North pole) instead than from the equator plane. The consequence in the formulas is that
- * {@code sin(Ω)} needs to be replaced by {@code cos(Ω)} and conversely.</div>
+ * <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>
+ * </ul>
  *
  * @author  Martin Desruisseaux (Geomatys)
  * @since   0.7
  * @version 0.7
  * @module
- *
- * @see CartesianToSpherical
- * @see EllipsoidToCentricTransform
- * @see <a href="https://en.wikipedia.org/wiki/Spherical_coordinate_system">Spherical coordinate system on Wikipedia</a>
  */
-final class SphericalToCartesian extends CoordinateSystemTransform implements Serializable {
+final class CylindricalToCartesian extends CoordinateSystemTransform implements Serializable {
     /**
      * For cross-version compatibility.
      */
-    private static final long serialVersionUID = 8001536207920751506L;
-
-    /**
-     * The source coordinate system.
-     */
-    static final SphericalCS SOURCE = (SphericalCS) DefaultGeocentricCRS.castOrCopy(CommonCRS.WGS84.spherical())
-            .forConvention(AxesConvention.RIGHT_HANDED).getCoordinateSystem();
+    private static final long serialVersionUID = 3447323620543409532L;
 
     /**
      * The singleton instance expecting input coordinates in radians.
      * For the instance expecting input coordinates in degrees, use {@link #completeTransform()} instead.
      */
-    static final SphericalToCartesian INSTANCE = new SphericalToCartesian();
+    static final CylindricalToCartesian INSTANCE = new CylindricalToCartesian();
 
     /**
      * Returns the singleton instance on deserialization.
@@ -88,9 +73,10 @@ final class SphericalToCartesian extends
      * Creates the singleton instance.
      * Input coordinates are in radians.
      */
-    private SphericalToCartesian() {
-        super("Spherical to Cartesian", 3);
-        context.normalizeGeographicInputs(0);                   // Convert (θ,Ω) from degrees to radians.
+    private CylindricalToCartesian() {
+        super("Cylindrical to Cartesian");
+        context.getMatrix(ContextualParameters.MatrixRole.NORMALIZATION)
+               .convertBefore(1, DoubleDouble.createDegreesToRadians(), null);
     }
 
     /**
@@ -98,25 +84,7 @@ final class SphericalToCartesian extends
      */
     @Override
     public MathTransform inverse() {
-        return CartesianToSpherical.INSTANCE;
-    }
-
-    /**
-     * Returns the source coordinate system of the complete math transform.
-     * Angular units shall be degrees.
-     */
-    @Override
-    final CoordinateSystem getSourceCS() {
-        return SOURCE;
-    }
-
-    /**
-     * Returns the target coordinate system of the complete math transform.
-     * Angular units shall be degrees.
-     */
-    @Override
-    final CoordinateSystem getTargetCS() {
-        return CartesianToSpherical.SOURCE;
+        return CartesianToCylindrical.INSTANCE;
     }
 
     /**
@@ -127,28 +95,22 @@ final class SphericalToCartesian extends
                             final double[] dstPts, final int dstOff,
                             final boolean derivate)
     {
-        final double θ = srcPts[srcOff  ];          // Spherical longitude
-        final double Ω = srcPts[srcOff+1];          // Spherical latitude
-        final double r = srcPts[srcOff+2];          // Spherical radius
+        final double r = srcPts[srcOff  ];
+        final double θ = srcPts[srcOff+1];
+        final double z = srcPts[srcOff+2];
         final double cosθ = cos(θ);
         final double sinθ = sin(θ);
-        final double cosΩ = cos(Ω);
-        final double sinΩ = sin(Ω);
-        final double rsinΩ = r * sinΩ;
-        final double rcosΩ = r * cosΩ;
         if (dstPts != null) {
-            dstPts[dstOff  ] = rcosΩ * cosθ;        // X: Toward prime meridian
-            dstPts[dstOff+1] = rcosΩ * sinθ;        // Y: Toward 90° east
-            dstPts[dstOff+2] = rsinΩ;               // Z: Toward north pole
+            dstPts[dstOff  ] = r*cosθ;
+            dstPts[dstOff+1] = r*sinθ;
+            dstPts[dstOff+2] = z;
         }
         if (!derivate) {
             return null;
         }
-        final double dX_dr = cosΩ * cosθ;
-        final double dY_dr = cosΩ * sinθ;
-        return new Matrix3(-r*dY_dr, -rsinΩ*cosθ, dX_dr,       // ∂X/∂θ, ∂X/∂Ω, ∂X/∂r
-                            r*dX_dr, -rsinΩ*sinθ, dY_dr,       // ∂Y/∂θ, ∂Y/∂Ω, ∂Y/∂r
-                                  0,  rcosΩ,      sinΩ);       // ∂Z/∂θ, ∂Z/∂Ω, ∂Z/∂r
+        return new Matrix3(cosθ, -r*sinθ,  0,
+                           sinθ,  r*cosθ,  0,
+                              0,       0,  1);
     }
 
     /**
@@ -180,13 +142,12 @@ final class SphericalToCartesian extends
             }
         }
         while (--numPts >= 0) {
-            final double θ = srcPts[srcOff++];          // Spherical longitude
-            final double Ω = srcPts[srcOff++];          // Spherical latitude
-            final double r = srcPts[srcOff++];          // Spherical radius
-            final double rcosΩ = r * cos(Ω);
-            dstPts[dstOff++] = rcosΩ * cos(θ);          // X: Toward prime meridian
-            dstPts[dstOff++] = rcosΩ * sin(θ);          // Y: Toward 90° east
-            dstPts[dstOff++] = r * sin(Ω);              // Z: Toward north pole
+            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;
         }
@@ -196,7 +157,7 @@ final class SphericalToCartesian extends
      * 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 EllipsoidToCentricTransform is at the beginning or the end of a transformation chain,
+     *       this CylindricalToCartesian 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/SphericalToCartesian.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/SphericalToCartesian.java?rev=1735177&r1=1735176&r2=1735177&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/SphericalToCartesian.java [UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/SphericalToCartesian.java [UTF-8] Tue Mar 15 23:14:39 2016
@@ -18,13 +18,8 @@ package org.apache.sis.referencing.opera
 
 import java.util.Arrays;
 import java.io.Serializable;
-import org.opengis.referencing.cs.SphericalCS;
-import org.opengis.referencing.cs.CoordinateSystem;
 import org.opengis.referencing.operation.Matrix;
 import org.opengis.referencing.operation.MathTransform;
-import org.apache.sis.referencing.CommonCRS;
-import org.apache.sis.referencing.cs.AxesConvention;
-import org.apache.sis.referencing.crs.DefaultGeocentricCRS;
 import org.apache.sis.referencing.operation.matrix.Matrix3;
 
 import static java.lang.Math.*;
@@ -66,12 +61,6 @@ final class SphericalToCartesian extends
     private static final long serialVersionUID = 8001536207920751506L;
 
     /**
-     * The source coordinate system.
-     */
-    static final SphericalCS SOURCE = (SphericalCS) DefaultGeocentricCRS.castOrCopy(CommonCRS.WGS84.spherical())
-            .forConvention(AxesConvention.RIGHT_HANDED).getCoordinateSystem();
-
-    /**
      * The singleton instance expecting input coordinates in radians.
      * For the instance expecting input coordinates in degrees, use {@link #completeTransform()} instead.
      */
@@ -89,7 +78,7 @@ final class SphericalToCartesian extends
      * Input coordinates are in radians.
      */
     private SphericalToCartesian() {
-        super("Spherical to Cartesian", 3);
+        super("Spherical to Cartesian");
         context.normalizeGeographicInputs(0);                   // Convert (θ,Ω) from degrees to radians.
     }
 
@@ -102,24 +91,6 @@ final class SphericalToCartesian extends
     }
 
     /**
-     * Returns the source coordinate system of the complete math transform.
-     * Angular units shall be degrees.
-     */
-    @Override
-    final CoordinateSystem getSourceCS() {
-        return SOURCE;
-    }
-
-    /**
-     * Returns the target coordinate system of the complete math transform.
-     * Angular units shall be degrees.
-     */
-    @Override
-    final CoordinateSystem getTargetCS() {
-        return CartesianToSpherical.SOURCE;
-    }
-
-    /**
      * Converts a single coordinate and optionally computes the derivative.
      */
     @Override
@@ -196,7 +167,7 @@ final class SphericalToCartesian extends
      * 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 EllipsoidToCentricTransform is at the beginning or the end of a transformation chain,
+     *       this SphericalToCartesian is at the beginning or the end of a transformation chain,
      *       the methods inherited from the subclass will work (but may be slightly slower).
      */
 }

Copied: sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/transform/CartesianToCylindricalTest.java (from r1735066, 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/CartesianToCylindricalTest.java?p2=sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/transform/CartesianToCylindricalTest.java&p1=sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/transform/CartesianToSphericalTest.java&r1=1735066&r2=1735177&rev=1735177&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/CartesianToCylindricalTest.java [UTF-8] Tue Mar 15 23:14:39 2016
@@ -28,15 +28,15 @@ import org.junit.Test;
 
 
 /**
- * Tests {@link CartesianToSpherical}.
+ * Tests {@link CartesianToCylindrical}.
  *
  * @author  Martin Desruisseaux (Geomatys)
  * @since   0.7
  * @version 0.7
  * @module
  */
-@DependsOn(SphericalToCartesianTest.class)
-public final strictfp class CartesianToSphericalTest extends TransformTestCase {
+@DependsOn(CylindricalToCartesianTest.class)
+public final strictfp class CartesianToCylindricalTest extends TransformTestCase {
     /**
      * Tests coordinate conversions.
      *
@@ -45,9 +45,9 @@ public final strictfp class CartesianToS
      */
     @Test
     public void testConversion() throws FactoryException, TransformException {
-        transform = CartesianToSpherical.INSTANCE.completeTransform();
+        transform = CartesianToCylindrical.INSTANCE.completeTransform();
         tolerance = 1E-12;
-        final double[][] data = SphericalToCartesianTest.testData();
+        final double[][] data = CylindricalToCartesianTest.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 = CartesianToCylindrical.INSTANCE.completeTransform();
         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 = CartesianToCylindrical.INSTANCE.completeTransform();
         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/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=1735177&r1=1735176&r2=1735177&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] Tue Mar 15 23:14:39 2016
@@ -20,10 +20,14 @@ import javax.measure.unit.SI;
 import javax.measure.unit.Unit;
 import org.opengis.util.FactoryException;
 import org.opengis.referencing.cs.CoordinateSystem;
+import org.opengis.referencing.cs.SphericalCS;
 import org.opengis.referencing.operation.MathTransformFactory;
 import org.opengis.referencing.operation.TransformException;
+import org.apache.sis.referencing.crs.DefaultGeocentricCRS;
 import org.apache.sis.referencing.cs.CoordinateSystems;
+import org.apache.sis.referencing.cs.AxesConvention;
 import org.apache.sis.referencing.cs.AxisFilter;
+import org.apache.sis.referencing.CommonCRS;
 
 // Test dependencies
 import org.opengis.test.referencing.TransformTestCase;
@@ -50,6 +54,11 @@ import org.junit.Test;
 })
 public final strictfp class CoordinateSystemTransformTest extends TransformTestCase {
     /**
+     * A right-handed spherical coordinate system.
+     */
+    private static SphericalCS spherical;
+
+    /**
      * The factory to use for creating the affine transforms and concatenated transforms.
      */
     private static MathTransformFactory factory;
@@ -61,6 +70,8 @@ public final strictfp class CoordinateSy
     @BeforeClass
     public static void createFactory() {
         factory = new DefaultMathTransformFactory();
+        spherical = (SphericalCS) DefaultGeocentricCRS.castOrCopy(CommonCRS.WGS84.spherical())
+                            .forConvention(AxesConvention.RIGHT_HANDED).getCoordinateSystem();
     }
 
     /**
@@ -68,6 +79,7 @@ public final strictfp class CoordinateSy
      */
     @AfterClass
     public static void disposeFactory() {
+        spherical = null;
         factory = null;
     }
 
@@ -108,7 +120,7 @@ public final strictfp class CoordinateSy
      */
     @Test
     public void testSphericalToSpherical() throws FactoryException, TransformException {
-        transform = CoordinateSystemTransform.create(factory, HardCodedCS.SPHERICAL, SphericalToCartesian.SOURCE);
+        transform = CoordinateSystemTransform.create(factory, HardCodedCS.SPHERICAL, spherical);
         tolerance = 0;
         final double[][] data = SphericalToCartesianTest.testData();
         final double[] source = data[0];

Copied: sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/transform/CylindricalToCartesianTest.java (from r1735066, 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/CylindricalToCartesianTest.java?p2=sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/transform/CylindricalToCartesianTest.java&p1=sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/transform/SphericalToCartesianTest.java&r1=1735066&r2=1735177&rev=1735177&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/CylindricalToCartesianTest.java [UTF-8] Tue Mar 15 23:14:39 2016
@@ -19,56 +19,49 @@ package org.apache.sis.referencing.opera
 import org.opengis.util.FactoryException;
 import org.opengis.referencing.operation.TransformException;
 
+import static java.lang.StrictMath.*;
+
 // Test dependencies
 import org.opengis.test.referencing.TransformTestCase;
 import org.apache.sis.test.DependsOnMethod;
 import org.apache.sis.test.TestUtilities;
 import org.junit.Test;
 
-import static java.lang.StrictMath.*;
-
 
 /**
- * Tests {@link SphericalToCartesian}.
+ * Tests {@link CylindricalToCartesian}.
  *
  * @author  Martin Desruisseaux (Geomatys)
  * @since   0.7
  * @version 0.7
  * @module
  */
-public final strictfp class SphericalToCartesianTest extends TransformTestCase {
+public final strictfp class CylindricalToCartesianTest extends TransformTestCase {
     /**
      * Returns coordinate points in spherical coordinates and their equivalent in Cartesian coordinates.
      */
     static double[][] testData() {
+        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[][] {
-            new double[] {                      // (θ,Ω,r) coordinates
+            new double[] {                      // (r,θ,z) coordinates
                  0,       0,       0,
-                 0,       0,       r,
-                90,       0,       r,
-               -90,       0,       r,
-                 0,      90,       r,
-                 0,     -90,       r,
-                 0,      60,       r,
-                60,       0,       r,
-                30,       0,       r,
-                30,      60,       r
-            }, new double[] {                   // (X,Y,Z) coordinates
+                 r,       0,       z,
+                 r,      90,       z,
+                 r,     -90,       z,
+                 r,      60,       z,
+                 r,      30,       z
+            }, new double[] {                   // (x,y,z) coordinates
                  0,       0,       0,
-                 r,       0,       0,
-                 0,       r,       0,
-                 0,      -r,       0,
-                 0,       0,       r,
-                 0,       0,      -r,
-                 cos60,   0,       sin60,
-                 cos60,   sin60,   0,
-                 cos30,   sin30,   0,
-                 cos30/2, sin30/2, sin60
+                 r,       0,       z,
+                 0,       r,       z,
+                 0,      -r,       z,
+                 cos60,   sin60,   z,
+                 cos30,   sin30,   z
             }
         };
     }
@@ -81,7 +74,7 @@ public final strictfp class SphericalToC
      */
     @Test
     public void testConversion() throws FactoryException, TransformException {
-        transform = SphericalToCartesian.INSTANCE.completeTransform();
+        transform = CylindricalToCartesian.INSTANCE.completeTransform();
         tolerance = 1E-12;
         final double[][] data = testData();
         verifyTransform(data[0], data[1]);
@@ -95,10 +88,10 @@ public final strictfp class SphericalToC
      */
     @Test
     public void testDerivative() throws FactoryException, TransformException {
-        transform = SphericalToCartesian.INSTANCE.completeTransform();
+        transform = CylindricalToCartesian.INSTANCE.completeTransform();
         derivativeDeltas = new double[] {1E-6, 1E-6, 1E-6};
         tolerance = 1E-7;
-        verifyDerivative(30, 60, 100);
+        verifyDerivative(100, 60, 25);
     }
 
     /**
@@ -110,12 +103,12 @@ public final strictfp class SphericalToC
     @Test
     @DependsOnMethod({"testConversion", "testDerivative"})
     public void testConsistency() throws FactoryException, TransformException {
-        transform = SphericalToCartesian.INSTANCE.completeTransform();
+        transform = CylindricalToCartesian.INSTANCE.completeTransform();
         derivativeDeltas = new double[] {1E-6, 1E-6, 1E-6};
         tolerance = 1E-7;
-        verifyInDomain(new double[] {-180, -90,   0},       // Minimal coordinates
-                       new double[] {+180, +90, 100},       // Maximal coordinates
-                       new int[]    {  10,  10,  10},
+        verifyInDomain(new double[] {  0, -180, -100},      // Minimal coordinates
+                       new double[] {+20, +180, +100},      // Maximal coordinates
+                       new int[]    { 10,   10,   10},
                        TestUtilities.createRandomNumberGenerator());
     }
 }

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=1735177&r1=1735176&r2=1735177&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] Tue Mar 15 23:14:39 2016
@@ -19,14 +19,14 @@ package org.apache.sis.referencing.opera
 import org.opengis.util.FactoryException;
 import org.opengis.referencing.operation.TransformException;
 
+import static java.lang.StrictMath.*;
+
 // Test dependencies
 import org.opengis.test.referencing.TransformTestCase;
 import org.apache.sis.test.DependsOnMethod;
 import org.apache.sis.test.TestUtilities;
 import org.junit.Test;
 
-import static java.lang.StrictMath.*;
-
 
 /**
  * Tests {@link SphericalToCartesian}.

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=1735177&r1=1735176&r2=1735177&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] Tue Mar 15 23:14:39 2016
@@ -123,6 +123,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.CoordinateSystemTransformTest.class,
     org.apache.sis.referencing.operation.DefaultFormulaTest.class,
     org.apache.sis.referencing.operation.DefaultOperationMethodTest.class,



Mime
View raw message