sis-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From desruisse...@apache.org
Subject svn commit: r1679644 - in /sis/branches/JDK7: ./ core/sis-metadata/src/test/java/org/apache/sis/internal/metadata/ core/sis-referencing/src/main/java/org/apache/sis/referencing/crs/ core/sis-referencing/src/main/java/org/apache/sis/referencing/operatio...
Date Fri, 15 May 2015 20:53:27 GMT
Author: desruisseaux
Date: Fri May 15 20:53:26 2015
New Revision: 1679644

URL: http://svn.apache.org/r1679644
Log:
Merge from the JDK8 branch a relaxation on the requirement that source/target CRS use the
same datum.

Modified:
    sis/branches/JDK7/   (props changed)
    sis/branches/JDK7/core/sis-metadata/src/test/java/org/apache/sis/internal/metadata/WKTKeywordsTest.java
    sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/crs/DefaultDerivedCRS.java
    sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/DefaultConversion.java
    sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/MismatchedDatumException.java
    sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/crs/DefaultDerivedCRSTest.java
    sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/DefaultConversionTest.java

Propchange: sis/branches/JDK7/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Fri May 15 20:53:26 2015
@@ -1,4 +1,4 @@
 /sis/branches/Android:1430670-1480699
 /sis/branches/JDK6:1394913-1508480
-/sis/branches/JDK8:1584960-1679629
+/sis/branches/JDK8:1584960-1679643
 /sis/trunk:1394364-1508466,1519089-1519674

Modified: sis/branches/JDK7/core/sis-metadata/src/test/java/org/apache/sis/internal/metadata/WKTKeywordsTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-metadata/src/test/java/org/apache/sis/internal/metadata/WKTKeywordsTest.java?rev=1679644&r1=1679643&r2=1679644&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-metadata/src/test/java/org/apache/sis/internal/metadata/WKTKeywordsTest.java
[UTF-8] (original)
+++ sis/branches/JDK7/core/sis-metadata/src/test/java/org/apache/sis/internal/metadata/WKTKeywordsTest.java
[UTF-8] Fri May 15 20:53:26 2015
@@ -37,6 +37,10 @@ public final strictfp class WKTKeywordsT
      * Ensures that all constants are equal to the name of the field that declare it.
      * The intend is to avoid misleading constant names when reading code.
      *
+     * <p>This test is not strictly necessary. We are just checking an arbitrary convention
here, not a requirement.
+     * If a developer change the constant values without changing the constant names (for
example in order to use the
+     * abridged WKT 2 keyword names instead that their long name), this is okay — just
ignore this test.</p>
+     *
      * @throws ReflectiveOperationException should never happen.
      */
     @Test

Modified: sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/crs/DefaultDerivedCRS.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/crs/DefaultDerivedCRS.java?rev=1679644&r1=1679643&r2=1679644&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/crs/DefaultDerivedCRS.java
[UTF-8] (original)
+++ sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/crs/DefaultDerivedCRS.java
[UTF-8] Fri May 15 20:53:26 2015
@@ -209,7 +209,8 @@ public class DefaultDerivedCRS extends A
             throws MismatchedDimensionException
     {
         if (baseCRS != null && derivedCS != null) {
-            switch (getType(baseCRS, derivedCS)) {
+            final String type = getType(baseCRS, derivedCS);
+            if (type != null) switch (type) {
                 case WKTKeywords.GeodeticCRS:    return new Geodetic   (properties, (GeodeticCRS)
baseCRS, conversion, (EllipsoidalCS) derivedCS);
                 case WKTKeywords.VerticalCRS:    return new Vertical   (properties, (VerticalCRS)
baseCRS, conversion,    (VerticalCS) derivedCS);
                 case WKTKeywords.TimeCRS:        return new Temporal   (properties, (TemporalCRS)
baseCRS, conversion,        (TimeCS) derivedCS);
@@ -233,13 +234,14 @@ public class DefaultDerivedCRS extends A
         if (object == null || object instanceof DefaultDerivedCRS) {
             return (DefaultDerivedCRS) object;
         } else {
-            switch (getType(object.getBaseCRS(), object.getCoordinateSystem())) {
+            final String type = getType(object.getBaseCRS(), object.getCoordinateSystem());
+            if (type != null) switch (type) {
                 case WKTKeywords.GeodeticCRS:    return new Geodetic   (object);
                 case WKTKeywords.VerticalCRS:    return new Vertical   (object);
                 case WKTKeywords.TimeCRS:        return new Temporal   (object);
                 case WKTKeywords.EngineeringCRS: return new Engineering(object);
-                default: return new DefaultDerivedCRS(object);
             }
+            return new DefaultDerivedCRS(object);
         }
     }
 

Modified: sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/DefaultConversion.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/DefaultConversion.java?rev=1679644&r1=1679643&r2=1679644&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/DefaultConversion.java
[UTF-8] (original)
+++ sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/DefaultConversion.java
[UTF-8] Fri May 15 20:53:26 2015
@@ -132,6 +132,27 @@ public class DefaultConversion extends A
      *   </tr>
      * </table>
      *
+     * <div class="section">Relationship between datum</div>
+     * By definition, coordinate <b>conversions</b> do not change the datum.
Consequently the given {@code sourceCRS}
+     * and {@code targetCRS} should use the same datum. If the datum is not the same, then
the coordinate operation
+     * should probably be a {@linkplain DefaultTransformation transformation} instead.
+     * However Apache SIS does not enforce that condition, but we encourage users to follow
it.
+     * The reason why SIS is tolerant is because some gray areas may exist about whether
an operation
+     * should be considered as a conversion or a transformation.
+     *
+     * <div class="note"><b>Example:</b>
+     * converting time instants from a {@linkplain org.apache.sis.referencing.crs.DefaultTemporalCRS
temporal CRS} using
+     * the <cite>January 1st, 1950</cite> epoch to another temporal CRS using
the <cite>January 1st, 1970</cite> epoch
+     * is a datum change, since the epoch is part of {@linkplain org.apache.sis.referencing.datum.DefaultTemporalDatum
+     * temporal datum} definition. However such operation does not have all the accuracy
issues of transformations
+     * between geodetic datum (empirically determined, over-determined systems, stochastic
nature of the parameters).
+     * Consequently some users may consider sufficient to represent temporal epoch changes
as conversions instead
+     * than transformations.</div>
+     *
+     * Note that while Apache SIS accepts to construct {@code DefaultConversion} instances
+     * with different source and target datum, it does not accept to use such instances for
+     * {@linkplain org.apache.sis.referencing.crs.DefaultDerivedCRS derived CRS} construction.
+     *
      * @param properties The properties to be given to the identified object.
      * @param sourceCRS  The source CRS.
      * @param targetCRS  The target CRS, which shall use a datum
@@ -139,7 +160,6 @@ public class DefaultConversion extends A
      * @param interpolationCRS The CRS of additional coordinates needed for the operation,
or {@code null} if none.
      * @param method     The coordinate operation method (mandatory in all cases).
      * @param transform  Transform from positions in the source CRS to positions in the target
CRS.
-     * @throws MismatchedDatumException if the source and target CRS use different datum.
      */
     public DefaultConversion(final Map<String,?>             properties,
                              final CoordinateReferenceSystem sourceCRS,
@@ -151,7 +171,6 @@ public class DefaultConversion extends A
         super(properties, sourceCRS, targetCRS, interpolationCRS, method, transform);
         ArgumentChecks.ensureNonNull("sourceCRS", sourceCRS);
         ArgumentChecks.ensureNonNull("targetCRS", targetCRS);
-        ensureCompatibleDatum("targetCRS", sourceCRS, targetCRS);
     }
 
     /**

Modified: sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/MismatchedDatumException.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/MismatchedDatumException.java?rev=1679644&r1=1679643&r2=1679644&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/MismatchedDatumException.java
[UTF-8] (original)
+++ sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/MismatchedDatumException.java
[UTF-8] Fri May 15 20:53:26 2015
@@ -22,6 +22,17 @@ package org.apache.sis.referencing.opera
  * By definition, conversions do not perform any change of datum
  * while {@linkplain DefaultTransformation transformations} can do.
  *
+ * <div class="note"><b>Note:</b>
+ * SIS is tolerant about different datum at {@code DefaultConversion} construction time,
+ * for the reasons explained in {@linkplain DefaultConversion#DefaultConversion(java.util.Map,
+ * org.opengis.referencing.crs.CoordinateReferenceSystem,
+ * org.opengis.referencing.crs.CoordinateReferenceSystem,
+ * org.opengis.referencing.crs.CoordinateReferenceSystem,
+ * org.opengis.referencing.operation.OperationMethod,
+ * org.opengis.referencing.operation.MathTransform) its constructor}.
+ * However SIS is stricter at {@linkplain org.apache.sis.referencing.crs.DefaultDerivedCRS
Derived CRS}
+ * construction time.</div>
+ *
  * @author  Martin Desruisseaux (Geomatys)
  * @since   0.6
  * @version 0.6

Modified: sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/crs/DefaultDerivedCRSTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/crs/DefaultDerivedCRSTest.java?rev=1679644&r1=1679643&r2=1679644&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/crs/DefaultDerivedCRSTest.java
[UTF-8] (original)
+++ sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/crs/DefaultDerivedCRSTest.java
[UTF-8] Fri May 15 20:53:26 2015
@@ -95,7 +95,7 @@ public final strictfp class DefaultDeriv
      * Its purpose is only to perform easy tests.
      */
     private static DefaultDerivedCRS createLongitudeRotation() {
-        final DefaultConversion conversion = DefaultConversionTest.createLongitudeRotation();
+        final DefaultConversion conversion = DefaultConversionTest.createLongitudeRotation(false);
         return new DefaultDerivedCRS(Collections.singletonMap(DefaultDerivedCRS.NAME_KEY,
conversion.getTargetCRS().getName()),
                 (SingleCRS) conversion.getSourceCRS(), conversion, HardCodedCS.GEODETIC_φλ);
     }

Modified: sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/DefaultConversionTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/DefaultConversionTest.java?rev=1679644&r1=1679643&r2=1679644&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/DefaultConversionTest.java
[UTF-8] (original)
+++ sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/DefaultConversionTest.java
[UTF-8] Fri May 15 20:53:26 2015
@@ -38,6 +38,7 @@ import org.apache.sis.referencing.datum.
 import org.apache.sis.referencing.cs.HardCodedCS;
 import org.apache.sis.referencing.crs.HardCodedCRS;
 import org.apache.sis.referencing.crs.DefaultGeographicCRS;
+import org.apache.sis.referencing.datum.DefaultGeodeticDatum;
 import org.apache.sis.referencing.operation.matrix.Matrix3;
 import org.apache.sis.referencing.operation.matrix.Matrix4;
 import org.apache.sis.referencing.operation.matrix.Matrices;
@@ -70,16 +71,24 @@ public final strictfp class DefaultConve
     private static final double OFFSET = 2.33722917;
 
     /**
-     * Creates a CRS using the same datum than the "Nouvelle Triangulation Française (Paris)"
datum (EPSG:6807).
+     * Creates a CRS using the same ellipsoid than the "Nouvelle Triangulation Française
(Paris)" datum (EPSG:6807),
+     * but with the prime meridian optionally set to Greenwich. Such CRS is not in real usage,
but this is convenient
+     * for testing a conversion consisting of only a longitude rotation, which is a very
simple operation easy to test.
      *
      * @param isSource {@code true} if creating the source CRS, or {@code false} if creating
the target CRS.
      * @param cs {@link HardCodedCS#GEODETIC_2D}, {@link HardCodedCS#GEODETIC_φλ} or other
compatible coordinate system.
+     * @param useGreenwich {@code true} for using Greenwich prime meridian, or {@code false}
for staying on the Paris one.
      *
      * @see HardCodedCRS#NTF
      */
-    private static GeographicCRS createParisCRS(final boolean isSource, final EllipsoidalCS
cs) {
+    private static GeographicCRS createParisCRS(final boolean isSource, final EllipsoidalCS
cs, final boolean useGreenwich) {
+        DefaultGeodeticDatum datum = HardCodedDatum.NTF;
+        if (useGreenwich) {
+            datum = new DefaultGeodeticDatum(Collections.singletonMap(DefaultGeodeticDatum.NAME_KEY,
datum.getName()),
+                    datum.getEllipsoid(), HardCodedDatum.GREENWICH);
+        }
         return new DefaultGeographicCRS(Collections.singletonMap(GeographicCRS.NAME_KEY,
-                isSource ? HardCodedCRS.NTF.getName() : "Back to Greenwich"), HardCodedDatum.NTF,
cs);
+                isSource ? HardCodedCRS.NTF.getName() : "Back to Greenwich"), datum, cs);
     }
 
     /**
@@ -100,10 +109,13 @@ public final strictfp class DefaultConve
      * change the prime meridian). However we handle them as conversions for testing purpose
only, because the
      * longitude rotation is a very simple operation easy to test.</p>
      *
+     * @param  useGreenwich {@code true} for using Greenwich prime meridian in the {@code
targetCRS},
+     *         or {@code false} for staying on the Paris one.
      * @return A pseudo-conversion performing a longitude rotation.
      */
-    public static DefaultConversion createLongitudeRotation() {
-        return createLongitudeRotation(HardCodedCRS.NTF, createParisCRS(false, HardCodedCS.GEODETIC_2D),
null);
+    public static DefaultConversion createLongitudeRotation(final boolean useGreenwich) {
+        return createLongitudeRotation(HardCodedCRS.NTF,
+                createParisCRS(false, HardCodedCS.GEODETIC_2D, useGreenwich), null);
     }
 
     /**
@@ -184,7 +196,17 @@ public final strictfp class DefaultConve
      */
     @Test
     public void testConstruction() {
-        verifyProperties(createLongitudeRotation(), false);
+        /*
+         * Test construction of a valid conversion.
+         * This conversion use the same datum for the source and target CRS.
+         */
+        verifyProperties(createLongitudeRotation(false), false);
+        /*
+         * Test a conversion with a source and target CRS using different datum.
+         * This is a violation of conversion definition, but SIS is tolerant to
+         * such violation. See DefaultConversion constructor javadoc for discussion.
+         */
+        verifyProperties(createLongitudeRotation(true), false);
     }
 
     /**
@@ -199,7 +221,7 @@ public final strictfp class DefaultConve
     @Test
     @DependsOnMethod("testConstruction")
     public void testDefiningConversion() throws FactoryException {
-        final DefaultConversion reference = createLongitudeRotation();
+        final DefaultConversion reference = createLongitudeRotation(true);
         final DefaultConversion definingConversion = new DefaultConversion(
                 IdentifiedObjects.getProperties(reference),
                 reference.getMethod(),
@@ -240,8 +262,8 @@ public final strictfp class DefaultConve
     public void testSpecialize() throws FactoryException {
         final MathTransformFactory factory = DefaultFactories.forBuildin(MathTransformFactory.class);
         DefaultConversion op = createLongitudeRotation(
-                createParisCRS(true,  HardCodedCS.GEODETIC_3D),
-                createParisCRS(false, HardCodedCS.GEODETIC_3D), null);
+                createParisCRS(true,  HardCodedCS.GEODETIC_3D, false),
+                createParisCRS(false, HardCodedCS.GEODETIC_3D, true), null);
         assertMatrixEquals("Longitude rotation of a three-dimensional CRS", new Matrix4(
                 1, 0, 0, OFFSET,
                 0, 1, 0, 0,
@@ -282,7 +304,7 @@ public final strictfp class DefaultConve
     @DependsOnMethod("testDefiningConversion")
     public void testWithInterpolationCRS() throws FactoryException {
         DefaultConversion op = createLongitudeRotation(HardCodedCRS.NTF,
-                createParisCRS(false, HardCodedCS.GEODETIC_2D), HardCodedCRS.TIME);
+                createParisCRS(false, HardCodedCS.GEODETIC_2D, true), HardCodedCRS.TIME);
         assertMatrixEquals("Longitude rotation of a time-varying CRS", new Matrix4(
                 1, 0, 0, 0,
                 0, 1, 0, OFFSET,
@@ -310,7 +332,7 @@ public final strictfp class DefaultConve
     @Test
     public void testDatumCheck() throws FactoryException {
         final MathTransformFactory factory = DefaultFactories.forBuildin(MathTransformFactory.class);
-        final DefaultConversion op = createLongitudeRotation();
+        final DefaultConversion op = createLongitudeRotation(true);
         try {
             op.specialize(Conversion.class, HardCodedCRS.WGS84, HardCodedCRS.NTF, factory);
             fail("Should not have accepted to change the geodetic datum.");
@@ -335,6 +357,6 @@ public final strictfp class DefaultConve
     @Test
     @DependsOnMethod("testConstruction")
     public void testSerialization() {
-        verifyProperties(assertSerializedEquals(createLongitudeRotation()), false);
+        verifyProperties(assertSerializedEquals(createLongitudeRotation(false)), false);
     }
 }



Mime
View raw message