sis-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From desruisse...@apache.org
Subject svn commit: r1737683 - in /sis/branches/JDK8/core/sis-referencing/src: main/java/org/apache/sis/referencing/operation/ test/java/org/apache/sis/referencing/crs/ test/java/org/apache/sis/referencing/operation/
Date Mon, 04 Apr 2016 13:02:13 GMT
Author: desruisseaux
Date: Mon Apr  4 13:02:13 2016
New Revision: 1737683

URL: http://svn.apache.org/viewvc?rev=1737683&view=rev
Log:
Tune pseudo-WKT formatting for ConcatenatedOperation.

Modified:
    sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/AbstractCoordinateOperation.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/operation/DefaultConcatenatedOperationTest.java
    sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/DefaultConversionTest.java
    sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/DefaultTransformationTest.java

Modified: sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/AbstractCoordinateOperation.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/AbstractCoordinateOperation.java?rev=1737683&r1=1737682&r2=1737683&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/AbstractCoordinateOperation.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/AbstractCoordinateOperation.java
[UTF-8] Mon Apr  4 13:02:13 2016
@@ -860,13 +860,18 @@ check:      for (int isTarget=0; ; isTar
         super.formatTo(formatter);
         formatter.newLine();
         /*
-         * If the WKT is a component of a ConcatenatedOperation, do not format the source
and target CRS.
-         * This decision SIS-specific since the WKT 2 specification does not define concatenated
operations.
-         * The choice of content to omit may change in any future version.
+         * If the WKT is a component of a ConcatenatedOperation, do not format the source
CRS since it is identical
+         * to the target CRS of the previous step, or to the source CRS of the enclosing
"ConcatenatedOperation" if
+         * this step is the first step.
+         *
+         * This decision is SIS-specific since the WKT 2 specification does not define concatenated
operations.
+         * This choice may change in any future SIS version.
          */
         final boolean isComponent = (formatter.getEnclosingElement(1) instanceof ConcatenatedOperation);
         if (!isComponent) {
             append(formatter, getSourceCRS(), WKTKeywords.SourceCRS);
+        }
+        if (!(this instanceof ConcatenatedOperation)) {
             append(formatter, getTargetCRS(), WKTKeywords.TargetCRS);
         }
         final OperationMethod method = getMethod();
@@ -904,7 +909,7 @@ check:      for (int isTarget=0; ; isTar
         if (formatter.getConvention().majorVersion() == 1) {
             formatter.setInvalidWKT(this, null);
         }
-        return WKTKeywords.CoordinateOperation;
+        return isComponent ? "CoordinateOperationStep" : WKTKeywords.CoordinateOperation;
     }
 
     /**

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=1737683&r1=1737682&r2=1737683&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 Apr  4 13:02:13 2016
@@ -36,7 +36,7 @@ import static org.apache.sis.referencing
  *
  * @author  Martin Desruisseaux (Geomatys)
  * @since   0.4
- * @version 0.5
+ * @version 0.7
  * @module
  */
 public final strictfp class HardCodedCRS {
@@ -109,6 +109,38 @@ public final strictfp class HardCodedCRS
             HardCodedDatum.NTF, HardCodedCS.GEODETIC_2D);
 
     /**
+     * A three-dimensional geographic coordinate reference system using the Tokyo datum.
+     * This CRS uses (<var>longitude</var>, <var>latitude</var>,
<var>height</var>) ordinates
+     * with longitude values increasing towards the East, latitude values increasing towards
+     * the North and ellipsoidal eight increasing toward up.
+     * The angular units are decimal degrees and the linear units are metres.
+     *
+     * <p>This CRS is equivalent to {@code EPSG:4301} except for axis order and the
addition
+     * of ellipsoidal height.</p>
+     *
+     * @since 0.7
+     */
+    public static final DefaultGeographicCRS TOKYO = new DefaultGeographicCRS(
+            Collections.singletonMap(DefaultGeographicCRS.NAME_KEY, "Tokyo"),
+            HardCodedDatum.TOKYO, HardCodedCS.GEODETIC_3D);
+
+    /**
+     * A two-dimensional geographic coordinate reference system using the JGD2000 datum.
+     * This CRS uses (<var>longitude</var>, <var>latitude</var>,
<var>height</var>) ordinates
+     * with longitude values increasing towards the East, latitude values increasing towards
+     * the North and ellipsoidal eight increasing toward up.
+     * The angular units are decimal degrees and the linear units are metres.
+     *
+     * <p>This CRS is equivalent to {@code EPSG:4612} except for axis order and the
addition
+     * of ellipsoidal height.</p>
+     *
+     * @since 0.7
+     */
+    public static final DefaultGeographicCRS JGD2000 = new DefaultGeographicCRS(
+            Collections.singletonMap(DefaultGeographicCRS.NAME_KEY, "JGD2000"),
+            HardCodedDatum.JGD2000, HardCodedCS.GEODETIC_3D);
+
+    /**
      * A two-dimensional geographic coordinate reference system using a spherical datum.
      * This CRS uses (<var>longitude</var>, <var>latitude</var>)
ordinates with longitude values
      * increasing towards the East and latitude values increasing towards the North.

Modified: sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/DefaultConcatenatedOperationTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/DefaultConcatenatedOperationTest.java?rev=1737683&r1=1737682&r2=1737683&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/DefaultConcatenatedOperationTest.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/DefaultConcatenatedOperationTest.java
[UTF-8] Mon Apr  4 13:02:13 2016
@@ -16,16 +16,26 @@
  */
 package org.apache.sis.referencing.operation;
 
+import java.util.Collections;
 import javax.xml.bind.JAXBException;
+import org.opengis.util.FactoryException;
 import org.opengis.referencing.crs.GeodeticCRS;
 import org.opengis.referencing.crs.CoordinateReferenceSystem;
 import org.opengis.referencing.operation.CoordinateOperation;
+import org.opengis.referencing.operation.MathTransformFactory;
+import org.opengis.referencing.operation.NoninvertibleTransformException;
+import org.apache.sis.referencing.operation.transform.EllipsoidToCentricTransform;
+import org.apache.sis.referencing.datum.HardCodedDatum;
+import org.apache.sis.referencing.crs.HardCodedCRS;
+import org.apache.sis.internal.system.DefaultFactories;
+import org.apache.sis.io.wkt.Convention;
+
 import org.opengis.test.Validators;
 import org.apache.sis.test.DependsOn;
 import org.apache.sis.test.XMLTestCase;
 import org.junit.Test;
 
-import static org.opengis.test.Assert.*;
+import static org.apache.sis.test.MetadataAssert.*;
 import static org.apache.sis.test.TestUtilities.getSingleton;
 
 
@@ -48,9 +58,96 @@ public final strictfp class DefaultConca
     private static final String XML_FILE = "ConcatenatedOperation.xml";
 
     /**
+     * Creates a “Tokyo to JGD2000” transformation.
+     *
+     * @see DefaultTransformationTest#createGeocentricTranslation()
+     */
+    private static DefaultConcatenatedOperation createGeocentricTranslation() throws FactoryException,
NoninvertibleTransformException {
+        final MathTransformFactory mtFactory = DefaultFactories.forBuildin(MathTransformFactory.class);
+        final DefaultTransformation op = DefaultTransformationTest.createGeocentricTranslation();
+
+        final DefaultConversion before = new DefaultConversion(
+                Collections.singletonMap(DefaultConversion.NAME_KEY, "Geographic to geocentric"),
+                HardCodedCRS.TOKYO,             // SourceCRS
+                op.getSourceCRS(),              // TargetCRS
+                null,                           // InterpolationCRS
+                DefaultOperationMethodTest.create("Geographic/geocentric conversions", "9602",
"EPSG guidance note #7-2", 3),
+                EllipsoidToCentricTransform.createGeodeticConversion(mtFactory, HardCodedDatum.TOKYO.getEllipsoid(),
true));
+
+        final DefaultConversion after = new DefaultConversion(
+                Collections.singletonMap(DefaultConversion.NAME_KEY, "Geocentric to geographic"),
+                op.getTargetCRS(),              // SourceCRS
+                HardCodedCRS.JGD2000,           // TargetCRS
+                null,                           // InterpolationCRS
+                DefaultOperationMethodTest.create("Geographic/geocentric conversions", "9602",
"EPSG guidance note #7-2", 3),
+                EllipsoidToCentricTransform.createGeodeticConversion(mtFactory, HardCodedDatum.JGD2000.getEllipsoid(),
true).inverse());
+
+        return new DefaultConcatenatedOperation(
+                Collections.singletonMap(DefaultConversion.NAME_KEY, "Tokyo to JGD2000"),
+                new AbstractSingleOperation[] {before, op, after}, mtFactory);
+    }
+
+    /**
+     * Tests WKT formatting. The WKT format used here is not defined in OGC/ISO standards;
+     * this is a SIS-specific extension.
+     *
+     * @throws FactoryException if an error occurred while creating the test operation.
+     * @throws NoninvertibleTransformException if an error occurred while creating the test
operation.
+     */
+    @Test
+    public void testWKT() throws FactoryException, NoninvertibleTransformException {
+        final DefaultConcatenatedOperation op = createGeocentricTranslation();
+        assertWktEquals(Convention.WKT2_SIMPLIFIED,                             // Pseudo-WKT
actually.
+                "ConcatenatedOperation[“Tokyo to JGD2000”,\n" +
+                "  SourceCRS[GeodeticCRS[“Tokyo”,\n" +
+                "    Datum[“Tokyo 1918”,\n" +
+                "      Ellipsoid[“Bessel 1841”, 6377397.155, 299.1528128]],\n" +
+                "    CS[ellipsoidal, 3],\n" +
+                "      Axis[“Longitude (L)”, east, Unit[“degree”, 0.017453292519943295]],\n"
+
+                "      Axis[“Latitude (B)”, north, Unit[“degree”, 0.017453292519943295]],\n"
+
+                "      Axis[“Ellipsoidal height (h)”, up, Unit[“metre”, 1]]]],\n"
+
+                "  CoordinateOperationStep[“Geographic to geocentric”,\n" +
+                "    TargetCRS[GeodeticCRS[“Tokyo 1918”,\n" +
+                "      Datum[“Tokyo 1918”,\n" +
+                "        Ellipsoid[“Bessel 1841”, 6377397.155, 299.1528128]],\n" +
+                "      CS[Cartesian, 3],\n" +
+                "        Axis[“(X)”, geocentricX],\n" +
+                "        Axis[“(Y)”, geocentricY],\n" +
+                "        Axis[“(Z)”, geocentricZ],\n" +
+                "        Unit[“metre”, 1]]],\n" +
+                "    Method[“Geographic/geocentric conversions”],\n" +
+                "      Parameter[“semi_major”, 6377397.155, Unit[“metre”, 1]],\n"
+
+                "      Parameter[“semi_minor”, 6356078.962818189, Unit[“metre”, 1]]],\n"
+
+                "  CoordinateOperationStep[“Tokyo to JGD2000 (GSI)”,\n" +
+                "    TargetCRS[GeodeticCRS[“JGD2000”,\n" +
+                "      Datum[“Japanese Geodetic Datum 2000”,\n" +
+                "        Ellipsoid[“GRS 1980”, 6378137.0, 298.257222101]],\n" +
+                "      CS[Cartesian, 3],\n" +
+                "        Axis[“(X)”, geocentricX],\n" +
+                "        Axis[“(Y)”, geocentricY],\n" +
+                "        Axis[“(Z)”, geocentricZ],\n" +
+                "        Unit[“metre”, 1]]],\n" +
+                "    Method[“Geocentric translations”],\n" +
+                "      Parameter[“X-axis translation”, -146.414],\n" +
+                "      Parameter[“Y-axis translation”, 507.337],\n" +
+                "      Parameter[“Z-axis translation”, 680.507]],\n" +
+                "  CoordinateOperationStep[“Geocentric to geographic”,\n" +
+                "    TargetCRS[GeodeticCRS[“JGD2000”,\n" +
+                "      Datum[“Japanese Geodetic Datum 2000”,\n" +
+                "        Ellipsoid[“GRS 1980”, 6378137.0, 298.257222101]],\n" +
+                "      CS[ellipsoidal, 3],\n" +
+                "        Axis[“Longitude (L)”, east, Unit[“degree”, 0.017453292519943295]],\n"
+
+                "        Axis[“Latitude (B)”, north, Unit[“degree”, 0.017453292519943295]],\n"
+
+                "        Axis[“Ellipsoidal height (h)”, up, Unit[“metre”, 1]]]],\n"
+
+                "    Method[“Geographic/geocentric conversions”],\n" +
+                "      Parameter[“semi_major”, 6378137.0, Unit[“metre”, 1]],\n" +
+                "      Parameter[“semi_minor”, 6356752.314140356, Unit[“metre”, 1]]]]",
op);
+    }
+
+    /**
      * Tests (un)marshalling of a concatenated operation.
      *
-     * @throws JAXBException If an error occurred during (un)marshalling.
+     * @throws JAXBException if an error occurred during (un)marshalling.
      */
     @Test
     public void testXML() throws JAXBException {

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=1737683&r1=1737682&r2=1737683&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 Apr  4 13:02:13 2016
@@ -23,6 +23,7 @@ import org.opengis.util.FactoryException
 import org.opengis.parameter.ParameterValue;
 import org.opengis.parameter.ParameterValueGroup;
 import org.opengis.referencing.crs.CoordinateReferenceSystem;
+import org.opengis.referencing.crs.GeodeticCRS;
 import org.opengis.referencing.crs.GeographicCRS;
 import org.opengis.referencing.crs.TemporalCRS;
 import org.opengis.referencing.cs.EllipsoidalCS;
@@ -96,7 +97,7 @@ public final strictfp class DefaultConve
      */
     private static GeographicCRS changeCS(final CoordinateReferenceSystem crs, final EllipsoidalCS
cs) {
         return new DefaultGeographicCRS(Collections.singletonMap(DefaultGeographicCRS.NAME_KEY,
-                crs.getName()), ((GeographicCRS) crs).getDatum(), cs);
+                crs.getName()), ((GeodeticCRS) crs).getDatum(), cs);
     }
 
     /**
@@ -167,6 +168,7 @@ public final strictfp class DefaultConve
      * Asserts that at least some of the properties of the given {@code op} instance have
the expected values
      * for an instance created by {@link #createLongitudeRotation(GeographicCRS, GeographicCRS)}.
      */
+    @SuppressWarnings("SuspiciousToArrayCall")
     private static void verifyProperties(final DefaultConversion op, final boolean swapSourceAxes)
{
         assertEquals("name",       "Paris to Greenwich", op.getName().getCode());
         assertEquals("sourceCRS",  "NTF (Paris)",        op.getSourceCRS().getName().getCode());

Modified: sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/DefaultTransformationTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/DefaultTransformationTest.java?rev=1737683&r1=1737682&r2=1737683&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/DefaultTransformationTest.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/DefaultTransformationTest.java
[UTF-8] Mon Apr  4 13:02:13 2016
@@ -69,7 +69,7 @@ public final strictfp class DefaultTrans
     /**
      * Creates a “Tokyo to JGD2000 (GSI)” transformation.
      */
-    private static DefaultTransformation createGeocentricTranslation() {
+    static DefaultTransformation createGeocentricTranslation() {
         /*
          * The following code fills the parameter values AND creates itself the MathTransform
instance
          * (indirectly, through the matrix). The later step is normally not our business,
since we are
@@ -108,6 +108,7 @@ public final strictfp class DefaultTrans
      * Asserts that at least some of the properties of the given {@code op} instance have
the expected values
      * for an instance created by {@link #createGeocentricTranslation()}.
      */
+    @SuppressWarnings("SuspiciousToArrayCall")
     private static void verifyProperties(final DefaultTransformation op) {
         assertEquals("name",       "Tokyo to JGD2000 (GSI)",  op.getName().getCode());
         assertEquals("sourceCRS",  "Tokyo 1918",              op.getSourceCRS().getName().getCode());



Mime
View raw message