sis-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From desruisse...@apache.org
Subject svn commit: r1737167 - in /sis/branches/JDK8/core: sis-referencing/src/test/java/org/apache/sis/referencing/operation/ sis-utility/src/main/java/org/apache/sis/util/resources/
Date Wed, 30 Mar 2016 22:05:17 GMT
Author: desruisseaux
Date: Wed Mar 30 22:05:17 2016
New Revision: 1737167

URL: http://svn.apache.org/viewvc?rev=1737167&view=rev
Log:
Add tests for vertical and temporal axes.
Prepare tests for the next step: 2D <-> 3D ellipsoidal CS.

Modified:
    sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/CoordinateOperationInferenceTest.java
    sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/resources/Errors.java
    sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/resources/Errors.properties
    sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/resources/Errors_fr.properties
    sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/resources/IndexedResourceBundle.java

Modified: sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/CoordinateOperationInferenceTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/CoordinateOperationInferenceTest.java?rev=1737167&r1=1737166&r2=1737167&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/CoordinateOperationInferenceTest.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/CoordinateOperationInferenceTest.java
[UTF-8] Wed Mar 30 22:05:17 2016
@@ -20,6 +20,10 @@ import java.util.Arrays;
 import java.text.ParseException;
 import org.opengis.util.FactoryException;
 import org.opengis.parameter.ParameterValueGroup;
+import org.opengis.referencing.crs.GeographicCRS;
+import org.opengis.referencing.crs.GeocentricCRS;
+import org.opengis.referencing.crs.VerticalCRS;
+import org.opengis.referencing.crs.TemporalCRS;
 import org.opengis.referencing.crs.CoordinateReferenceSystem;
 import org.opengis.referencing.operation.CoordinateOperation;
 import org.opengis.referencing.operation.SingleOperation;
@@ -27,6 +31,9 @@ import org.opengis.referencing.operation
 import org.opengis.referencing.operation.Projection;
 import org.opengis.referencing.operation.Transformation;
 import org.opengis.referencing.operation.TransformException;
+import org.opengis.referencing.operation.OperationNotFoundException;
+import org.apache.sis.referencing.operation.transform.LinearTransform;
+import org.apache.sis.referencing.operation.matrix.Matrices;
 import org.apache.sis.referencing.CommonCRS;
 import org.apache.sis.io.wkt.WKTFormat;
 
@@ -142,6 +149,8 @@ public final strictfp class CoordinateOp
         testIdentityTransform(CommonCRS.WGS84.geocentric());
         testIdentityTransform(CommonCRS.WGS84.spherical());
         testIdentityTransform(CommonCRS.WGS84.UTM(0, 0));
+        testIdentityTransform(CommonCRS.Vertical.DEPTH.crs());
+        testIdentityTransform(CommonCRS.Temporal.JULIAN.crs());
     }
 
     /**
@@ -183,7 +192,7 @@ public final strictfp class CoordinateOp
                 "  AXIS[“Longitude (λ)”, EAST],\n" +
                 "  AUTHORITY[“EPSG”, “4267”]]");
 
-        final CoordinateReferenceSystem targetCRS = CommonCRS.WGS84.geographic();
+        final GeographicCRS       targetCRS = CommonCRS.WGS84.geographic();
         final CoordinateOperation operation = factory.createOperation(sourceCRS, targetCRS);
         assertSame ("sourceCRS",  sourceCRS,  operation.getSourceCRS());
         assertSame ("targetCRS",  targetCRS,  operation.getTargetCRS());
@@ -227,7 +236,7 @@ public final strictfp class CoordinateOp
                 "    Unit[“grade”, 0.015707963267949],\n" +
                 "  Id[“EPSG”, “4807”]]");
 
-        final CoordinateReferenceSystem targetCRS = CommonCRS.WGS84.geographic();
+        final GeographicCRS       targetCRS = CommonCRS.WGS84.geographic();
         final CoordinateOperation operation = factory.createOperation(sourceCRS, targetCRS);
         assertSame ("sourceCRS",  sourceCRS,  operation.getSourceCRS());
         assertSame ("targetCRS",  targetCRS,  operation.getTargetCRS());
@@ -271,7 +280,7 @@ public final strictfp class CoordinateOp
                 "    Axis[“(Z)”, geocentricZ],\n" +
                 "    Unit[“km”, 1000]]");
 
-        final CoordinateReferenceSystem targetCRS = CommonCRS.WGS84.geocentric();
+        final GeocentricCRS       targetCRS = CommonCRS.WGS84.geocentric();
         final CoordinateOperation operation = factory.createOperation(sourceCRS, targetCRS);
         assertSame ("sourceCRS",  sourceCRS,  operation.getSourceCRS());
         assertSame ("targetCRS",  targetCRS,  operation.getTargetCRS());
@@ -349,4 +358,121 @@ public final strictfp class CoordinateOp
         verifyTransform(new double[] {0, 0}, new double[] {170, 50});
         validate();
     }
+
+    /**
+     * Tests that an exception is thrown on attempt to grab a transformation between incompatible
vertical CRS.
+     *
+     * @throws FactoryException if an exception other than the expected one occurred.
+     */
+    @Test
+    @DependsOnMethod("testIdentityTransform")
+    public void testIncompatibleVerticalCRS() throws FactoryException {
+        final VerticalCRS sourceCRS = CommonCRS.Vertical.NAVD88.crs();
+        final VerticalCRS targetCRS = CommonCRS.Vertical.MEAN_SEA_LEVEL.crs();
+        try {
+            factory.createOperation(sourceCRS, targetCRS);
+            fail("The operation should have failed.");
+        } catch (OperationNotFoundException e) {
+            final String message = e.getMessage();
+            assertTrue(message, message.contains("North American Vertical Datum"));
+            assertTrue(message, message.contains("Mean Sea Level"));
+        }
+    }
+
+    /**
+     * Tests a conversion of the temporal axis. We convert 1899-12-31 from a CRS having its
epoch at 1970-1-1
+     * to an other CRS having its epoch at 1858-11-17, so the new value shall be approximatively
41 years
+     * after the new epoch. This conversion also implies a change of units from seconds to
days.
+     *
+     * @throws FactoryException if the operation can not be created.
+     * @throws TransformException if an error occurred while converting the test points.
+     */
+    @Test
+    @DependsOnMethod("testIdentityTransform")
+    public void testTemporalConversion() throws FactoryException, TransformException {
+        final TemporalCRS sourceCRS = CommonCRS.Temporal.UNIX.crs();
+        final TemporalCRS targetCRS = CommonCRS.Temporal.MODIFIED_JULIAN.crs();
+        final CoordinateOperation operation = factory.createOperation(sourceCRS, targetCRS);
+        assertSame("sourceCRS", sourceCRS, operation.getSourceCRS());
+        assertSame("targetCRS", targetCRS, operation.getTargetCRS());
+        assertInstanceOf("operation", Conversion.class, operation);
+
+        transform = operation.getMathTransform();
+        tolerance = 1E-12;
+        verifyTransform(new double[] {
+            // December 31, 1899 at 12:00 UTC in seconds.
+            CommonCRS.Temporal.DUBLIN_JULIAN.datum().getOrigin().getTime() / 1000
+        }, new double[] {
+            15019.5
+        });
+        validate();
+    }
+
+
+
+
+    //////////////////////////////////////////////////////////////////////////////////
+    ////////////                                                          ////////////
+    ////////////        Tests that change the number of dimensions        ////////////
+    ////////////                                                          ////////////
+    //////////////////////////////////////////////////////////////////////////////////
+
+    /**
+     * Tests the conversion from a three-dimensional geographic CRS to a two-dimensional
geographic CRS.
+     * The vertical dimension is simply dropped.
+     *
+     * @throws FactoryException if the operation can not be created.
+     * @throws TransformException if an error occurred while converting the test points.
+     */
+//  @Test
+    @DependsOnMethod("testIdentityTransform")
+    public void testGeographic3D_to_2D() throws FactoryException, TransformException {
+        final GeographicCRS sourceCRS = CommonCRS.WGS84.geographic3D();
+        final GeographicCRS targetCRS = CommonCRS.WGS84.geographic();
+        final CoordinateOperation operation = factory.createOperation(sourceCRS, targetCRS);
+        assertSame("sourceCRS", sourceCRS, operation.getSourceCRS());
+        assertSame("targetCRS", targetCRS, operation.getTargetCRS());
+        assertInstanceOf("operation", Conversion.class, operation);
+
+        transform = operation.getMathTransform();
+        assertInstanceOf("transform", LinearTransform.class, transform);
+        assertEquals(3, transform.getSourceDimensions());
+        assertEquals(2, transform.getTargetDimensions());
+        assertTrue(Matrices.equals(Matrices.create(3, 4, new double[] {
+            1, 0, 0, 0,
+            0, 1, 0, 0,
+            0, 0, 0, 1
+        }), ((LinearTransform) transform).getMatrix(), STRICT, false));
+        validate();
+    }
+
+    /**
+     * Tests the conversion from a two-dimensional geographic CRS to a three-dimensional
geographic CRS.
+     * Ordinate values of the vertical dimension should be set to zero.
+     *
+     * @throws FactoryException if the operation can not be created.
+     * @throws TransformException if an error occurred while converting the test points.
+     */
+//  @Test
+    @DependsOnMethod("testGeographic3D_to_2D")
+    public void testGeographic2D_to_3D() throws Exception {
+        final GeographicCRS sourceCRS = CommonCRS.WGS84.geographic();
+        final GeographicCRS targetCRS = CommonCRS.WGS84.geographic3D();
+        final CoordinateOperation operation = factory.createOperation(sourceCRS, targetCRS);
+        assertSame("sourceCRS", sourceCRS, operation.getSourceCRS());
+        assertSame("targetCRS", targetCRS, operation.getTargetCRS());
+        assertInstanceOf("operation", Conversion.class, operation);
+
+        transform = operation.getMathTransform();
+        assertInstanceOf("transform", LinearTransform.class, transform);
+        assertEquals(2, transform.getSourceDimensions());
+        assertEquals(3, transform.getTargetDimensions());
+        assertTrue(Matrices.equals(Matrices.create(4, 3, new double[] {
+            1, 0, 0,
+            0, 1, 0,
+            0, 0, 0,
+            0, 0, 1
+        }), ((LinearTransform) transform).getMatrix(), STRICT, false));
+        validate();
+    }
 }

Modified: sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/resources/Errors.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/resources/Errors.java?rev=1737167&r1=1737166&r2=1737167&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/resources/Errors.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/resources/Errors.java
[UTF-8] Wed Mar 30 22:05:17 2016
@@ -1136,7 +1136,8 @@ public final class Errors extends Indexe
         public static final short UnspecifiedParameterValues = 185;
 
         /**
-         * Can not handle instances of ‘{0}’ because arbitrary implementations are not
yet supported.
+         * Can not handle this instance of ‘{0}’ because arbitrary implementations are
not yet
+         * supported.
          */
         public static final short UnsupportedImplementation_1 = 127;
 

Modified: sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/resources/Errors.properties
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/resources/Errors.properties?rev=1737167&r1=1737166&r2=1737167&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/resources/Errors.properties
[ISO-8859-1] (original)
+++ sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/resources/Errors.properties
[ISO-8859-1] Wed Mar 30 22:05:17 2016
@@ -238,7 +238,7 @@ UnspecifiedCRS                    = Coor
 UnspecifiedDimensions             = Dimensions have not been specified.
 UnspecifiedFormatForClass_1       = No format is specified for objects of class \u2018{0}\u2019.
 UnspecifiedParameterValues        = Parameter values have not been specified.
-UnsupportedImplementation_1       = Can not handle instances of \u2018{0}\u2019 because arbitrary
implementations are not yet supported.
+UnsupportedImplementation_1       = Can not handle this instance of \u2018{0}\u2019 because
arbitrary implementations are not yet supported.
 UnsupportedInterpolation_1        = The \u201c{0}\u201d interpolation is unsupported.
 UnsupportedOperation_1            = The \u2018{0}\u2019 operation is unsupported.
 UnsupportedType_1                 = The \u2018{0}\u2019 type is unsupported.

Modified: sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/resources/Errors_fr.properties
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/resources/Errors_fr.properties?rev=1737167&r1=1737166&r2=1737167&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/resources/Errors_fr.properties
[ISO-8859-1] (original)
+++ sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/resources/Errors_fr.properties
[ISO-8859-1] Wed Mar 30 22:05:17 2016
@@ -234,7 +234,7 @@ UnparsableStringForClass_2        = Le t
 UnparsableStringForClass_3        = Le texte \u00ab\u202f{1}\u202f\u00bb n\u2019est pas reconnu
comme un objet de type \u2018{0}\u2019, \u00e0 cause des caract\u00e8res \u00ab\u202f{2}\u202f\u00bb.
 UnparsableStringInElement_2       = Le texte \u00ab\u202f{1}\u202f\u00bb dans l\u2019\u00e9l\u00e9ment
\u00ab\u202f{0}\u202f\u00bb ne peut pas \u00eatre lu.
 UnresolvedFeatureName_1           = L\u2019entit\u00e9 nomm\u00e9e \u00ab\u202f{0}\u202f\u00bb
n\u2019a pas encore \u00e9t\u00e9 r\u00e9solue.
-UnsupportedImplementation_1       = Les instances de \u2018{0}\u2019 ne peuvent pas \u00eatre
g\u00e9r\u00e9es parce que les impl\u00e9mentations arbitraires ne sont pas encore support\u00e9es.
+UnsupportedImplementation_1       = Cette instance de \u2018{0}\u2019 ne peut pas \u00eatre
g\u00e9r\u00e9e parce que les impl\u00e9mentations arbitraires ne sont pas encore support\u00e9es.
 UnsupportedInterpolation_1        = L\u2019interpolation \u201c{0}\u201d n\u2019est pas support\u00e9e.
 UnsupportedOperation_1            = L\u2019op\u00e9ration \u2018{0}\u2019 n\u2019est pas
support\u00e9e.
 UnsupportedType_1                 = Le type \u2018{0}\u2019 n\u2019est pas support\u00e9.

Modified: sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/resources/IndexedResourceBundle.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/resources/IndexedResourceBundle.java?rev=1737167&r1=1737166&r2=1737167&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/resources/IndexedResourceBundle.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/resources/IndexedResourceBundle.java
[UTF-8] Wed Mar 30 22:05:17 2016
@@ -431,18 +431,26 @@ public class IndexedResourceBundle exten
     /**
      * If the given class is not public, returns the first public interface or the first
public super-class.
      * This is for avoiding confusing the user with private class in message like "Value
can not be instance
-     * of XYZ". In the worst case (nothing public other than {@code Object}), returns {@code
Object.class}.
+     * of XYZ".
+     *
+     * <p>An exception to above rule happen if the first public class is abstract.
+     * In such case, we return the nearest non-abstract child even if non-public.</p>
      */
     private static Class<?> getPublicType(Class<?> c) {
-        while (!Modifier.isPublic(c.getModifiers())) {
+        Class<?> fallback = c;
+        int modifiers;
+        while (!Modifier.isPublic(modifiers = c.getModifiers())) {
             for (final Class<?> type : c.getInterfaces()) {
                 if (Modifier.isPublic(type.getModifiers()) && !type.getName().startsWith("java"))
{
                     return type;
                 }
             }
+            if (!Modifier.isAbstract(modifiers)) {
+                fallback = c;
+            }
             c = c.getSuperclass();
         }
-        return c;
+        return Modifier.isAbstract(modifiers) ? fallback : c;
     }
 
     /**



Mime
View raw message