sis-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From desruisse...@apache.org
Subject svn commit: r1684220 - in /sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis: io/wkt/ referencing/crs/ referencing/cs/ referencing/operation/
Date Mon, 08 Jun 2015 16:52:43 GMT
Author: desruisseaux
Date: Mon Jun  8 16:52:42 2015
New Revision: 1684220

URL: http://svn.apache.org/r1684220
Log:
WKT: added tests.

Modified:
    sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/io/wkt/GeodeticObjectParserTest.java
    sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/crs/DefaultGeographicCRSTest.java
    sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/crs/DefaultProjectedCRSTest.java
    sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/crs/HardCodedCRS.java
    sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/cs/HardCodedAxes.java
    sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/cs/HardCodedCS.java
    sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/DefaultConversionTest.java

Modified: sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/io/wkt/GeodeticObjectParserTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/io/wkt/GeodeticObjectParserTest.java?rev=1684220&r1=1684219&r2=1684220&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/io/wkt/GeodeticObjectParserTest.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/io/wkt/GeodeticObjectParserTest.java
[UTF-8] Mon Jun  8 16:52:42 2015
@@ -27,6 +27,7 @@ import org.opengis.referencing.Identifie
 import org.opengis.referencing.cs.*;
 import org.opengis.referencing.crs.*;
 import org.opengis.referencing.datum.*;
+import org.opengis.parameter.ParameterValue;
 import org.opengis.parameter.ParameterValueGroup;
 import org.apache.sis.internal.metadata.AxisNames;
 import org.apache.sis.test.DependsOnMethod;
@@ -127,6 +128,15 @@ public final strictfp class GeodeticObje
     }
 
     /**
+     * Verifies that the axes of the coordinate system are those of a projected CRS, in metres.
+     */
+    private static void verifyProjectedCS(final CartesianCS cs) {
+        assertEquals("dimension", 2, cs.getDimension());
+        assertUnboundedAxisEquals("Easting",  "E", AxisDirection.EAST,  SI.METRE, cs.getAxis(0));
+        assertUnboundedAxisEquals("Northing", "N", AxisDirection.NORTH, SI.METRE, cs.getAxis(1));
+    }
+
+    /**
      * Tests the parsing of a geocentric CRS from a WKT 1 string. The parser
      * shall replace the OGC 01-009 axis directions (OTHER, EAST, NORTH) by
      * ISO 19111 axis directions (Geocentric X, Geocentric Y, Geocentric Z).
@@ -252,23 +262,24 @@ public final strictfp class GeodeticObje
     public void testProjectedCRS() throws ParseException {
         final ProjectedCRS crs = parse(ProjectedCRS.class,
                 "PROJCS[“Mercator test”,\n" +
-               "  GEOGCS[“WGS 84”,\n" +
-               "    DATUM[“World Geodetic System 1984”,\n" +
-               "      SPHEROID[“WGS84”, 6378137.0, 298.257223563]],\n" +
-               "      PRIMEM[“Greenwich”, 0.0],\n" +
-               "    UNIT[“degree”, 0.017453292519943295],\n" +
-               "    AXIS[“Longitude”, EAST],\n" +
-               "    AXIS[“Latitude”, NORTH]],\n" +
-               "  PROJECTION[“Mercator_1SP”],\n" +
-               "  PARAMETER[“central_meridian”, -20.0],\n" +
-               "  PARAMETER[“scale_factor”, 1.0],\n" +
-               "  PARAMETER[“false_easting”, 500000.0],\n" +
-               "  PARAMETER[“false_northing”, 0.0],\n" +
-               "  UNIT[“metre”, 1.0],\n" +
-               "  AXIS[“Easting”, EAST],\n" +
-               "  AXIS[“Northing”, NORTH]]");
+                "  GEOGCS[“WGS 84”,\n" +
+                "    DATUM[“World Geodetic System 1984”,\n" +
+                "      SPHEROID[“WGS84”, 6378137.0, 298.257223563]],\n" +
+                "      PRIMEM[“Greenwich”, 0.0],\n" +
+                "    UNIT[“degree”, 0.017453292519943295],\n" +
+                "    AXIS[“Longitude”, EAST],\n" +
+                "    AXIS[“Latitude”, NORTH]],\n" +
+                "  PROJECTION[“Mercator_1SP”],\n" +
+                "  PARAMETER[“central_meridian”, -20.0],\n" +
+                "  PARAMETER[“scale_factor”, 1.0],\n" +
+                "  PARAMETER[“false_easting”, 500000.0],\n" +
+                "  PARAMETER[“false_northing”, 0.0],\n" +
+                "  UNIT[“metre”, 1.0],\n" +
+                "  AXIS[“Easting”, EAST],\n" +
+                "  AXIS[“Northing”, NORTH]]");
 
         assertNameAndIdentifierEqual("Mercator test", 0, crs);
+        verifyProjectedCS(crs.getCoordinateSystem());
         verifyGeographicCRS(0, crs.getBaseCRS());
 
         final GeodeticDatum datum = crs.getDatum();
@@ -280,11 +291,6 @@ public final strictfp class GeodeticObje
         assertEquals("semiMajor", 6378137, ellipsoid.getSemiMajorAxis(), STRICT);
         assertEquals("inverseFlattening", 298.257223563, ellipsoid.getInverseFlattening(),
STRICT);
 
-        final CartesianCS cs = crs.getCoordinateSystem();
-        assertEquals("dimension", 2, cs.getDimension());
-        assertUnboundedAxisEquals("Easting",  "E", AxisDirection.EAST,  SI.METRE, cs.getAxis(0));
-        assertUnboundedAxisEquals("Northing", "N", AxisDirection.NORTH, SI.METRE, cs.getAxis(1));
-
         assertEquals("Mercator (variant A)", crs.getConversionFromBase().getMethod().getName().getCode());
         final ParameterValueGroup param = crs.getConversionFromBase().getParameterValues();
         assertEquals("semi_major",   6378137.0, param.parameter("semi_major"      ).doubleValue(),
STRICT);
@@ -332,7 +338,7 @@ public final strictfp class GeodeticObje
          * This is a violation of both OGC 01-009 and ISO 19162 standards, but this is what
GDAL does.
          * So we allow this interpretation in Convention.WKT1_COMMON_UNITS for compatibility
reasons.
          */
-        wkt = wkt.replace("2.5969213", "2.33722917");
+        wkt = wkt.replace("2.5969213", "2.33722917");   // Convert unit in prime meridian.
         setConvention(Convention.WKT1_COMMON_UNITS, true);
         crs = parse(GeographicCRS.class, wkt);
         assertNameAndIdentifierEqual("NTF (Paris)", 0, crs);
@@ -346,7 +352,63 @@ public final strictfp class GeodeticObje
     }
 
     /**
-     * Verifies some invariant of the CRS parsed by {@link #testNonGreenwichMeridian()}.
+     * Tests the parsing of a projected CRS using parameters in grades instead than degrees.
+     * The grad units are also used for the prime meridian.
+     *
+     * @throws ParseException if the parsing failed.
+     */
+    @Test
+    @DependsOnMethod({"testNonGreenwichMeridian", "testProjectedCRS"})
+    public void testGradUnitInParameters() throws ParseException {
+        String wkt = "PROJCS[“NTF (Paris) / Lambert zone II”," +
+                     "  GEOGCS[“NTF (Paris)”," +
+                     "    DATUM[“Nouvelle Triangulation Française (Paris)”," +
+                     "      SPHEROID[“Clarke 1880 (IGN)”, 6378249.2, 293.4660212936269],"
+
+                     "      TOWGS84[-168,-60,320,0,0,0,0]]," +
+                     "    PRIMEM[“Paris”, 2.5969213, AUTHORITY[“EPSG”, “8903”]],"
+  // In grads.
+                     "    UNIT[“grad”, 0.01570796326794897]]," +
+                     "  PROJECTION[“Lambert Conformal Conic (1SP)”]," +  // Intentional
swapping of "Conformal" and "Conic".
+                     "  PARAMETER[“latitude_of_origin”, 52.0]," +        // In grads.
+                     "  PARAMETER[“scale_factor”, 0.99987742]," +
+                     "  PARAMETER[“false_easting”, 600000]," +
+                     "  PARAMETER[“false_northing”, 2200000]," +
+                     "  UNIT[“metre”,1]]";
+
+        ProjectedCRS crs = parse(ProjectedCRS.class, wkt);
+        assertNameAndIdentifierEqual("NTF (Paris) / Lambert zone II", 0, crs);
+        verifyProjectedCS(crs.getCoordinateSystem());
+        PrimeMeridian pm = verifyNTF(crs.getDatum());
+        assertEquals("angularUnit", NonSI.GRADE, pm.getAngularUnit());
+        assertEquals("greenwichLongitude", 2.5969213, pm.getGreenwichLongitude(), STRICT);
+        ParameterValue<?> param = verifyNTF(crs.getConversionFromBase().getParameterValues());
+        assertEquals("angularUnit", NonSI.GRADE, param.getUnit());
+        assertEquals("latitude_of_origin",  52.0, param.doubleValue(), STRICT);
+        /*
+         * Parse again using Convention.WKT1_COMMON_UNITS and ignoring AXIS[…] elements.
+         * See the comment in testNonGreenwichMeridian for a discussion. The new aspect
+         * tested by this method is that the unit should be ignored for the parameters
+         * in addition to the prime meridian.
+         */
+        wkt = wkt.replace("2.5969213", "2.33722917");   // Convert unit in prime meridian.
+        wkt = wkt.replace("52.0", "46.8");              // Convert unit in “latitude_of_origin”
parameter.
+        setConvention(Convention.WKT1_COMMON_UNITS, true);
+        crs = parse(ProjectedCRS.class, wkt);
+        assertNameAndIdentifierEqual("NTF (Paris) / Lambert zone II", 0, crs);
+        verifyProjectedCS(crs.getCoordinateSystem());
+        pm = verifyNTF(crs.getDatum());
+        assertEquals("angularUnit", NonSI.DEGREE_ANGLE, pm.getAngularUnit());
+        assertEquals("greenwichLongitude", 2.33722917, pm.getGreenwichLongitude(), STRICT);
+        param = verifyNTF(crs.getConversionFromBase().getParameterValues());
+        assertEquals("angularUnit", NonSI.DEGREE_ANGLE, param.getUnit());
+        assertEquals("latitude_of_origin",  46.8, param.doubleValue(), STRICT);
+    }
+
+    /**
+     * Verifies the properties of a datum which is expected to be “Nouvelle Triangulation
Française (Paris)”.
+     * This is used by the methods in this class which test a CRS using less frequently used
units and prime
+     * meridian.
+     *
+     * @return The prime meridian, to be verified by the caller because the unit of measurement
depends on the test.
      */
     private static PrimeMeridian verifyNTF(final GeodeticDatum datum) {
         assertNameAndIdentifierEqual("Nouvelle Triangulation Française (Paris)", 0, datum);
@@ -362,6 +424,23 @@ public final strictfp class GeodeticObje
     }
 
     /**
+     * Verifies the parameter values for a projected CRS which is expected to be “NTF (Paris)
/ Lambert zone II”.
+     * This is used by the methods in this class which test a CRS using less frequently used
units and prime meridian.
+     *
+     * @return The latitude of origin, to be verified by the caller because the unit of measurement
depends on the test.
+     */
+    private static ParameterValue<?> verifyNTF(final ParameterValueGroup param) {
+        assertEquals("Lambert Conic Conformal (1SP)", param.getDescriptor().getName().getCode());
+        assertEquals("semi_major",     6378249.2, param.parameter("semi_major"      ).doubleValue(),
STRICT);
+        assertEquals("semi_minor",     6356515.0, param.parameter("semi_minor"      ).doubleValue(),
1E-12);
+        assertEquals("central_meridian",     0.0, param.parameter("central_meridian").doubleValue(),
STRICT);
+        assertEquals("scale_factor",  0.99987742, param.parameter("scale_factor"    ).doubleValue(),
STRICT);
+        assertEquals("false_easting",   600000.0, param.parameter("false_easting"   ).doubleValue(),
STRICT);
+        assertEquals("false_northing", 2200000.0, param.parameter("false_northing"  ).doubleValue(),
STRICT);
+        return param.parameter("latitude_of_origin");
+    }
+
+    /**
      * Tests the parsing of a compound CRS from a WKT 1 string, except the time dimension
which is WKT 2.
      *
      * @throws ParseException if the parsing failed.
@@ -463,4 +542,66 @@ public final strictfp class GeodeticObje
         assertEquals("minimumValue", -secondsIn90,         axis.getMinimumValue(), 1E-9);
         assertEquals("maximumValue", +secondsIn90,         axis.getMaximumValue(), 1E-9);
     }
+
+    /**
+     * Tests parsing a WKT with a missing Geographic CRS name.
+     * This should be considered invalid, but happen in practice.
+     *
+     * <p>The WKT tested in this method contains also some other oddities compared
to the usual WKT:</p>
+     * <ul>
+     *   <li>The prime meridian is declared in the {@code "central_meridian"} projection
parameter instead
+     *       than in the {@code PRIMEM[…]} element.</li>
+     *   <li>Some elements are not in the usual order.</li>
+     * </ul>
+     *
+     * @throws ParseException if the parsing failed.
+     */
+    @Test
+    @DependsOnMethod("testProjectedCRS")
+    public void testWithMissingName() throws ParseException {
+        final ProjectedCRS crs = parse(ProjectedCRS.class,
+                "PROJCS[“FRANCE/NTF/Lambert III”," +
+                "GEOGCS[“”," + // Missing name (the purpose of this test).
+                "DATUM[“NTF=GR3DF97A”,TOWGS84[-168, -60, 320, 0, 0, 0, 0] ," + // Intentionally
misplaced coma.
+                "SPHEROID[“Clarke 1880 (IGN)”,6378249.2,293.4660212936269]]," +
+                "PRIMEM[“Greenwich”,0],UNIT[“Degrees”,0.0174532925199433]," +
+                "AXIS[“Long”,East],AXIS[“Lat”,North]]," +
+                "PROJECTION[“Lambert_Conformal_Conic_1SP”]," +
+                "PARAMETER[“latitude_of_origin”,44.1]," +
+                "PARAMETER[“central_meridian”,2.33722917]," +   // Paris prime meridian.
+                "PARAMETER[“scale_factor”,0.999877499]," +
+                "PARAMETER[“false_easting”,600000]," +
+                "PARAMETER[“false_northing”,200000]," +
+                "UNIT[“Meter”,1]," +
+                "AXIS[“Easting”,East],AXIS[“Northing”,North]]");
+
+        assertNameAndIdentifierEqual("FRANCE/NTF/Lambert III", 0, crs);
+        verifyProjectedCS(crs.getCoordinateSystem());
+        final GeographicCRS geoCRS = crs.getBaseCRS();
+        assertNameAndIdentifierEqual("NTF=GR3DF97A", 0, geoCRS);    // Inherited the datum
name.
+
+        final GeodeticDatum datum = geoCRS.getDatum();
+        assertNameAndIdentifierEqual("NTF=GR3DF97A", 0, datum);
+        assertNameAndIdentifierEqual("Greenwich", 0, datum.getPrimeMeridian());
+
+        final Ellipsoid ellipsoid = datum.getEllipsoid();
+        assertNameAndIdentifierEqual("Clarke 1880 (IGN)", 0, ellipsoid);
+        assertEquals("semiMajor", 6378249.2, ellipsoid.getSemiMajorAxis(), STRICT);
+        assertEquals("inverseFlattening", 293.4660212936269, ellipsoid.getInverseFlattening(),
STRICT);
+
+        final EllipsoidalCS cs = geoCRS.getCoordinateSystem();
+        assertEquals("dimension", 2, cs.getDimension());
+        assertLongitudeAxisEquals(cs.getAxis(0));
+        assertLatitudeAxisEquals (cs.getAxis(1));
+
+        final ParameterValueGroup param = crs.getConversionFromBase().getParameterValues();
+        assertEquals("Lambert Conic Conformal (1SP)", param.getDescriptor().getName().getCode());
+        assertEquals("semi_major",        6378249.2, param.parameter("semi_major"       
).doubleValue(), STRICT);
+        assertEquals("semi_minor",        6356515.0, param.parameter("semi_minor"       
).doubleValue(), 1E-12);
+        assertEquals("latitude_of_origin",     44.1, param.parameter("latitude_of_origin").doubleValue(),
STRICT);
+        assertEquals("central_meridian", 2.33722917, param.parameter("central_meridian" 
).doubleValue(), STRICT);
+        assertEquals("scale_factor",    0.999877499, param.parameter("scale_factor"     
).doubleValue(), STRICT);
+        assertEquals("false_easting",      600000.0, param.parameter("false_easting"    
).doubleValue(), STRICT);
+        assertEquals("false_northing",     200000.0, param.parameter("false_northing"   
).doubleValue(), STRICT);
+    }
 }

Modified: sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/crs/DefaultGeographicCRSTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/crs/DefaultGeographicCRSTest.java?rev=1684220&r1=1684219&r2=1684220&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/crs/DefaultGeographicCRSTest.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/crs/DefaultGeographicCRSTest.java
[UTF-8] Mon Jun  8 16:52:42 2015
@@ -38,7 +38,7 @@ import static org.apache.sis.test.TestUt
  *
  * @author  Martin Desruisseaux (Geomatys)
  * @since   0.4
- * @version 0.5
+ * @version 0.6
  * @module
  */
 @DependsOn({
@@ -209,8 +209,8 @@ public final strictfp class DefaultGeogr
     /**
      * Tests WKT 2 formatting on a CRS using a prime meridian other than Greenwich.
      *
-     * <p>This CRS used in this test is equivalent to {@code EPSG:4807} except for
axis order and units
-     * of measurement, since EPSG defines (<var>latitude</var>, <var>longitude</var>)
in grades.</p>
+     * <p>This CRS used in this test is equivalent to {@code EPSG:4807} except for
axis order,
+     * since EPSG defines (<var>latitude</var>, <var>longitude</var>)
in grades.</p>
      */
     @Test
     @DependsOnMethod("testWKT2")
@@ -223,15 +223,14 @@ public final strictfp class DefaultGeogr
                 "  CS[“ellipsoidal”, 2],\n" +
                 "    Axis[“Longitude (L)”, east],\n" +                      // See method
javadoc.
                 "    Axis[“Latitude (B)”, north],\n" +
-                "    Unit[“degree”, 0.017453292519943295]]",                // See method
javadoc.
+                "    Unit[“grade”, 0.015707963267948967]]",
                 HardCodedCRS.NTF);
     }
 
     /**
      * Tests WKT 1 formatting using {@link Convention#WKT1_COMMON_UNITS}. That convention
ignores the unit of
      * measurement in {@code PRIMEM} element, and rather unconditionally interpret the angle
unit as degrees.
-     * In order to avoid ambiguity, SIS in {@code WKT1_COMMON_UNITS} mode should declare
explicitely that the
-     * units are degrees.
+     * This is a violation of OGC 01-009 and ISO 19162 standards, but is required for compatibility
with GDAL.
      */
     @Test
     @DependsOnMethod("testWKT2_ForNonGreenwich")
@@ -240,8 +239,8 @@ public final strictfp class DefaultGeogr
                 "GEOGCS[“NTF (Paris)”,\n" +
                 "  DATUM[“Nouvelle Triangulation Francaise”,\n" +   // Formatter should
replace "ç" by "c".
                 "    SPHEROID[“NTF”, 6378249.2, 293.4660212936269]],\n" +
-                "    PRIMEM[“Paris”, 2.33722917],\n" +
-                "  UNIT[“degree”, 0.017453292519943295],\n" +       // Formatter should
replace "grade" by "degree".
+                "    PRIMEM[“Paris”, 2.33722917],\n" +              // Would be 2.5969213
in standard-compliant WKT.
+                "  UNIT[“grade”, 0.015707963267948967],\n" +
                 "  AXIS[“Longitude”, EAST],\n" +
                 "  AXIS[“Latitude”, NORTH]]",
                 HardCodedCRS.NTF);

Modified: sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/crs/DefaultProjectedCRSTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/crs/DefaultProjectedCRSTest.java?rev=1684220&r1=1684219&r2=1684220&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/crs/DefaultProjectedCRSTest.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/crs/DefaultProjectedCRSTest.java
[UTF-8] Mon Jun  8 16:52:42 2015
@@ -22,6 +22,7 @@ import javax.measure.unit.Unit;
 import javax.xml.bind.JAXBException;
 import org.opengis.util.FactoryException;
 import org.opengis.referencing.crs.ProjectedCRS;
+import org.opengis.referencing.crs.GeographicCRS;
 import org.opengis.test.Validators;
 import org.apache.sis.referencing.cs.HardCodedCS;
 import org.apache.sis.referencing.GeodeticObjectBuilder;
@@ -55,11 +56,13 @@ public final strictfp class DefaultProje
     private static final String XML_FILE = "NTF.xml";
 
     /**
-     * Creates the "NTF (Paris) / Lambert zone II" CRS.
+     * Creates the "NTF (Paris) / Lambert zone II" CRS. The prime meridian is always in grades,
+     * but the axes can be in degrees or in grades depending if the {@code baseCRS} argument
is
+     * {@link HardCodedCRS.NTF_NORMALIZED_AXES} or {@link HardCodedCRS.NTF} respectively.
      *
      * @see HardCodedCRS#NTF
      */
-    private static ProjectedCRS create() throws FactoryException {
+    private static ProjectedCRS create(final GeographicCRS baseCRS) throws FactoryException
{
         return new GeodeticObjectBuilder()
                 .setConversionMethod("Lambert Conic Conformal (1SP)")
                 .setConversionName("Lambert zone II")
@@ -70,7 +73,7 @@ public final strictfp class DefaultProje
                 .setCodeSpace(Citations.EPSG, Constants.EPSG)
                 .addName("NTF (Paris) / Lambert zone II")
                 .addIdentifier("27572")
-                .createProjectedCRS(HardCodedCRS.NTF, HardCodedCS.PROJECTED);
+                .createProjectedCRS(baseCRS, HardCodedCS.PROJECTED);
     }
 
     /**
@@ -80,7 +83,40 @@ public final strictfp class DefaultProje
      */
     @Test
     public void testWKT1() throws FactoryException {
-        final ProjectedCRS crs = create();
+        final ProjectedCRS crs = create(HardCodedCRS.NTF);
+        assertWktEquals(Convention.WKT1,
+                "PROJCS[“NTF (Paris) / Lambert zone II”,\n" +
+                "  GEOGCS[“NTF (Paris)”,\n" +
+                "    DATUM[“Nouvelle Triangulation Francaise”,\n" +
+                "      SPHEROID[“NTF”, 6378249.2, 293.4660212936269]],\n" +
+                "      PRIMEM[“Paris”, 2.5969213],\n" +
+                "    UNIT[“grade”, 0.015707963267948967],\n" +
+                "    AXIS[“Longitude”, EAST],\n" +
+                "    AXIS[“Latitude”, NORTH]],\n" +
+                "  PROJECTION[“Lambert_Conformal_Conic_1SP”, AUTHORITY[“EPSG”, “9801”]],\n"
+
+                "  PARAMETER[“latitude_of_origin”, 52.0],\n" +
+                "  PARAMETER[“central_meridian”, 0.0],\n" +
+                "  PARAMETER[“scale_factor”, 0.99987742],\n" +
+                "  PARAMETER[“false_easting”, 600000.0],\n" +
+                "  PARAMETER[“false_northing”, 2200000.0],\n" +
+                "  UNIT[“metre”, 1],\n" +
+                "  AXIS[“Easting”, EAST],\n" +
+                "  AXIS[“Northing”, NORTH],\n" +
+                "  AUTHORITY[“EPSG”, “27572”]]",
+                crs);
+    }
+
+    /**
+     * Tests WKT 1 formatting with a somewhat convolved case where the units of the prime
meridian is not
+     * the same than the unit of axes. Since the axis units is what we write in the {@code
UNIT[…]} element,
+     * the WKT formatter need to convert the unit of prime meridian and all parameter angular
values.
+     *
+     * @throws FactoryException if the CRS creation failed.
+     */
+    @Test
+    @DependsOnMethod("testWKT1")
+    public void testWKT1_WithMixedUnits() throws FactoryException {
+        final ProjectedCRS crs = create(HardCodedCRS.NTF_NORMALIZED_AXES);
         Validators.validate(crs);   // Opportunist check.
         assertWktEquals(Convention.WKT1,
                 "PROJCS[“NTF (Paris) / Lambert zone II”,\n" +
@@ -105,14 +141,15 @@ public final strictfp class DefaultProje
     }
 
     /**
-     * Tests WKT 2 formatting.
+     * Tests WKT 2 formatting. Contrarily to the WKT 1 formatting, in this case it does not
matter
+     * if we mix the units of measurement because the unit is declared for each parameter
and axis.
      *
      * @throws FactoryException if the CRS creation failed.
      */
     @Test
     @DependsOnMethod("testWKT1")
     public void testWKT2() throws FactoryException {
-        final ProjectedCRS crs = create();
+        final ProjectedCRS crs = create(HardCodedCRS.NTF_NORMALIZED_AXES);
         assertWktEquals(Convention.WKT2,
                 "ProjectedCRS[“NTF (Paris) / Lambert zone II”,\n" +
                 "  BaseGeodCRS[“NTF (Paris)”,\n" +

Modified: sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/crs/HardCodedCRS.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/crs/HardCodedCRS.java?rev=1684220&r1=1684219&r2=1684220&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/crs/HardCodedCRS.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/crs/HardCodedCRS.java
[UTF-8] Mon Jun  8 16:52:42 2015
@@ -77,17 +77,33 @@ public final strictfp class HardCodedCRS
      * A two-dimensional geographic coordinate reference system using the Paris prime meridian.
      * This CRS uses (<var>longitude</var>, <var>latitude</var>)
ordinates with longitude values
      * increasing towards the East and latitude values increasing towards the North.
+     * The angular units for the prime meridian and the axes are grades.
+     *
+     * <p>This CRS is equivalent to {@code EPSG:4807} except for axis order, since
EPSG defines
+     * (<var>latitude</var>, <var>longitude</var>).</p>
+     *
+     * @since 0.6
+     */
+    public static final DefaultGeographicCRS NTF = new DefaultGeographicCRS(
+            Collections.singletonMap(DefaultGeographicCRS.NAME_KEY, "NTF (Paris)"),
+            HardCodedDatum.NTF, HardCodedCS.ELLIPSOIDAL_gon);
+
+    /**
+     * A two-dimensional geographic coordinate reference system using the Paris prime meridian.
+     * This CRS uses (<var>longitude</var>, <var>latitude</var>)
ordinates with longitude values
+     * increasing towards the East and latitude values increasing towards the North.
      * The angular units are decimal degrees except for the prime meridian (Paris),
      * which is measured in grades.
      *
      * <p>This CRS is equivalent to {@code EPSG:4807} except for axis order and units
of measurement,
      * since EPSG defines (<var>latitude</var>, <var>longitude</var>)
in grades. The main purpose of
-     * this CRS is to test operations between CRS having different prime meridian.</p>
+     * this CRS is to test the convolved case where the unit of prime meridian is different
than the
+     * axis units.</p>
      *
-     * @since 0.5
+     * @since 0.6
      */
-    public static final DefaultGeographicCRS NTF = new DefaultGeographicCRS(
-            Collections.singletonMap(DefaultGeographicCRS.NAME_KEY, "NTF (Paris)"),
+    public static final DefaultGeographicCRS NTF_NORMALIZED_AXES = new DefaultGeographicCRS(
+            Collections.singletonMap(DefaultGeographicCRS.NAME_KEY, NTF.getName()),
             HardCodedDatum.NTF, HardCodedCS.GEODETIC_2D);
 
     /**

Modified: sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/cs/HardCodedAxes.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/cs/HardCodedAxes.java?rev=1684220&r1=1684219&r2=1684220&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/cs/HardCodedAxes.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/cs/HardCodedAxes.java
[UTF-8] Mon Jun  8 16:52:42 2015
@@ -73,7 +73,7 @@ public final strictfp class HardCodedAxe
 
     /**
      * Axis for longitudes in gradian units.
-     * The axis name is {@code "Longitude"} (the {@code "Geodetic" } prefix is omitted for
testing purpose).
+     * The axis name is {@code "Longitude"} (the {@code "Geodetic"} prefix is omitted for
testing purpose).
      * Increasing ordinates values go {@linkplain AxisDirection#EAST East} and units are
{@link NonSI#GRADE}.
      * The abbreviation is "λ" (lambda). The unit symbol is "gon".
      *
@@ -85,7 +85,7 @@ public final strictfp class HardCodedAxe
 
     /**
      * Axis for latitudes in gradian units.
-     * The axis name is {@code "Latitude"} (the {@code "Geodetic" } prefix is omitted for
testing purpose).
+     * The axis name is {@code "Latitude"} (the {@code "Geodetic"} prefix is omitted for
testing purpose).
      * Increasing ordinates values go {@linkplain AxisDirection#NORTH North} and units are
{@link NonSI#GRADE}.
      * The abbreviation is "φ" (phi). The unit symbol is "gon".
      *

Modified: sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/cs/HardCodedCS.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/cs/HardCodedCS.java?rev=1684220&r1=1684219&r2=1684220&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/cs/HardCodedCS.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/cs/HardCodedCS.java
[UTF-8] Mon Jun  8 16:52:42 2015
@@ -75,6 +75,8 @@ public final strictfp class HardCodedCS
      * <var>{@linkplain HardCodedAxes#LONGITUDE_gon longitude}</var>,
      * <var>{@linkplain HardCodedAxes#LATITUDE_gon latitude}</var>
      * axes (without "Geodetic" prefix) in gradians.
+     *
+     * <p>This coordinate system is used for testing unit conversions without axes
swapping.</p>
      */
     public static final DefaultEllipsoidalCS ELLIPSOIDAL_gon = new DefaultEllipsoidalCS(
             singletonMap(NAME_KEY, "Ellipsoidal (gon)"),

Modified: sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/DefaultConversionTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/DefaultConversionTest.java?rev=1684220&r1=1684219&r2=1684220&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/DefaultConversionTest.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/DefaultConversionTest.java
[UTF-8] Mon Jun  8 16:52:42 2015
@@ -114,7 +114,7 @@ public final strictfp class DefaultConve
      * @return A pseudo-conversion performing a longitude rotation.
      */
     public static DefaultConversion createLongitudeRotation(final boolean useGreenwich) {
-        return createLongitudeRotation(HardCodedCRS.NTF,
+        return createLongitudeRotation(HardCodedCRS.NTF_NORMALIZED_AXES,
                 createParisCRS(false, HardCodedCS.GEODETIC_2D, useGreenwich), null);
     }
 
@@ -303,7 +303,7 @@ public final strictfp class DefaultConve
     @Test
     @DependsOnMethod("testDefiningConversion")
     public void testWithInterpolationCRS() throws FactoryException {
-        DefaultConversion op = createLongitudeRotation(HardCodedCRS.NTF,
+        DefaultConversion op = createLongitudeRotation(HardCodedCRS.NTF_NORMALIZED_AXES,
                 createParisCRS(false, HardCodedCS.GEODETIC_2D, true), HardCodedCRS.TIME);
         assertMatrixEquals("Longitude rotation of a time-varying CRS", new Matrix4(
                 1, 0, 0, 0,
@@ -334,7 +334,7 @@ public final strictfp class DefaultConve
         final MathTransformFactory factory = DefaultFactories.forBuildin(MathTransformFactory.class);
         final DefaultConversion op = createLongitudeRotation(true);
         try {
-            op.specialize(Conversion.class, HardCodedCRS.WGS84, HardCodedCRS.NTF, factory);
+            op.specialize(Conversion.class, HardCodedCRS.WGS84, HardCodedCRS.NTF_NORMALIZED_AXES,
factory);
             fail("Should not have accepted to change the geodetic datum.");
         } catch (IllegalArgumentException e) {
             final String message = e.getMessage();
@@ -342,7 +342,7 @@ public final strictfp class DefaultConve
             assertTrue(message, message.contains("Nouvelle Triangulation Française"));
         }
         try {
-            op.specialize(Conversion.class, HardCodedCRS.NTF, HardCodedCRS.WGS84, factory);
+            op.specialize(Conversion.class, HardCodedCRS.NTF_NORMALIZED_AXES, HardCodedCRS.WGS84,
factory);
             fail("Should not have accepted to change the geodetic datum.");
         } catch (IllegalArgumentException e) {
             final String message = e.getMessage();



Mime
View raw message