sis-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From desruisse...@apache.org
Subject svn commit: r1737072 [4/5] - in /sis/branches/JDK7: ./ application/sis-console/src/main/artifact/conf/ core/sis-metadata/src/main/java/org/apache/sis/internal/metadata/ core/sis-metadata/src/main/java/org/apache/sis/io/wkt/ core/sis-referencing/src/mai...
Date Tue, 29 Mar 2016 22:51:41 GMT
Modified: sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/InterpolatedTransform.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/InterpolatedTransform.java?rev=1737072&r1=1737071&r2=1737072&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/InterpolatedTransform.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/InterpolatedTransform.java [UTF-8] Tue Mar 29 22:51:40 2016
@@ -347,7 +347,7 @@ public class InterpolatedTransform 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 handle by those LinearTransforms.   If nevertheless
+     *       conversion between float and double will be handled by those LinearTransforms.  If nevertheless
      *       this MolodenskyTransform 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/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/MathTransforms.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/MathTransforms.java?rev=1737072&r1=1737071&r2=1737072&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/MathTransforms.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/MathTransforms.java [UTF-8] Tue Mar 29 22:51:40 2016
@@ -32,10 +32,9 @@ import org.apache.sis.internal.referenci
 import org.apache.sis.internal.referencing.j2d.AffineTransform2D;
 import org.apache.sis.referencing.operation.matrix.AffineTransforms2D;
 import org.apache.sis.referencing.operation.matrix.Matrices;
+import org.apache.sis.util.ArgumentChecks;
 import org.apache.sis.util.Static;
 
-import static org.apache.sis.util.ArgumentChecks.*;
-
 
 /**
  * Utility methods creating or working on {@link MathTransform} instances.
@@ -78,7 +77,7 @@ public final class MathTransforms extend
      * @return An identity transform of the specified dimension.
      */
     public static LinearTransform identity(final int dimension) {
-        ensureStrictlyPositive("dimension", dimension);
+        ArgumentChecks.ensureStrictlyPositive("dimension", dimension);
         return IdentityTransform.create(dimension);
     }
 
@@ -113,7 +112,7 @@ public final class MathTransforms extend
      * @see DefaultMathTransformFactory#createAffineTransform(Matrix)
      */
     public static LinearTransform linear(final Matrix matrix) {
-        ensureNonNull("matrix", matrix);
+        ArgumentChecks.ensureNonNull("matrix", matrix);
         final int sourceDimension = matrix.getNumCol() - 1;
         final int targetDimension = matrix.getNumRow() - 1;
         if (sourceDimension == targetDimension) {
@@ -170,12 +169,12 @@ public final class MathTransforms extend
      * @since 0.6
      */
     public static MathTransform compound(final MathTransform... transforms) {
-        ensureNonNull("transforms", transforms);
+        ArgumentChecks.ensureNonNull("transforms", transforms);
         int sum = 0;
         final int[] dimensions = new int[transforms.length];
         for (int i=0; i<transforms.length; i++) {
             final MathTransform tr = transforms[i];
-            ensureNonNullElement("transforms", i, tr);
+            ArgumentChecks.ensureNonNullElement("transforms", i, tr);
             sum += (dimensions[i] = tr.getSourceDimensions());
         }
         MathTransform compound = null;
@@ -209,8 +208,8 @@ public final class MathTransforms extend
     public static MathTransform concatenate(final MathTransform tr1, final MathTransform tr2)
             throws MismatchedDimensionException
     {
-        ensureNonNull("tr1", tr1);
-        ensureNonNull("tr2", tr2);
+        ArgumentChecks.ensureNonNull("tr1", tr1);
+        ArgumentChecks.ensureNonNull("tr2", tr2);
         final MathTransform tr;
         try {
             tr = ConcatenatedTransform.create(tr1, tr2, null);
@@ -269,9 +268,9 @@ public final class MathTransforms extend
     public static MathTransform concatenate(MathTransform tr1, MathTransform tr2, MathTransform tr3)
             throws MismatchedDimensionException
     {
-        ensureNonNull("tr1", tr1);
-        ensureNonNull("tr2", tr2);
-        ensureNonNull("tr3", tr3);
+        ArgumentChecks.ensureNonNull("tr1", tr1);
+        ArgumentChecks.ensureNonNull("tr2", tr2);
+        ArgumentChecks.ensureNonNull("tr3", tr3);
         return concatenate(concatenate(tr1, tr2), tr3);
     }
 

Modified: sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/MolodenskyTransform.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/MolodenskyTransform.java?rev=1737072&r1=1737071&r2=1737072&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/MolodenskyTransform.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/MolodenskyTransform.java [UTF-8] Tue Mar 29 22:51:40 2016
@@ -362,7 +362,7 @@ public class MolodenskyTransform 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 handle by those LinearTransforms.   If nevertheless
+     *       conversion between float and double will be handled by those LinearTransforms.  If nevertheless
      *       this MolodenskyTransform 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/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/ProjectiveTransform.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/ProjectiveTransform.java?rev=1737072&r1=1737071&r2=1737072&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/ProjectiveTransform.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/ProjectiveTransform.java [UTF-8] Tue Mar 29 22:51:40 2016
@@ -92,6 +92,9 @@ class ProjectiveTransform extends Abstra
      * Otherwise returns {@code this} unchanged.
      */
     final LinearTransform optimize() {
+        if (numCol < numRow) {
+            return this;
+        }
         final int n = (numRow - 1) * numCol;
         for (int i = 0; i != numCol;) {
             if (elt[n + i] != (++i == numCol ? 1 : 0)) {

Modified: sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/internal/metadata/AxisDirectionsTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/internal/metadata/AxisDirectionsTest.java?rev=1737072&r1=1737071&r2=1737072&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/internal/metadata/AxisDirectionsTest.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/internal/metadata/AxisDirectionsTest.java [UTF-8] Tue Mar 29 22:51:40 2016
@@ -32,6 +32,9 @@ import org.junit.Test;
 import static org.junit.Assert.*;
 import static java.lang.StrictMath.abs;
 import static org.opengis.referencing.cs.AxisDirection.*;
+import static org.apache.sis.internal.metadata.AxisDirections.AWAY_FROM;
+import static org.apache.sis.internal.metadata.AxisDirections.CLOCKWISE;
+import static org.apache.sis.internal.metadata.AxisDirections.COUNTER_CLOCKWISE;
 
 
 /**
@@ -63,6 +66,9 @@ public final strictfp class AxisDirectio
         assertEquals(UP,                AxisDirections.absolute(DOWN));
         assertEquals(FUTURE,            AxisDirections.absolute(FUTURE));
         assertEquals(FUTURE,            AxisDirections.absolute(PAST));
+        assertEquals(AWAY_FROM,         AxisDirections.absolute(AWAY_FROM));
+        assertEquals(COUNTER_CLOCKWISE, AxisDirections.absolute(CLOCKWISE));
+        assertEquals(COUNTER_CLOCKWISE, AxisDirections.absolute(COUNTER_CLOCKWISE));
     }
 
     /**
@@ -82,6 +88,9 @@ public final strictfp class AxisDirectio
         assertEquals(UP,                AxisDirections.opposite(DOWN));
         assertEquals(PAST,              AxisDirections.opposite(FUTURE));
         assertEquals(FUTURE,            AxisDirections.opposite(PAST));
+        assertEquals(COUNTER_CLOCKWISE, AxisDirections.opposite(CLOCKWISE));
+        assertEquals(CLOCKWISE,         AxisDirections.opposite(COUNTER_CLOCKWISE));
+        assertNull  (                   AxisDirections.opposite(AWAY_FROM));
     }
 
     /**
@@ -381,7 +390,10 @@ public final strictfp class AxisDirectio
         assertEquals("φ′",  AxisDirections.suggestAbbreviation("Spherical latitude",     NORTH,         NonSI.DEGREE_ANGLE));
         assertEquals("h",   AxisDirections.suggestAbbreviation("Ellipsoidal height",     UP,               SI.METRE));
         assertEquals("H",   AxisDirections.suggestAbbreviation("Gravity-related height", UP,               SI.METRE));
-        assertEquals("r",   AxisDirections.suggestAbbreviation("Geocentric radius",      UP,               SI.METRE));
+        assertEquals("φ",   AxisDirections.suggestAbbreviation("Elevation",              UP,               SI.METRE));
+        assertEquals("R",   AxisDirections.suggestAbbreviation("Geocentric radius",      UP,               SI.METRE));
+        assertEquals("r",   AxisDirections.suggestAbbreviation("Distance",               AWAY_FROM,        SI.METRE));
+        assertEquals("θ",   AxisDirections.suggestAbbreviation("Bearing",                CLOCKWISE,     NonSI.DEGREE_ANGLE));
         assertEquals("X",   AxisDirections.suggestAbbreviation("not needed",             GEOCENTRIC_X,     SI.METRE));
         assertEquals("Y",   AxisDirections.suggestAbbreviation("not needed",             GEOCENTRIC_Y,     SI.METRE));
         assertEquals("Z",   AxisDirections.suggestAbbreviation("not needed",             GEOCENTRIC_Z,     SI.METRE));

Modified: sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/BuilderTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/BuilderTest.java?rev=1737072&r1=1737071&r2=1737072&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/BuilderTest.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/BuilderTest.java [UTF-8] Tue Mar 29 22:51:40 2016
@@ -300,9 +300,9 @@ public final strictfp class BuilderTest
         assertNull(properties.put(AbstractIdentifiedObject.REMARKS_KEY,     "Some remarks"));
         final BuilderMock builder = new BuilderMock(new AbstractIdentifiedObject(properties));
 
-        assertEquals("Expected only name and remarks.", 2, builder.properties.size());
+        assertEquals("Expected only name, remarks and deprecated status.", 3, builder.properties.size());
         builder.onCreate(false);
-        assertEquals("Expected name, aliases, identifiers and remarks.", 4, builder.properties.size());
+        assertEquals("Expected name, aliases, identifiers and remarks.", 5, builder.properties.size());
 
         assertEquals(AbstractIdentifiedObject.NAME_KEY, "Dummy object",
                 builder.properties.get(AbstractIdentifiedObject.NAME_KEY).toString());

Modified: sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/CommonCRSTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/CommonCRSTest.java?rev=1737072&r1=1737071&r2=1737072&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/CommonCRSTest.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/CommonCRSTest.java [UTF-8] Tue Mar 29 22:51:40 2016
@@ -40,7 +40,7 @@ import org.apache.sis.test.DependsOn;
 import org.apache.sis.test.TestCase;
 import org.junit.Test;
 
-import static org.junit.Assert.*;
+import static org.opengis.test.Assert.*;
 import static org.apache.sis.test.TestUtilities.*;
 
 
@@ -100,7 +100,7 @@ public final strictfp class CommonCRSTes
     public void testGeographic3D() {
         final GeographicCRS crs = CommonCRS.WGS72.geographic3D();
         Validators.validate(crs);
-        assertEquals("WGS 72", crs.getName().getCode());
+        assertEquals ("WGS 72", crs.getName().getCode());
         assertSame   (CommonCRS.WGS72.geographic().getDatum(), crs.getDatum());
         assertNotSame(CommonCRS.WGS84.geographic().getDatum(), crs.getDatum());
 
@@ -108,9 +108,7 @@ public final strictfp class CommonCRSTes
         final String name = cs.getName().getCode();
         assertTrue(name, name.startsWith("Ellipsoidal 3D"));
         assertEquals("dimension", 3, cs.getDimension());
-        assertEquals(AxisDirection.NORTH, cs.getAxis(0).getDirection());
-        assertEquals(AxisDirection.EAST,  cs.getAxis(1).getDirection());
-        assertEquals(AxisDirection.UP,    cs.getAxis(2).getDirection());
+        assertAxisDirectionsEqual(name, cs, AxisDirection.NORTH, AxisDirection.EAST, AxisDirection.UP);
         assertSame("Cached value", crs, CommonCRS.WGS72.geographic3D());
     }
 
@@ -122,7 +120,7 @@ public final strictfp class CommonCRSTes
     public void testGeocentric() {
         final GeocentricCRS crs = CommonCRS.WGS72.geocentric();
         Validators.validate(crs);
-        assertEquals("WGS 72", crs.getName().getCode());
+        assertEquals ("WGS 72", crs.getName().getCode());
         assertSame   (CommonCRS.WGS72.geographic().getDatum(), crs.getDatum());
         assertNotSame(CommonCRS.WGS84.geographic().getDatum(), crs.getDatum());
 
@@ -130,13 +128,32 @@ public final strictfp class CommonCRSTes
         final String name = cs.getName().getCode();
         assertTrue(name, name.startsWith("Earth centred"));
         assertEquals("dimension", 3, cs.getDimension());
-        assertEquals(AxisDirection.GEOCENTRIC_X, cs.getAxis(0).getDirection());
-        assertEquals(AxisDirection.GEOCENTRIC_Y, cs.getAxis(1).getDirection());
-        assertEquals(AxisDirection.GEOCENTRIC_Z, cs.getAxis(2).getDirection());
+        assertAxisDirectionsEqual(name, cs, AxisDirection.GEOCENTRIC_X,
+                AxisDirection.GEOCENTRIC_Y, AxisDirection.GEOCENTRIC_Z);
         assertSame("Cached value", crs, CommonCRS.WGS72.geocentric());
     }
 
     /**
+     * Tests the {@link CommonCRS#spherical()} method.
+     */
+    @Test
+    @DependsOnMethod("testGeographic3D")
+    public void testSpherical() {
+        final GeocentricCRS crs = CommonCRS.ETRS89.spherical();
+        Validators.validate(crs);
+        assertEquals ("ETRS89", crs.getName().getCode());
+        assertSame   (CommonCRS.ETRS89.geographic().getDatum(), crs.getDatum());
+        assertNotSame(CommonCRS.WGS84 .geographic().getDatum(), crs.getDatum());
+
+        final CoordinateSystem cs = crs.getCoordinateSystem();
+        final String name = cs.getName().getCode();
+        assertTrue(name, name.startsWith("Spherical"));
+        assertEquals("dimension", 3, cs.getDimension());
+        assertAxisDirectionsEqual(name, cs, AxisDirection.NORTH, AxisDirection.EAST, AxisDirection.UP);
+        assertSame("Cached value", crs, CommonCRS.ETRS89.spherical());
+    }
+
+    /**
      * Verifies the vertical datum enumeration.
      */
     @Test

Modified: sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/StandardDefinitionsTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/StandardDefinitionsTest.java?rev=1737072&r1=1737071&r2=1737072&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/StandardDefinitionsTest.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/StandardDefinitionsTest.java [UTF-8] Tue Mar 29 22:51:40 2016
@@ -150,12 +150,15 @@ public final strictfp class StandardDefi
      */
     @Test
     public void testCreateAxis() {
-        for (final short code : new short[] {1, 2, 106, 107, 110, 114, 113}) {
+        for (final short code : new short[] {1, 2, 60, 61, 62, 106, 107, 110, 114, 113}) {
             final CoordinateSystemAxis actual = StandardDefinitions.createAxis(code);
             Validators.validate(actual);
             switch (code) {
                 case   1: compare(HardCodedAxes.EASTING,                actual); break;
                 case   2: compare(HardCodedAxes.NORTHING,               actual); break;
+                case  60: compare(HardCodedAxes.SPHERICAL_LATITUDE,     actual); break;
+                case  61: compare(HardCodedAxes.SPHERICAL_LONGITUDE,    actual); break;
+                case  62: compare(HardCodedAxes.GEOCENTRIC_RADIUS,      actual); break;
                 case 106: compare(HardCodedAxes.GEODETIC_LATITUDE,      actual); break;
                 case 107: compare(HardCodedAxes.GEODETIC_LONGITUDE,     actual); break;
                 case 110: compare(HardCodedAxes.ELLIPSOIDAL_HEIGHT,     actual); break;

Modified: sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/crs/DefaultEngineeringCRSTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/crs/DefaultEngineeringCRSTest.java?rev=1737072&r1=1737071&r2=1737072&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/crs/DefaultEngineeringCRSTest.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/crs/DefaultEngineeringCRSTest.java [UTF-8] Tue Mar 29 22:51:40 2016
@@ -86,7 +86,7 @@ public final strictfp class DefaultEngin
                 "  CS[spherical, 3],\n" +
                 "    AXIS[“Spherical latitude (U)”, north, ORDER[1], ANGLEUNIT[“degree”, 0.017453292519943295]],\n" +
                 "    AXIS[“Spherical longitude (V)”, east, ORDER[2], ANGLEUNIT[“degree”, 0.017453292519943295]],\n" +
-                "    AXIS[“Geocentric radius (r)”, up, ORDER[3], LENGTHUNIT[“metre”, 1]]]",
+                "    AXIS[“Geocentric radius (R)”, up, ORDER[3], LENGTHUNIT[“metre”, 1]]]",
                 crs);
     }
 
@@ -102,7 +102,7 @@ public final strictfp class DefaultEngin
                 "  CS[spherical, 3],\n" +
                 "    Axis[“Spherical latitude (U)”, north, Unit[“degree”, 0.017453292519943295]],\n" +
                 "    Axis[“Spherical longitude (V)”, east, Unit[“degree”, 0.017453292519943295]],\n" +
-                "    Axis[“Geocentric radius (r)”, up, Unit[“metre”, 1]]]",
+                "    Axis[“Geocentric radius (R)”, up, Unit[“metre”, 1]]]",
                 crs);
     }
 
@@ -192,7 +192,7 @@ public final strictfp class DefaultEngin
                 "    <gml:axis>\n" +
                 "      <gml:CoordinateSystemAxis uom=\"urn:ogc:def:uom:EPSG::9001\" gml:id=\"GeocentricRadius\">\n" +
                 "        <gml:name>Geocentric radius</gml:name>\n" +
-                "        <gml:axisAbbrev>r</gml:axisAbbrev>\n" +
+                "        <gml:axisAbbrev>R</gml:axisAbbrev>\n" +
                 "        <gml:axisDirection codeSpace=\"EPSG\">up</gml:axisDirection>\n" +
                 "        <gml:minimumValue>0.0</gml:minimumValue>\n" +
                 "        <gml:rangeMeaning codeSpace=\"EPSG\">exact</gml:rangeMeaning>\n" +
@@ -222,6 +222,6 @@ public final strictfp class DefaultEngin
         assertEquals("cs.axis[2].name", "Geocentric radius",   cs.getAxis(2).getName().getCode());
         assertEquals("cs.axis[0].abbreviation", "φ′",          cs.getAxis(0).getAbbreviation());
         assertEquals("cs.axis[1].abbreviation", "θ",           cs.getAxis(1).getAbbreviation());
-        assertEquals("cs.axis[2].abbreviation", "r",           cs.getAxis(2).getAbbreviation());
+        assertEquals("cs.axis[2].abbreviation", "R",           cs.getAxis(2).getAbbreviation());
     }
 }

Modified: sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/crs/DefaultGeocentricCRSTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/crs/DefaultGeocentricCRSTest.java?rev=1737072&r1=1737071&r2=1737072&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/crs/DefaultGeocentricCRSTest.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/crs/DefaultGeocentricCRSTest.java [UTF-8] Tue Mar 29 22:51:40 2016
@@ -18,12 +18,16 @@ package org.apache.sis.referencing.crs;
 
 import javax.measure.unit.SI;
 import org.opengis.referencing.cs.CartesianCS;
+import org.opengis.referencing.cs.CoordinateSystem;
+import org.opengis.referencing.cs.CoordinateSystemAxis;
 import org.apache.sis.io.wkt.Convention;
 import org.apache.sis.referencing.IdentifiedObjects;
+import org.apache.sis.referencing.cs.AxesConvention;
 import org.apache.sis.internal.referencing.Legacy;
 import org.apache.sis.test.DependsOn;
 import org.apache.sis.test.DependsOnMethod;
 import org.apache.sis.test.TestCase;
+import org.opengis.test.Validators;
 import org.junit.Test;
 
 import static org.apache.sis.test.MetadataAssert.*;
@@ -34,7 +38,7 @@ import static org.apache.sis.test.Metada
  *
  * @author  Martin Desruisseaux (Geomatys)
  * @since   0.4
- * @version 0.6
+ * @version 0.7
  * @module
  */
 @DependsOn({
@@ -42,6 +46,48 @@ import static org.apache.sis.test.Metada
 })
 public final strictfp class DefaultGeocentricCRSTest extends TestCase {
     /**
+     * Tests the {@link DefaultGeocentricCRS#forConvention(AxesConvention)} method
+     * for {@link AxesConvention#RIGHT_HANDED}.
+     *
+     * @since 0.7
+     */
+    @Test
+    public void testRightHanded() {
+        final DefaultGeocentricCRS crs = DefaultGeocentricCRS.castOrCopy(HardCodedCRS.SPHERICAL);
+        final DefaultGeocentricCRS normalized = crs.forConvention(AxesConvention.RIGHT_HANDED);
+        assertNotSame(crs, normalized);
+        final CoordinateSystem cs = normalized.getCoordinateSystem();
+        final CoordinateSystem ref = crs.getCoordinateSystem();
+        assertSame("longitude", ref.getAxis(1), cs.getAxis(0));
+        assertSame("latitude",  ref.getAxis(0), cs.getAxis(1));
+        assertSame("height",    ref.getAxis(2), cs.getAxis(2));
+    }
+
+    /**
+     * Tests the {@link DefaultGeocentricCRS#forConvention(AxesConvention)} method
+     * for {@link AxesConvention#POSITIVE_RANGE}.
+     *
+     * @since 0.7
+     */
+    @Test
+    public void testShiftLongitudeRange() {
+        final DefaultGeocentricCRS crs = HardCodedCRS.SPHERICAL;
+        CoordinateSystemAxis axis = crs.getCoordinateSystem().getAxis(1);
+        assertEquals("longitude.minimumValue", -180.0, axis.getMinimumValue(), STRICT);
+        assertEquals("longitude.maximumValue", +180.0, axis.getMaximumValue(), STRICT);
+
+        final DefaultGeocentricCRS shifted =  crs.forConvention(AxesConvention.POSITIVE_RANGE);
+        assertNotSame("Expected a new CRS.", crs, shifted);
+        Validators.validate(shifted);
+
+        axis = shifted.getCoordinateSystem().getAxis(1);
+        assertEquals("longitude.minimumValue",      0.0, axis.getMinimumValue(), STRICT);
+        assertEquals("longitude.maximumValue",    360.0, axis.getMaximumValue(), STRICT);
+        assertSame("Expected a no-op.",         shifted, shifted.forConvention(AxesConvention.POSITIVE_RANGE));
+        assertSame("Expected cached instance.", shifted, crs    .forConvention(AxesConvention.POSITIVE_RANGE));
+    }
+
+    /**
      * Tests WKT 1 formatting.
      * Axis directions Geocentric X, Y and Z shall be replaced be Other, East and North respectively,
      * for conformance with legacy WKT 1 practice.

Modified: sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/cs/CoordinateSystemsTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/cs/CoordinateSystemsTest.java?rev=1737072&r1=1737071&r2=1737072&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/cs/CoordinateSystemsTest.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/cs/CoordinateSystemsTest.java [UTF-8] Tue Mar 29 22:51:40 2016
@@ -294,6 +294,19 @@ public final strictfp class CoordinateSy
             }
 
             @Override
+            public Unit<?> getUnitReplacement(CoordinateSystemAxis axis, Unit<?> unit) {
+                if (Units.isAngular(unit)) {
+                    unit = NonSI.GRADE;
+                }
+                return unit;
+            }
+
+            @Override
+            public AxisDirection getDirectionReplacement(CoordinateSystemAxis axis, final AxisDirection direction) {
+                return direction;
+            }
+
+            @Override
             public AxisDirection getDirectionReplacement(final AxisDirection direction) {
                 return direction;
             }
@@ -325,6 +338,16 @@ public final strictfp class CoordinateSy
             public AxisDirection getDirectionReplacement(final AxisDirection direction) {
                 return direction;
             }
+
+            @Override
+            public Unit<?> getUnitReplacement(CoordinateSystemAxis axis, final Unit<?> unit) {
+                return unit;
+            }
+
+            @Override
+            public AxisDirection getDirectionReplacement(CoordinateSystemAxis axis, final AxisDirection direction) {
+                return direction;
+            }
         });
         assertEqualsIgnoreMetadata(targetCS, actualCS);
     }

Modified: sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/cs/DefaultCartesianCSTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/cs/DefaultCartesianCSTest.java?rev=1737072&r1=1737071&r2=1737072&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/cs/DefaultCartesianCSTest.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/cs/DefaultCartesianCSTest.java [UTF-8] Tue Mar 29 22:51:40 2016
@@ -170,8 +170,8 @@ public final strictfp class DefaultCarte
      * Then ensures that swapping the axes and applying conventional orientation gives back the original CS.
      */
     private static void testConventionalOrientation(final String x, final String y) {
-        assertConventionallyOrientedEquals(x, y, x, y); // Expect no-op.
-        assertConventionallyOrientedEquals(x, y, y, x); // Expect normalization.
+        assertConventionallyOrientedEquals(x, y, x, y);         // Expect no-op.
+        assertConventionallyOrientedEquals(x, y, y, x);         // Expect normalization.
     }
 
     /**

Modified: sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/cs/DefaultSphericalCSTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/cs/DefaultSphericalCSTest.java?rev=1737072&r1=1737071&r2=1737072&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/cs/DefaultSphericalCSTest.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/cs/DefaultSphericalCSTest.java [UTF-8] Tue Mar 29 22:51:40 2016
@@ -17,12 +17,13 @@
 package org.apache.sis.referencing.cs;
 
 import java.util.Collections;
+import org.opengis.referencing.cs.AxisDirection;
+import org.apache.sis.internal.metadata.AxisDirections;
 import org.apache.sis.test.TestCase;
 import org.apache.sis.test.DependsOn;
 import org.junit.Test;
 
-import static org.apache.sis.test.Assert.*;
-import static org.apache.sis.referencing.cs.HardCodedCS.*;
+import static org.opengis.test.Assert.*;
 
 
 /**
@@ -30,23 +31,63 @@ import static org.apache.sis.referencing
  *
  * @author  Martin Desruisseaux (Geomatys)
  * @since   0.4
- * @version 0.5
+ * @version 0.7
  * @module
  */
 @DependsOn(AbstractCSTest.class)
 public final strictfp class DefaultSphericalCSTest extends TestCase {
     /**
-     * Tests the conventional orientation of a coordinate system.
+     * Tests a spherical CRS conforms to EPSG:8.9:6404 definition.
+     * Expected axes are:
+     *
+     * <ol>
+     *   <li>Spherical latitude (φ′)</li>
+     *   <li>Spherical longitude (θ)</li>
+     *   <li>Geocentric radius (R)</li>
+     * </ol>
      */
     @Test
-    public void testConventionalOrientation() {
-        final AbstractCS normalized = SPHERICAL.forConvention(AxesConvention.CONVENTIONALLY_ORIENTED);
-        assertNotSame(SPHERICAL, normalized);
+    public void testGeodetic() {
+        final DefaultSphericalCS cs = HardCodedCS.SPHERICAL;
+        assertEquals("EPSG abbreviation for geocentric radius should be upper-case", "R", cs.getAxis(2).getAbbreviation());
+
+        final DefaultSphericalCS normalized = cs.forConvention(AxesConvention.CONVENTIONALLY_ORIENTED);
+        assertNotSame("Should create a new CoordinateSystem.", cs, normalized);
+        assertAxisDirectionsEqual("Normalized", normalized,
+                AxisDirection.EAST,
+                AxisDirection.NORTH,
+                AxisDirection.UP);
+
         assertEquals(new DefaultSphericalCS(
-            Collections.singletonMap(AbstractCS.NAME_KEY, "Spherical CS: East (°), North (°), Up (m)."),
-            HardCodedAxes.SPHERICAL_LONGITUDE,
-            HardCodedAxes.SPHERICAL_LATITUDE,
-            HardCodedAxes.GEOCENTRIC_RADIUS
-        ), normalized);
+                Collections.singletonMap(AbstractCS.NAME_KEY, "Spherical CS: East (°), North (°), Up (m)."),
+                HardCodedAxes.SPHERICAL_LONGITUDE,
+                HardCodedAxes.SPHERICAL_LATITUDE,
+                HardCodedAxes.GEOCENTRIC_RADIUS), normalized);
+    }
+
+    /**
+     * Tests a spherical CRS conforms to the example given in ISO 19162.
+     * Expected axes are:
+     *
+     * <ol>
+     *   <li>Distance (r)</li>
+     *   <li>Longitude</li>
+     *   <li>Elevation</li>
+     * </ol>
+     *
+     * This order is not exactly the usual engineering axis order.
+     * But this is the order expected by the {@code SphericalToCartesian} transform.
+     */
+    @Test
+    public void testEngineering() {
+        final DefaultSphericalCS cs = HardCodedCS.SPHERICAL_ENGINEERING;
+        assertEquals("Abbreviation for distance should be lower-case", "r", cs.getAxis(0).getAbbreviation());
+
+        final DefaultSphericalCS normalized = cs.forConvention(AxesConvention.NORMALIZED);
+        assertNotSame("Should create a new CoordinateSystem.", cs, normalized);
+        assertAxisDirectionsEqual("Normalized", normalized,
+                AxisDirections.COUNTER_CLOCKWISE,
+                AxisDirection.UP,
+                AxisDirections.AWAY_FROM);
     }
 }

Modified: sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/cs/HardCodedAxes.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/cs/HardCodedAxes.java?rev=1737072&r1=1737071&r2=1737072&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/cs/HardCodedAxes.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/cs/HardCodedAxes.java [UTF-8] Tue Mar 29 22:51:40 2016
@@ -24,6 +24,7 @@ import javax.measure.unit.NonSI;
 import org.opengis.referencing.cs.AxisDirection;
 import org.opengis.referencing.cs.RangeMeaning;
 import org.apache.sis.internal.metadata.AxisNames;
+import org.apache.sis.internal.metadata.AxisDirections;
 
 
 /**
@@ -31,7 +32,7 @@ import org.apache.sis.internal.metadata.
  *
  * @author  Martin Desruisseaux (Geomatys)
  * @since   0.4
- * @version 0.6
+ * @version 0.7
  * @module
  */
 public final strictfp class HardCodedAxes {
@@ -164,17 +165,24 @@ public final strictfp class HardCodedAxe
      * Axis for radius in a {@linkplain org.apache.sis.referencing.crs.DefaultGeocentricCRS geocentric CRS}
      * using {@linkplain org.apache.sis.referencing.cs.DefaultSphericalCS spherical CS}.
      * Increasing ordinates values go {@linkplain AxisDirection#UP up} and units are {@linkplain SI#METRE metres}.
-     * The ISO 19111 name is <cite>"geocentric radius"</cite> and the abbreviation is lower case <cite>"r"</cite>.
+     * The ISO 19111 name is <cite>"geocentric radius"</cite> and the abbreviation is upper-case <cite>"R"</cite>.
+     *
+     * <div class="note"><b>Note:</b>
+     * The uses upper-case <cite>"R"</cite> come from EPSG dataset 8.9.
+     * ISO 19111 and 19162 use lower-case <cite>"r"</cite> instead,
+     * but with "awayFrom" direction instead of "geocentricRadius".
+     * In this class, <cite>"r"</cite> is taken by {@link #DISTANCE}.</div>
      *
      * <p>This axis is usually part of a {@link #SPHERICAL_LONGITUDE}, {@link #SPHERICAL_LATITUDE},
      * {@link #GEOCENTRIC_RADIUS} set.</p>
      *
+     * @see #DISTANCE
      * @see #ALTITUDE
      * @see #ELLIPSOIDAL_HEIGHT
      * @see #GRAVITY_RELATED_HEIGHT
      * @see #DEPTH
      */
-    public static final DefaultCoordinateSystemAxis GEOCENTRIC_RADIUS = create(AxisNames.GEOCENTRIC_RADIUS, "r",
+    public static final DefaultCoordinateSystemAxis GEOCENTRIC_RADIUS = create(AxisNames.GEOCENTRIC_RADIUS, "R",
             AxisDirection.UP, SI.METRE, 0, Double.POSITIVE_INFINITY, RangeMeaning.EXACT);
 
     /**
@@ -185,7 +193,10 @@ public final strictfp class HardCodedAxe
      * The ISO 19111 name is <cite>"spherical longitude"</cite> and the abbreviation is "θ" (theta).
      *
      * <p>This axis is close to the definition found in the EPSG database, except for the "long" abbreviation which
-     * is replaced by "θ". Note that other conventions exist, in which the meaning of φ and θ are interchanged.</p>
+     * is replaced by "θ". Note that other conventions exist, in which the meaning of φ and θ are interchanged.
+     * ISO mentions also the symbol Ω, but it is not clear if it applies to longitude or latitude.
+     * The "θ" abbreviation used here is found in ISO 19162.
+     * See {@link AxisNames#SPHERICAL_LONGITUDE} for other information.</p>
      *
      * <p>This axis is usually part of a {@link #SPHERICAL_LONGITUDE}, {@link #SPHERICAL_LATITUDE},
      * {@link #GEOCENTRIC_RADIUS} set.</p>
@@ -208,7 +219,10 @@ public final strictfp class HardCodedAxe
      *
      * <p>This axis is close to the definition found in the EPSG database, except for the "lat" abbreviation
      * which is replaced by "φ′". Note that other conventions exist, in which the meaning of φ and θ are
-     * interchanged or in which this axis is named "elevation" and is oriented toward "Up".</p>
+     * interchanged or in which this axis is named "elevation" and is oriented toward "Up".
+     * Other conventions use symbol Ψ or Ω.
+     * The "φ" abbreviation used here is found in ISO 19162.
+     * See {@link AxisNames#SPHERICAL_LATITUDE} for other information.</p>
      *
      * <p>This axis is usually part of a {@link #SPHERICAL_LONGITUDE}, {@link #SPHERICAL_LATITUDE},
      * {@link #GEOCENTRIC_RADIUS} set.</p>
@@ -361,16 +375,42 @@ public final strictfp class HardCodedAxe
     /**
      * An axis with North-East orientation.
      */
-    static final DefaultCoordinateSystemAxis NORTH_EAST = create("NORTH_EAST", "NE",
+    public static final DefaultCoordinateSystemAxis NORTH_EAST = create("North-East", "NE",
             AxisDirection.NORTH_EAST, SI.METRE, Double.NEGATIVE_INFINITY, Double.POSITIVE_INFINITY, null);
 
     /**
      * An axis with South-East orientation.
      */
-    static final DefaultCoordinateSystemAxis SOUTH_EAST = create("SOUTH_EAST", "SE",
+    public static final DefaultCoordinateSystemAxis SOUTH_EAST = create("South-East", "SE",
             AxisDirection.SOUTH_EAST, SI.METRE, Double.NEGATIVE_INFINITY, Double.POSITIVE_INFINITY, null);
 
     /**
+     * An axis for a distance from an origin.
+     * This is part of a polar or engineering spherical coordinate system
+     * (not to be confused with geodetic spherical coordinate system).
+     *
+     * @see #GEOCENTRIC_RADIUS
+     */
+    public static final DefaultCoordinateSystemAxis DISTANCE = create("Distance", "r",
+            AxisDirections.AWAY_FROM, SI.METRE, 0, Double.POSITIVE_INFINITY, RangeMeaning.EXACT);
+
+    /**
+     * An axis with clockwise orientation.
+     * This is part of a polar or engineering spherical coordinate system
+     * (not to be confused with geodetic spherical coordinate system).
+     */
+    public static final DefaultCoordinateSystemAxis BEARING = create("Bearing", "θ",
+            AxisDirections.CLOCKWISE, NonSI.DEGREE_ANGLE, -180, +180, RangeMeaning.WRAPAROUND);
+
+    /**
+     * An axis with for elevation angle.
+     * This is part of an engineering spherical coordinate system
+     * (not to be confused with geodetic spherical coordinate system).
+     */
+    public static final DefaultCoordinateSystemAxis ELEVATION = create("Elevation", "φ",
+            AxisDirection.UP, NonSI.DEGREE_ANGLE, -90, +90, RangeMeaning.WRAPAROUND);
+
+    /**
      * Axis for time values in a {@linkplain org.apache.sis.referencing.cs.DefaultTimeCS time CS}.
      * Increasing time go toward {@linkplain AxisDirection#FUTURE future} and units are {@linkplain NonSI#DAY days}.
      * The abbreviation is lower case <cite>"t"</cite>.
@@ -421,7 +461,7 @@ public final strictfp class HardCodedAxe
     /**
      * Creates a new axis of the given name, abbreviation, direction and unit.
      */
-    private static DefaultCoordinateSystemAxis create(final String name, final String abbreviation,
+    static DefaultCoordinateSystemAxis create(final String name, final String abbreviation,
             final AxisDirection direction, final Unit<?> unit, final double minimum, final double maximum,
             final RangeMeaning meaning)
     {

Modified: sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/cs/HardCodedCS.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/cs/HardCodedCS.java?rev=1737072&r1=1737071&r2=1737072&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/cs/HardCodedCS.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/cs/HardCodedCS.java [UTF-8] Tue Mar 29 22:51:40 2016
@@ -31,7 +31,7 @@ import static org.apache.sis.referencing
  *
  * @author  Martin Desruisseaux (Geomatys)
  * @since   0.4
- * @version 0.4
+ * @version 0.7
  * @module
  */
 public final strictfp class HardCodedCS {
@@ -84,13 +84,14 @@ public final strictfp class HardCodedCS
             HardCodedAxes.LATITUDE_gon);
 
     /**
-     * A three-dimensional spherical CS with
+     * A three-dimensional spherical CS for geodetic use with
      * <var>{@linkplain HardCodedAxes#SPHERICAL_LATITUDE latitude}</var>,
      * <var>{@linkplain HardCodedAxes#SPHERICAL_LONGITUDE longitude}</var>,
-     * <var>{@linkplain HardCodedAxes#GEOCENTRIC_RADIUS radius}</var>
-     * axes.
+     * <var>{@linkplain HardCodedAxes#GEOCENTRIC_RADIUS radius}</var> axes.
      * This axis order is the one of EPSG:6404.
      * Note that this is not a right-handed system.
+     *
+     * @see #SPHERICAL_ENGINEERING
      */
     public static final DefaultSphericalCS SPHERICAL = new DefaultSphericalCS(
             singletonMap(NAME_KEY, "Spherical"),
@@ -99,6 +100,18 @@ public final strictfp class HardCodedCS
             HardCodedAxes.GEOCENTRIC_RADIUS);
 
     /**
+     * A three-dimensional spherical CS for geodetic use with
+     * <var>{@linkplain HardCodedAxes#DISTANCE distance}</var>,
+     * <var>{@linkplain HardCodedAxes#BEARING bearing}</var>,
+     * <var>{@linkplain HardCodedAxes#ELEVATION elevation}</var> axes.
+     */
+    public static final DefaultSphericalCS SPHERICAL_ENGINEERING = new DefaultSphericalCS(
+            singletonMap(NAME_KEY, SPHERICAL.getName()),
+            HardCodedAxes.DISTANCE,
+            HardCodedAxes.BEARING,
+            HardCodedAxes.ELEVATION);
+
+    /**
      * A three-dimensional Cartesian CS with geocentric
      * <var>{@linkplain HardCodedAxes#GEOCENTRIC_X x}</var>,
      * <var>{@linkplain HardCodedAxes#GEOCENTRIC_Y y}</var>,
@@ -112,6 +125,34 @@ public final strictfp class HardCodedCS
             HardCodedAxes.GEOCENTRIC_Z);
 
     /**
+     * A three-dimensional cylindrical CS with
+     * <var>{@linkplain HardCodedAxes#DISTANCE distance}</var>,
+     * <var>{@link HardCodedAxes#BEARING bearing}</var>,
+     * <var>{@linkplain HardCodedAxes#Z z}</var> axes.
+     * Note that this is not a right-handed system.
+     *
+     * @since 0.7
+     */
+    public static final DefaultCylindricalCS CYLINDRICAL = new DefaultCylindricalCS(
+            singletonMap(NAME_KEY, "Cylindrical"),
+            HardCodedAxes.DISTANCE,
+            HardCodedAxes.BEARING,
+            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>

Modified: sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/cs/NormalizerTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/cs/NormalizerTest.java?rev=1737072&r1=1737071&r2=1737072&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/cs/NormalizerTest.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/cs/NormalizerTest.java [UTF-8] Tue Mar 29 22:51:40 2016
@@ -36,7 +36,7 @@ import static org.apache.sis.test.Refere
  *
  * @author  Martin Desruisseaux (IRD, Geomatys)
  * @since   0.4
- * @version 0.6
+ * @version 0.7
  * @module
  */
 @DependsOn({
@@ -70,8 +70,8 @@ public final strictfp class NormalizerTe
 
         // A plausible CS.
         assertOrdered(new AxisDirection[] {
-            AxisDirection.EAST,    // Right handed-rule
-            AxisDirection.NORTH,   // Right handed-rule
+            AxisDirection.EAST,                 // Right handed-rule
+            AxisDirection.NORTH,                // Right handed-rule
             AxisDirection.UP
         }, new AxisDirection[] {
             AxisDirection.NORTH,
@@ -82,8 +82,8 @@ public final strictfp class NormalizerTe
         // A very dummy CS just for testing. The order of
         // any non-compass direction should be unchanged.
         assertOrdered(new AxisDirection[] {
-            AxisDirection.NORTH_EAST,        // Right handed-rule
-            AxisDirection.NORTH_NORTH_WEST,  // Right handed-rule
+            AxisDirection.NORTH_EAST,           // Right handed-rule
+            AxisDirection.NORTH_NORTH_WEST,     // Right handed-rule
             AxisDirection.GEOCENTRIC_X,
             AxisDirection.GEOCENTRIC_Y,
             AxisDirection.PAST
@@ -97,8 +97,8 @@ public final strictfp class NormalizerTe
 
         // An other plausible CS.
         assertOrdered(new AxisDirection[] {
-            AxisDirection.WEST,   // Right handed-rule
-            AxisDirection.SOUTH,  // Right handed-rule
+            AxisDirection.WEST,                 // Right handed-rule
+            AxisDirection.SOUTH,                // Right handed-rule
             AxisDirection.DOWN
         }, new AxisDirection[] {
             AxisDirection.SOUTH,
@@ -108,8 +108,8 @@ public final strictfp class NormalizerTe
 
         // An other plausible CS.
         assertOrdered(new AxisDirection[] {
-            AxisDirection.SOUTH,  // Right handed-rule
-            AxisDirection.EAST,   // Right handed-rule
+            AxisDirection.SOUTH,                // Right handed-rule
+            AxisDirection.EAST,                 // Right handed-rule
             AxisDirection.DOWN
         }, new AxisDirection[] {
             AxisDirection.SOUTH,
@@ -136,7 +136,7 @@ public final strictfp class NormalizerTe
                                       final CoordinateSystemAxis[] actual)
     {
         final boolean changeExpected = !Arrays.equals(actual, expected);
-        assertEquals(changeExpected, Normalizer.sort(actual));
+        assertEquals(changeExpected, Normalizer.sort(actual, 0));
         assertArrayEquals(expected, actual);
     }
 
@@ -171,10 +171,11 @@ public final strictfp class NormalizerTe
         assertSame(HardCodedAxes.NORTHING,           Normalizer.normalize(HardCodedAxes.NORTHING, changes));
         assertSame(HardCodedAxes.ALTITUDE,           Normalizer.normalize(HardCodedAxes.ALTITUDE, changes));
         assertSame(HardCodedAxes.TIME,               Normalizer.normalize(HardCodedAxes.TIME, changes));
+        assertSame(HardCodedAxes.DISTANCE,           Normalizer.normalize(HardCodedAxes.DISTANCE, changes));
     }
 
     /**
-     * Tests {@link Normalizer#normalize(CoordinateSystemAxis)}.
+     * Tests {@link Normalizer#normalize(CoordinateSystemAxis, AxisFilter)}.
      */
     @Test
     public void testNormalizeAxis() {
@@ -185,15 +186,15 @@ public final strictfp class NormalizerTe
          * Test a change of unit from centimetre to metre.
          */
         assertSame(HardCodedAxes.HEIGHT_cm, Normalizer.normalize(HardCodedAxes.HEIGHT_cm,
-                AxesConvention.CONVENTIONALLY_ORIENTED));   // Do not change unit.
+                AxesConvention.CONVENTIONALLY_ORIENTED));                                   // Do not change unit.
         assertAxisEquals("Height", "h", AxisDirection.UP,
-            Double.NEGATIVE_INFINITY, Double.POSITIVE_INFINITY, SI.METRE, null,
-            Normalizer.normalize(HardCodedAxes.HEIGHT_cm, AxesConvention.NORMALIZED));
+                Double.NEGATIVE_INFINITY, Double.POSITIVE_INFINITY, SI.METRE, null,
+                Normalizer.normalize(HardCodedAxes.HEIGHT_cm, AxesConvention.NORMALIZED));
         /*
          * Test a change of direction from West to East.
          */
         assertAxisEquals(Vocabulary.format(Vocabulary.Keys.Unnamed), "E",
-            AxisDirection.EAST, Double.NEGATIVE_INFINITY, Double.POSITIVE_INFINITY, SI.METRE, null,
-            Normalizer.normalize(HardCodedAxes.WESTING, AxesConvention.NORMALIZED));
+                AxisDirection.EAST, Double.NEGATIVE_INFINITY, Double.POSITIVE_INFINITY, SI.METRE, null,
+                Normalizer.normalize(HardCodedAxes.WESTING, AxesConvention.NORMALIZED));
     }
 }

Modified: sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/datum/BursaWolfParametersTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/datum/BursaWolfParametersTest.java?rev=1737072&r1=1737071&r2=1737072&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/datum/BursaWolfParametersTest.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/datum/BursaWolfParametersTest.java [UTF-8] Tue Mar 29 22:51:40 2016
@@ -37,7 +37,7 @@ import static org.apache.sis.test.Assert
  *
  * @author  Martin Desruisseaux (Geomatys)
  * @since   0.4
- * @version 0.6
+ * @version 0.7
  * @module
  */
 public final strictfp class BursaWolfParametersTest extends TestCase {
@@ -55,7 +55,7 @@ public final strictfp class BursaWolfPar
         bursaWolf.tZ = 4.5;
         bursaWolf.rZ = 0.554;
         bursaWolf.dS = 0.219;
-        bursaWolf.verify();
+        bursaWolf.verify(PrimeMeridianMock.GREENWICH);
         assertFalse("isIdentity",    bursaWolf.isIdentity());
         assertFalse("isTranslation", bursaWolf.isTranslation());
         return bursaWolf;
@@ -75,7 +75,7 @@ public final strictfp class BursaWolfPar
         bursaWolf.rY =    0.1503;
         bursaWolf.rZ =    0.3898;
         bursaWolf.dS =   -0.3143;
-        bursaWolf.verify();
+        bursaWolf.verify(PrimeMeridianMock.GREENWICH);
         assertFalse("isIdentity",    bursaWolf.isIdentity());
         assertFalse("isTranslation", bursaWolf.isTranslation());
         return bursaWolf;
@@ -91,7 +91,7 @@ public final strictfp class BursaWolfPar
         bursaWolf.tX = -168;
         bursaWolf.tY =  -60;
         bursaWolf.tZ =  320;
-        bursaWolf.verify();
+        bursaWolf.verify(PrimeMeridianMock.GREENWICH);
         assertFalse("isIdentity",    bursaWolf.isIdentity());
         assertTrue ("isTranslation", bursaWolf.isTranslation());
         return bursaWolf;

Modified: sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/matrix/MatrixTestCase.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/matrix/MatrixTestCase.java?rev=1737072&r1=1737071&r2=1737072&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/matrix/MatrixTestCase.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/matrix/MatrixTestCase.java [UTF-8] Tue Mar 29 22:51:40 2016
@@ -534,7 +534,7 @@ public abstract strictfp class MatrixTes
     /**
      * Tests {@link MatrixSIS#solve(Matrix)}.
      *
-     * @throws NoninvertibleMatrixException Should never happen.
+     * @throws NoninvertibleMatrixException if the matrix can not be inverted.
      */
     @Test
     @DependsOnMethod("testMultiply")
@@ -575,7 +575,7 @@ public abstract strictfp class MatrixTes
      * Tests {@link MatrixSIS#inverse()}.
      * SIS implements the {@code inverse} operation as a special case of the {@code solve} operation.
      *
-     * @throws NoninvertibleMatrixException Should never happen.
+     * @throws NoninvertibleMatrixException if the matrix can not be inverted.
      */
     @Test
     @DependsOnMethod("testSolve")

Modified: sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/matrix/NonSquareMatrixTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/matrix/NonSquareMatrixTest.java?rev=1737072&r1=1737071&r2=1737072&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/matrix/NonSquareMatrixTest.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/matrix/NonSquareMatrixTest.java [UTF-8] Tue Mar 29 22:51:40 2016
@@ -17,9 +17,11 @@
 package org.apache.sis.referencing.operation.matrix;
 
 import java.util.Random;
+import org.opengis.test.Assert;
 import org.apache.sis.test.DependsOn;
 import org.apache.sis.test.TestUtilities;
 import org.junit.AfterClass;
+import org.junit.Test;
 
 import static java.lang.Double.NaN;
 import static org.junit.Assert.*;
@@ -37,7 +39,7 @@ import static org.junit.Assert.*;
  *
  * @author  Martin Desruisseaux (Geomatys)
  * @since   0.4
- * @version 0.4
+ * @version 0.7
  * @module
  */
 @DependsOn(SolverTest.class)
@@ -76,8 +78,9 @@ public final strictfp class NonSquareMat
     /**
      * Tests {@link NonSquareMatrix#inverse()} with a non-square matrix.
      *
-     * @throws NoninvertibleMatrixException Should never happen.
+     * @throws NoninvertibleMatrixException if the matrix can not be inverted.
      */
+    @Test
     @Override
     public void testInverse() throws NoninvertibleMatrixException {
         testDimensionReduction(null, 1, 0);
@@ -85,10 +88,51 @@ public final strictfp class NonSquareMat
     }
 
     /**
+     * Tests inversion of a matrix with a column containing only a translation term.
+     * The purpose is to test the algorithm that selects the rows to omit.
+     *
+     * @throws NoninvertibleMatrixException if the matrix can not be inverted.
+     */
+    @Test
+    public void testInverseWithTranslationTerm() throws NoninvertibleMatrixException {
+        final NonSquareMatrix m = new NonSquareMatrix(5, 3, new double[] {
+            2, 0, 0,
+            0, 0, 0,
+            0, 4, 0,
+            0, 0, 3,
+            0, 0, 1
+        });
+        MatrixSIS inverse = m.inverse();
+        Assert.assertMatrixEquals("Inverse of non-square matrix.", new NonSquareMatrix(3, 5, new double[] {
+            0.5, 0,   0,    0,   0,
+            0,   0,   0.25, 0,   0,
+            0,   0,   0,    0,   1}), inverse, STRICT);
+
+        Assert.assertMatrixEquals("Back to original.", new NonSquareMatrix(5, 3, new double[] {
+            2, 0, 0,
+            0, 0, NaN,
+            0, 4, 0,
+            0, 0, NaN,
+            0, 0, 1}), inverse.inverse(), STRICT);
+        /*
+         * Change the [0 0 3] row into [1 0 3]. The NonSquareMarix class should no longer omit that row.
+         * As a consequence, the matrix can not be inverted anymore.
+         */
+        m.setElement(3, 0, 1);
+        try {
+            m.inverse();
+            fail("Matrix should not be invertible.");
+        } catch (NoninvertibleMatrixException e) {
+            assertNotNull(e.getMessage());
+        }
+    }
+
+    /**
      * Tests {@link NonSquareMatrix#solve(Matrix)} with a non-square matrix.
      *
-     * @throws NoninvertibleMatrixException Should never happen.
+     * @throws NoninvertibleMatrixException if the matrix can not be inverted.
      */
+    @Test
     @Override
     public void testSolve() throws NoninvertibleMatrixException {
         testDimensionReduction(new Matrix3(
@@ -110,7 +154,7 @@ public final strictfp class NonSquareMat
      * @param  Y    The matrix to give to {@code solve(Y)}, {@code null} for testing {@code inverse()}.
      * @param  sf   The scale factor by which to multiply all expected scale elements.
      * @param  uks  Value of unknown scales (O for {@code inverse()}, or NaN for {@code solve(Y)}).
-     * @throws NoninvertibleMatrixException Should never happen.
+     * @throws NoninvertibleMatrixException if the matrix can not be inverted.
      */
     private static void testDimensionReduction(final MatrixSIS Y, final double sf, final double uks)
             throws NoninvertibleMatrixException
@@ -137,7 +181,7 @@ public final strictfp class NonSquareMat
      *
      * @param  Y    The matrix to give to {@code solve(Y)}, {@code null} for testing {@code inverse()}.
      * @param  sf   The scale factor by which to multiply all expected scale elements.
-     * @throws NoninvertibleMatrixException Should never happen.
+     * @throws NoninvertibleMatrixException if the matrix can not be inverted.
      */
     private static void testDimensionIncrease(final MatrixSIS Y, final double sf)
             throws NoninvertibleMatrixException

Copied: sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/transform/CoordinateSystemTransformTest.java (from r1737071, 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/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/transform/CoordinateSystemTransformTest.java?p2=sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/transform/CoordinateSystemTransformTest.java&p1=sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/transform/CoordinateSystemTransformTest.java&r1=1737071&r2=1737072&rev=1737072&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/transform/CoordinateSystemTransformTest.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/transform/CoordinateSystemTransformTest.java [UTF-8] Tue Mar 29 22:51:40 2016
@@ -40,6 +40,9 @@ import org.junit.BeforeClass;
 import org.junit.AfterClass;
 import org.junit.Test;
 
+// Branch-dependent imports
+import org.opengis.referencing.cs.AxisDirection;
+
 
 
 /**
@@ -93,6 +96,24 @@ public final strictfp class CoordinateSy
             @Override public Unit<?> getUnitReplacement(CoordinateSystemAxis axis, Unit<?> unit) {
                 return Units.isLinear(unit) ? SI.CENTIMETRE : unit;
             }
+            @Override public Unit<?> getUnitReplacement(Unit<?> unit) {
+                return Units.isLinear(unit) ? SI.CENTIMETRE : unit;
+            }
+
+            @Override
+            public boolean accept(CoordinateSystemAxis axis) {
+                return true;
+            }
+
+            @Override
+            public AxisDirection getDirectionReplacement(CoordinateSystemAxis axis, AxisDirection direction) {
+                return direction;
+            }
+
+            @Override
+            public AxisDirection getDirectionReplacement(AxisDirection direction) {
+                return direction;
+            }
         });
     }
 

Modified: sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/transform/EllipsoidToCentricTransformTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/transform/EllipsoidToCentricTransformTest.java?rev=1737072&r1=1737071&r2=1737072&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/transform/EllipsoidToCentricTransformTest.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/transform/EllipsoidToCentricTransformTest.java [UTF-8] Tue Mar 29 22:51:40 2016
@@ -59,8 +59,22 @@ public final strictfp class EllipsoidToC
      * Convenience method for creating an instance from an ellipsoid.
      */
     private void createGeodeticConversion(final Ellipsoid ellipsoid, boolean is3D) throws FactoryException {
-        transform = EllipsoidToCentricTransform.createGeodeticConversion(
-                DefaultFactories.forBuildin(MathTransformFactory.class), ellipsoid, is3D);
+        final MathTransformFactory factory = DefaultFactories.forBuildin(MathTransformFactory.class);
+        transform = EllipsoidToCentricTransform.createGeodeticConversion(factory, ellipsoid, is3D);
+        /*
+         * If the ellipsoid is a sphere, then EllipsoidToCentricTransform.createGeodeticConversion(…) created a
+         * SphericalToCartesian instance instead than an EllipsoidToCentricTransform instance.  Create manually
+         * the EllipsoidToCentricTransform here and wrap the two transform in a comparator for making sure that
+         * the two implementations are consistent.
+         */
+        if (ellipsoid.isSphere()) {
+            EllipsoidToCentricTransform tr = new EllipsoidToCentricTransform(
+                    ellipsoid.getSemiMajorAxis(),
+                    ellipsoid.getSemiMinorAxis(),
+                    ellipsoid.getAxisUnit(), is3D,
+                    EllipsoidToCentricTransform.TargetType.CARTESIAN);
+            transform = new TransformResultComparator(transform, tr.context.completeTransform(factory, tr), 1E-2);
+        }
     }
 
     /**

Modified: sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/transform/ProjectiveTransformTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/transform/ProjectiveTransformTest.java?rev=1737072&r1=1737071&r2=1737072&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/transform/ProjectiveTransformTest.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/transform/ProjectiveTransformTest.java [UTF-8] Tue Mar 29 22:51:40 2016
@@ -21,7 +21,9 @@ import org.opengis.referencing.operation
 import org.opengis.referencing.operation.MathTransform1D;
 import org.opengis.referencing.operation.MathTransform2D;
 import org.opengis.referencing.operation.MathTransformFactory;
+import org.opengis.referencing.operation.TransformException;
 import org.apache.sis.referencing.operation.matrix.Matrices;
+import org.apache.sis.referencing.operation.matrix.MatrixSIS;
 import org.apache.sis.internal.referencing.provider.Affine;
 import org.apache.sis.parameter.Parameterized;
 
@@ -31,6 +33,7 @@ import org.apache.sis.test.DependsOn;
 import org.junit.runner.RunWith;
 import org.junit.runners.JUnit4;
 import org.junit.After;
+import org.junit.Test;
 import static org.opengis.test.Assert.*;
 
 // Branch-dependent imports
@@ -100,6 +103,35 @@ public strictfp class ProjectiveTransfor
      */
 
     /**
+     * Tests {@link ProjectiveTransform#optimize()}. In particular this method verifies that a non-square matrix
+     * that looks like diagonal is not confused with a real diagonal matrix.
+     *
+     * @throws TransformException if a coordinate conversion failed.
+     *
+     * @since 0.7
+     */
+    @Test
+    public void testOptimize() throws TransformException {
+        matrix = Matrices.create(5, 4, new double[] {
+            2, 0, 0, 0,
+            0, 3, 0, 0,
+            0, 0, 4, 0,
+            0, 0, 0, 5,
+            0, 0, 0, 1
+        });
+        transform = new ProjectiveTransform(matrix).optimize();
+        assertInstanceOf("Non-diagonal matrix shall not be handled by ScaleTransform.", ProjectiveTransform.class, transform);
+        verifyConsistency(1, 2, 3,   -3, -2, -1);
+        /*
+         * Remove the "problematic" row. The new transform should now be optimizable.
+         */
+        matrix = ((MatrixSIS) matrix).removeRows(3, 4);
+        transform = new ProjectiveTransform(matrix).optimize();
+        assertInstanceOf("Diagonal matrix should be handled by a specialized class.", ScaleTransform.class, transform);
+        verifyConsistency(1, 2, 3,   -3, -2, -1);
+    }
+
+    /**
      * {@code true} if {@link #ensureImplementRightInterface()} should skip its check for a transform
      * of the given dimension. {@code ProjectiveTransformTest} needs to skip the case for dimension 1
      * because there is no {@code ProjectiveTransform1D} class. However {@link LinearTransformTest}

Modified: sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/transform/TransformResultComparator.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/transform/TransformResultComparator.java?rev=1737072&r1=1737071&r2=1737072&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/transform/TransformResultComparator.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/transform/TransformResultComparator.java [UTF-8] Tue Mar 29 22:51:40 2016
@@ -23,13 +23,12 @@ import org.opengis.referencing.operation
 import org.opengis.referencing.operation.MathTransform;
 import org.opengis.referencing.operation.TransformException;
 import org.opengis.referencing.operation.NoninvertibleTransformException;
-import org.apache.sis.geometry.GeneralDirectPosition;
 
 import static org.opengis.test.Assert.*;
 
 
 /**
- * Compares the projection results of two {@link MathTransform} implementations.
+ * Compares the results of two {@link MathTransform} implementations.
  *
  * @author  Martin Desruisseaux (Geomatys)
  * @since   0.7
@@ -111,9 +110,9 @@ final strictfp class TransformResultComp
      */
     @Override
     public DirectPosition transform(DirectPosition ptSrc, DirectPosition ptDst) throws TransformException {
-        GeneralDirectPosition clone = new GeneralDirectPosition(ptSrc);
+        final double[] expected = reference.transform(ptSrc, ptDst).getCoordinate();
         final DirectPosition value = tested.transform(ptSrc, ptDst);
-        assertEquals("transform(DirectPosition, …)", reference.transform(clone, null), value);
+        assertArrayEquals("transform(DirectPosition, …)", expected, value.getCoordinate(), tolerance);
         return value;
     }
 

Modified: sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/test/suite/ReferencingTestSuite.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/test/suite/ReferencingTestSuite.java?rev=1737072&r1=1737071&r2=1737072&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/test/suite/ReferencingTestSuite.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/test/suite/ReferencingTestSuite.java [UTF-8] Tue Mar 29 22:51:40 2016
@@ -91,6 +91,8 @@ 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,
     org.apache.sis.referencing.cs.HardCodedCSTest.class,
@@ -121,6 +123,11 @@ import org.junit.BeforeClass;
     org.apache.sis.referencing.operation.transform.ContextualParametersTest.class,
     org.apache.sis.referencing.operation.transform.EllipsoidToCentricTransformTest.class,
     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.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,
     org.apache.sis.referencing.operation.AbstractSingleOperationTest.class,
@@ -163,6 +170,7 @@ import org.junit.BeforeClass;
     org.apache.sis.referencing.operation.SingleOperationMarshallingTest.class,
     org.apache.sis.referencing.operation.DefaultPassThroughOperationTest.class,
     org.apache.sis.referencing.operation.DefaultConcatenatedOperationTest.class,
+    org.apache.sis.referencing.operation.CoordinateOperationInferenceTest.class,
     org.apache.sis.referencing.crs.DefaultProjectedCRSTest.class,
     org.apache.sis.referencing.crs.DefaultDerivedCRSTest.class,
     org.apache.sis.referencing.crs.SubTypesTest.class,

Modified: sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/internal/jdk8/JDK8.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/internal/jdk8/JDK8.java?rev=1737072&r1=1737071&r2=1737072&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/internal/jdk8/JDK8.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/internal/jdk8/JDK8.java [UTF-8] Tue Mar 29 22:51:40 2016
@@ -219,6 +219,28 @@ public final class JDK8 {
     }
 
     /**
+     * Replaces the value for the given key if the current value is {@code oldValue}.
+     *
+     * @param  <K>      The type of keys.
+     * @param  <V>      The type of values.
+     * @param  map      The map from where to replace the values.
+     * @param  key      The key of value to replace.
+     * @param  oldValue The expected current value.
+     * @param  newValue The new value to store if the current value is the expected one.
+     * @return Whether the replacement has been done.
+     *
+     * @since 0.7
+     */
+    public static <K,V> boolean replace(final Map<K,V> map, final K key, final V oldValue, final V newValue) {
+        final Object c = map.get(key);
+        if (Objects.equals(c, oldValue) && (c != null || map.containsKey(key))) {
+            map.put(key, newValue);
+            return true;
+        }
+        return false;
+    }
+
+    /**
      * Replaces the values for all entries in the given map.
      *
      * @param  <K>      The type of keys.

Modified: sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/internal/system/Shutdown.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/internal/system/Shutdown.java?rev=1737072&r1=1737071&r2=1737072&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/internal/system/Shutdown.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/internal/system/Shutdown.java [UTF-8] Tue Mar 29 22:51:40 2016
@@ -19,8 +19,6 @@ package org.apache.sis.internal.system;
 import java.util.List;
 import java.util.ArrayList;
 import java.util.concurrent.Callable;
-import java.security.AccessController;
-import java.security.PrivilegedAction;
 import org.apache.sis.util.logging.Logging;
 
 // Branch-dependent imports
@@ -118,12 +116,7 @@ public final class Shutdown extends Thre
             resources.add(resource);
             if (hook == null && container == null) {
                 hook = new Shutdown();
-                AccessController.doPrivileged(new PrivilegedAction<Void>() {
-                    @Override public Void run() {
-                        Runtime.getRuntime().addShutdownHook(hook);
-                        return null;
-                    }
-                });
+                Runtime.getRuntime().addShutdownHook(hook);
             }
         }
     }
@@ -134,12 +127,7 @@ public final class Shutdown extends Thre
     private static void removeShutdownHook() {
         assert Thread.holdsLock(resources);
         if (hook != null) {
-            AccessController.doPrivileged(new PrivilegedAction<Void>() {
-                @Override public Void run() {
-                    Runtime.getRuntime().removeShutdownHook(hook);
-                    return null;
-                }
-            });
+            Runtime.getRuntime().removeShutdownHook(hook);
             hook = null;
         }
     }

Modified: sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/util/Exceptions.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/util/Exceptions.java?rev=1737072&r1=1737071&r2=1737072&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/util/Exceptions.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/util/Exceptions.java [UTF-8] Tue Mar 29 22:51:40 2016
@@ -22,6 +22,7 @@ import java.util.Locale;
 import java.sql.SQLException;
 import org.apache.sis.internal.util.LocalizedException;
 
+import org.apache.sis.util.resources.Vocabulary;
 import static org.apache.sis.util.CharSequences.trimWhitespaces;
 
 
@@ -30,7 +31,7 @@ import static org.apache.sis.util.CharSe
  *
  * @author  Martin Desruisseaux (IRD, Geomatys)
  * @since   0.3
- * @version 0.4
+ * @version 0.7
  * @module
  */
 public final class Exceptions extends Static {
@@ -109,8 +110,8 @@ public final class Exceptions extends St
      * Returns a string which contain the given message on the first line, followed by the
      * {@linkplain Throwable#getLocalizedMessage() localized message} of the given exception
      * on the next line. If the exception has a {@linkplain Throwable#getCause() causes}, then
-     * the localized message of the cause is formatted on the next line and the process is
-     * repeated for the whole cause chain, omitting duplicated messages.
+     * the class name and the localized message of the cause are formatted on the next line
+     * and the process is repeated for the whole cause chain, omitting duplicated messages.
      *
      * <p>{@link SQLException} is handled especially in order to process the
      * {@linkplain SQLException#getNextException() next exception} instead than the cause.</p>
@@ -124,16 +125,15 @@ public final class Exceptions extends St
      *         and no exception provide a message.
      */
     public static String formatChainedMessages(final Locale locale, String header, Throwable cause) {
-        List<String> previousLines = null;
-        String lineSeparator = null;
+        final List<String> previousLines = new ArrayList<>();
+        final String lineSeparator = System.lineSeparator();
         StringBuilder buffer = null;
+        Vocabulary resources = null;
         while (cause != null) {
             final String message = trimWhitespaces(getLocalizedMessage(cause, locale));
             if (message != null && !message.isEmpty()) {
                 if (buffer == null) {
                     buffer = new StringBuilder(128);
-                    previousLines = new ArrayList<>(4);
-                    lineSeparator = System.lineSeparator();
                     header = trimWhitespaces(header);
                     if (header != null && !header.isEmpty()) {
                         buffer.append(header);
@@ -144,6 +144,10 @@ public final class Exceptions extends St
                     previousLines.add(message);
                     if (buffer.length() != 0) {
                         buffer.append(lineSeparator);
+                        if (resources == null) {
+                            resources = Vocabulary.getResources(locale);
+                        }
+                        buffer.append(resources.getString(Vocabulary.Keys.CausedBy_1, cause.getClass())).append(": ");
                     }
                     buffer.append(message);
                 }
@@ -168,8 +172,7 @@ public final class Exceptions extends St
      */
     private static boolean contains(final List<String> previousLines, final String message) {
         for (int i=previousLines.size(); --i>=0;) {
-            final int p = previousLines.get(i).indexOf(message);
-            if (p >= 0) {
+            if (previousLines.get(i).contains(message)) {
                 return true;
             }
         }

Modified: sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/util/Utilities.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/util/Utilities.java?rev=1737072&r1=1737071&r2=1737072&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/util/Utilities.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/util/Utilities.java [UTF-8] Tue Mar 29 22:51:40 2016
@@ -55,7 +55,7 @@ public final class Utilities extends Sta
      *
      *   <li>If the two given objects are
      *       {@linkplain org.apache.sis.referencing.crs.AbstractCRS Coordinate Reference Systems} (CRS), then a call to
-     *       <code>{@linkplain org.apache.sis.referencing.CRS#findOperation findOperation}(crs1, crs2)</code>
+     *       <code>{@linkplain org.apache.sis.referencing.CRS#findOperation findOperation}(crs1, crs2, null)</code>
      *       will return an identity operation.</li>
      * </ul>
      *
@@ -92,7 +92,7 @@ public final class Utilities extends Sta
      *
      *   <li>If the two given objects are
      *       {@linkplain org.apache.sis.referencing.crs.AbstractCRS Coordinate Reference Systems} (CRS), then a call to
-     *       <code>{@linkplain org.apache.sis.referencing.CRS#findOperation findOperation}(crs1, crs2)</code>
+     *       <code>{@linkplain org.apache.sis.referencing.CRS#findOperation findOperation}(crs1, crs2, null)</code>
      *       will return an operation close to identity.</li>
      * </ul>
      *

Modified: sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/util/logging/MonolineFormatter.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/util/logging/MonolineFormatter.java?rev=1737072&r1=1737071&r2=1737072&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/util/logging/MonolineFormatter.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/util/logging/MonolineFormatter.java [UTF-8] Tue Mar 29 22:51:40 2016
@@ -86,7 +86,7 @@ import org.apache.sis.util.Debug;
  *     #
  *     #  source: If set, writes the source logger name or the source class name.
  *     #          Valid argument values are "none", "logger:short", "logger:long",
- *     #          "class:short" and "class:long".
+ *     #          "class:short", "class:long" and "class.method".
  *     ###########################################################################
  *     org.apache.sis.util.logging.MonolineFormatter.time = HH:mm:ss.SSS
  *     org.apache.sis.util.logging.MonolineFormatter.source = class:short
@@ -120,16 +120,18 @@ public class MonolineFormatter extends F
     /** Format the source logger only.         */ private static final int LOGGER_LONG  = 2;
     /** Format the class name without package. */ private static final int CLASS_SHORT  = 3;
     /** Format the fully qualified class name. */ private static final int CLASS_LONG   = 4;
+    /** Format the class name and method name. */ private static final int METHOD       = 5;
 
     /**
      * The label to use in the {@code logging.properties} for setting the source format.
      */
-    private static final String[] FORMAT_LABELS = new String[5];
+    private static final String[] FORMAT_LABELS = new String[6];
     static {
         FORMAT_LABELS[LOGGER_SHORT] = "logger:short";
         FORMAT_LABELS[LOGGER_LONG ] = "logger:long";
         FORMAT_LABELS[ CLASS_SHORT] = "class:short";
         FORMAT_LABELS[ CLASS_LONG ] = "class:long";
+        FORMAT_LABELS[METHOD      ] = "class.method";
     }
 
     /**
@@ -236,7 +238,7 @@ public class MonolineFormatter extends F
 
     /**
      * One of the following constants: {@link #NO_SOURCE}, {@link #LOGGER_SHORT},
-     * {@link #LOGGER_LONG}, {@link #CLASS_SHORT} or {@link #CLASS_LONG}.
+     * {@link #LOGGER_LONG}, {@link #CLASS_SHORT}, {@link #CLASS_LONG} or {@link #METHOD}.
      */
     private int sourceFormat = NO_SOURCE;
 
@@ -375,7 +377,7 @@ loop:   for (int i=0; ; i++) {
      *        or {@code null} if none.
      */
     public void setHeader(String header) {
-        if (header == null) { // See comment in getHeader().
+        if (header == null) {                           // See comment in getHeader().
             header = "";
         }
         synchronized (buffer) {
@@ -454,6 +456,8 @@ loop:   for (int i=0; ; i++) {
      *   <li>{@code "logger:long"}  for the {@linkplain LogRecord#getLoggerName() logger name}</li>
      *   <li>{@code "class:short"}  for the source class name without the package part.</li>
      *   <li>{@code "logger:short"} for the logger name without the package part.</li>
+     *   <li>{@code "class.method"} for the short class name followed by the
+     *       {@linkplain LogRecord#getSourceMethodName() source method name}</li>
      * </ul>
      *
      * The source class name usually contains the logger name since (by convention) logger
@@ -605,7 +609,7 @@ loop:   for (int i=0; ; i++) {
         }
         int i = Arrays.binarySearch(colorLevels, level.intValue());
         if (i < 0) {
-            i = Math.max((~i)-1, 0);  // Really tild, not minus sign.
+            i = Math.max((~i)-1, 0);                    // Really tild, not minus sign.
         }
         return colorSequences[i];
     }
@@ -660,12 +664,14 @@ loop:   for (int i=0; ; i++) {
             switch (sourceFormat) {
                 case LOGGER_SHORT: // Fall through
                 case LOGGER_LONG:  source = record.getLoggerName(); break;
+                case METHOD:       // Fall through
                 case CLASS_SHORT:  // Fall through
                 case CLASS_LONG:   source = record.getSourceClassName(); break;
                 default:           source = null; break;
             }
             if (source != null) {
                 switch (sourceFormat) {
+                    case METHOD:       // Fall through
                     case LOGGER_SHORT: // Fall through
                     case CLASS_SHORT: {
                         // Works even if there is no '.' since we get -1 as index.
@@ -673,6 +679,9 @@ loop:   for (int i=0; ; i++) {
                         break;
                     }
                 }
+                if (sourceFormat == METHOD) {
+                    source = source + '.' + record.getSourceMethodName();
+                }
                 if (colors && emphase) {
                     buffer.append(X364.BOLD.sequence());
                 }
@@ -712,7 +721,7 @@ loop:   for (int i=0; ; i++) {
                 }
                 if (exception != null) {
                     if (message != null) {
-                        writer.append("\nCaused by: "); // LineAppender will replace '\n' by the system EOL.
+                        writer.append("\nCaused by: ");     // LineAppender will replace '\n' by the system EOL.
                     }
                     if (level.intValue() >= LEVEL_THRESHOLD.intValue()) {
                         exception.printStackTrace(printer);
@@ -881,7 +890,7 @@ loop:   for (int i=0; ; i++) {
             if (con) {
                 writer.append(" ...");
             }
-            writer.append('\n'); // LineAppender will replace '\n' by the system EOL.
+            writer.append('\n');                    // LineAppender will replace '\n' by the system EOL.
         }
     }
 
@@ -1001,7 +1010,7 @@ loop:   for (int i=0; ; i++) {
             }
             final Handler handler = new ConsoleHandler();
             if (level != null) {
-                handler.setLevel(level); // Shall be before MonolineFormatter creation.
+                handler.setLevel(level);                    // Shall be before MonolineFormatter creation.
             }
             monoline = new MonolineFormatter(handler);
             handler.setFormatter(monoline);

Modified: sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/util/resources/Errors.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/util/resources/Errors.java?rev=1737072&r1=1737071&r2=1737072&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/util/resources/Errors.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/util/resources/Errors.java [UTF-8] Tue Mar 29 22:51:40 2016
@@ -121,12 +121,12 @@ public final class Errors extends Indexe
         public static final short CanNotConvertValue_2 = 4;
 
         /**
-         * Can not create an object of type “{1}” as an instance of ‘{0}’.
+         * Can not create an object “{1}” as an instance of class ‘{0}’.
          */
-        public static final short CanNotCreateObjectOfType_2 = 215;
+        public static final short CanNotCreateObjectAsInstanceOf_2 = 215;
 
         /**
-         * Can not instantiate an object of type ‘{0}’.
+         * Can not instantiate “{0}”.
          */
         public static final short CanNotInstantiate_1 = 5;
 
@@ -206,6 +206,11 @@ public final class Errors extends Indexe
         public static final short ColinearAxisDirections_2 = 14;
 
         /**
+         * Coordinate conversion of transformation from system “{0}” to “{1}” has not been found.
+         */
+        public static final short CoordinateOperationNotFound_2 = 219;
+
+        /**
          * Database error while creating a ‘{0}’ object for code “{1}”.
          */
         public static final short DatabaseError_2 = 209;
@@ -584,6 +589,11 @@ public final class Errors extends Indexe
         public static final short MismatchedParameterDescriptor_1 = 146;
 
         /**
+         * Expected the “{0}” prime meridian but found “{1}”.
+         */
+        public static final short MismatchedPrimeMeridian_2 = 220;
+
+        /**
          * Mismatched type for “{0}” property.
          */
         public static final short MismatchedPropertyType_1 = 154;




Mime
View raw message