sis-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From desruisse...@apache.org
Subject svn commit: r1801973 - in /sis/branches/JDK8/core/sis-referencing/src: main/java/org/apache/sis/internal/referencing/provider/ main/java/org/apache/sis/referencing/operation/ main/java/org/apache/sis/referencing/operation/transform/ test/java/org/apach...
Date Fri, 14 Jul 2017 15:46:35 GMT
Author: desruisseaux
Date: Fri Jul 14 15:46:34 2017
New Revision: 1801973

URL: http://svn.apache.org/viewvc?rev=1801973&view=rev
Log:
Fix CoordinateOperationNotFoundException thrown for some pairs of CRS when the EPSG geodetic dataset is not available (SIS-364).

Modified:
    sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/AbridgedMolodensky.java
    sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/Affine.java
    sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/CoordinateFrameRotation3D.java
    sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/FranceGeocentricInterpolation.java
    sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/GeocentricAffineBetweenGeographic.java
    sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/GeocentricToGeographic.java
    sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/GeocentricTranslation3D.java
    sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/GeographicOffsets.java
    sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/GeographicToGeocentric.java
    sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/LongitudeRotation.java
    sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/Molodensky.java
    sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/MolodenskyInterpolation.java
    sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/PositionVector7Param3D.java
    sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/CoordinateOperationFinder.java
    sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/DefaultMathTransformFactory.java
    sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/CoordinateOperationFinderTest.java
    sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/CoordinateOperationRegistryTest.java
    sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/DefaultCoordinateOperationFactoryTest.java

Modified: sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/AbridgedMolodensky.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/AbridgedMolodensky.java?rev=1801973&r1=1801972&r2=1801973&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/AbridgedMolodensky.java [UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/AbridgedMolodensky.java [UTF-8] Fri Jul 14 15:46:34 2017
@@ -70,7 +70,6 @@ public final class AbridgedMolodensky ex
     /**
      * Constructs a new provider.
      */
-    @SuppressWarnings("ThisEscapedInObjectConstruction")
     public AbridgedMolodensky() {
         this(3, 3, new AbridgedMolodensky[4]);
         redimensioned[0] = new AbridgedMolodensky(2, 2, redimensioned);

Modified: sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/Affine.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/Affine.java?rev=1801973&r1=1801972&r2=1801973&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/Affine.java [UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/Affine.java [UTF-8] Fri Jul 14 15:46:34 2017
@@ -122,7 +122,6 @@ public final class Affine extends Abstra
      *
      * @see org.apache.sis.referencing.operation.transform.DefaultMathTransformFactory
      */
-    @SuppressWarnings("ThisEscapedInObjectConstruction")
     public Affine() {
         super(IDENTIFICATION_EPSG, EPSG_DIMENSION, EPSG_DIMENSION, new Descriptor(IDENTIFICATION_EPSG,
                 Arrays.copyOfRange( // Discards param 0 and 1, take only the ones in index range [2…7].

Modified: sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/CoordinateFrameRotation3D.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/CoordinateFrameRotation3D.java?rev=1801973&r1=1801972&r2=1801973&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/CoordinateFrameRotation3D.java [UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/CoordinateFrameRotation3D.java [UTF-8] Fri Jul 14 15:46:34 2017
@@ -56,7 +56,6 @@ public final class CoordinateFrameRotati
     /**
      * Constructs the provider.
      */
-    @SuppressWarnings("ThisEscapedInObjectConstruction")
     public CoordinateFrameRotation3D() {
         this(3, 3, new GeocentricAffineBetweenGeographic[4]);
         redimensioned[0] = new CoordinateFrameRotation2D(      redimensioned);

Modified: sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/FranceGeocentricInterpolation.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/FranceGeocentricInterpolation.java?rev=1801973&r1=1801972&r2=1801973&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/FranceGeocentricInterpolation.java [UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/FranceGeocentricInterpolation.java [UTF-8] Fri Jul 14 15:46:34 2017
@@ -167,7 +167,6 @@ public class FranceGeocentricInterpolati
     /**
      * Constructs a provider.
      */
-    @SuppressWarnings("ThisEscapedInObjectConstruction")
     public FranceGeocentricInterpolation() {
         this(2, 2, PARAMETERS, new FranceGeocentricInterpolation[4]);
         redimensioned[0] = this;

Modified: sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/GeocentricAffineBetweenGeographic.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/GeocentricAffineBetweenGeographic.java?rev=1801973&r1=1801972&r2=1801973&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/GeocentricAffineBetweenGeographic.java [UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/GeocentricAffineBetweenGeographic.java [UTF-8] Fri Jul 14 15:46:34 2017
@@ -62,6 +62,8 @@ public abstract class GeocentricAffineBe
      * Furthermore it would not solve the case where the number of input dimensions is different than the number of
      * output dimensions. We can not afford to have wrong default values since it would confuse our interpretation
      * of user's parameters in {@link #createMathTransform(MathTransformFactory, ParameterValueGroup)}.</p>
+     *
+     * @see GeographicToGeocentric#DIMENSION
      */
     public static final ParameterDescriptor<Integer> DIMENSION;
 

Modified: sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/GeocentricToGeographic.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/GeocentricToGeographic.java?rev=1801973&r1=1801972&r2=1801973&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/GeocentricToGeographic.java [UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/GeocentricToGeographic.java [UTF-8] Fri Jul 14 15:46:34 2017
@@ -24,6 +24,7 @@ import org.opengis.referencing.operation
 import org.opengis.referencing.operation.NoninvertibleTransformException;
 import org.opengis.util.FactoryException;
 import org.apache.sis.metadata.iso.citation.Citations;
+import org.apache.sis.parameter.Parameters;
 
 
 /**
@@ -31,14 +32,14 @@ import org.apache.sis.metadata.iso.citat
  * This provider creates transforms from geocentric to geographic coordinate reference systems.
  *
  * @author  Martin Desruisseaux (IRD, Geomatys)
- * @version 0.7
+ * @version 0.8
  *
  * @see GeographicToGeocentric
  *
  * @since 0.7
  * @module
  */
-public final class GeocentricToGeographic extends AbstractProvider {
+public final class GeocentricToGeographic extends GeodeticOperation {
     /**
      * Serial number for inter-operability with different versions.
      */
@@ -47,7 +48,7 @@ public final class GeocentricToGeographi
     /**
      * The OGC name used for this operation method.
      */
-    static final String NAME = "Geocentric_To_Ellipsoid";
+    public static final String NAME = "Geocentric_To_Ellipsoid";
 
     /**
      * The group of all parameters expected by this coordinate operation.
@@ -56,7 +57,7 @@ public final class GeocentricToGeographi
     static {
         PARAMETERS = builder()
                 .addName(Citations.OGC, NAME)
-                .createGroupForMapProjection();
+                .createGroupForMapProjection(GeographicToGeocentric.DIMENSION);
                 // Not really a map projection, but we leverage the same axis parameters.
     }
 
@@ -64,7 +65,19 @@ public final class GeocentricToGeographi
      * Constructs a provider for the 3-dimensional case.
      */
     public GeocentricToGeographic() {
-        super(3, 3, PARAMETERS);
+        this(3, new GeocentricToGeographic[4]);
+        redimensioned[2] = new GeocentricToGeographic(2, redimensioned);
+        redimensioned[3] = this;
+    }
+
+    /**
+     * Constructs a provider for the given dimensions.
+     *
+     * @param targetDimensions  number of dimensions in the target CRS of this operation method.
+     * @param redimensioned     providers for all combinations between 2D and 3D cases.
+     */
+    private GeocentricToGeographic(int targetDimensions, GeodeticOperation[] redimensioned) {
+        super(3, targetDimensions, PARAMETERS, redimensioned);
     }
 
     /**
@@ -89,6 +102,16 @@ public final class GeocentricToGeographi
     }
 
     /**
+     * Specifies that the inverse of this operation is a different kind of operation.
+     *
+     * @return {@code false}.
+     */
+    @Override
+    public boolean isInvertible() {
+        return false;
+    }
+
+    /**
      * Creates a transform from the specified group of parameter values.
      *
      * @param  factory  the factory to use for creating the transform.
@@ -100,7 +123,7 @@ public final class GeocentricToGeographi
     public MathTransform createMathTransform(final MathTransformFactory factory, final ParameterValueGroup values)
             throws FactoryException
     {
-        MathTransform tr = GeographicToGeocentric.create(factory, values);
+        MathTransform tr = GeographicToGeocentric.create(factory, Parameters.castOrWrap(values));
         try {
             tr = tr.inverse();
         } catch (NoninvertibleTransformException e) {

Modified: sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/GeocentricTranslation3D.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/GeocentricTranslation3D.java?rev=1801973&r1=1801972&r2=1801973&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/GeocentricTranslation3D.java [UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/GeocentricTranslation3D.java [UTF-8] Fri Jul 14 15:46:34 2017
@@ -51,7 +51,6 @@ public final class GeocentricTranslation
     /**
      * Constructs the provider.
      */
-    @SuppressWarnings("ThisEscapedInObjectConstruction")
     public GeocentricTranslation3D() {
         this(3, 3, new GeocentricAffineBetweenGeographic[4]);
         redimensioned[0] = new GeocentricTranslation2D(      redimensioned);

Modified: sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/GeographicOffsets.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/GeographicOffsets.java?rev=1801973&r1=1801972&r2=1801973&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/GeographicOffsets.java [UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/GeographicOffsets.java [UTF-8] Fri Jul 14 15:46:34 2017
@@ -77,7 +77,6 @@ public class GeographicOffsets extends G
     /**
      * Constructs a provider with default parameters.
      */
-    @SuppressWarnings("ThisEscapedInObjectConstruction")
     public GeographicOffsets() {
         super(3, 3, PARAMETERS, new GeographicOffsets[4]);
         redimensioned[0] = new GeographicOffsets2D(redimensioned);

Modified: sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/GeographicToGeocentric.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/GeographicToGeocentric.java?rev=1801973&r1=1801972&r2=1801973&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/GeographicToGeocentric.java [UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/GeographicToGeocentric.java [UTF-8] Fri Jul 14 15:46:34 2017
@@ -19,9 +19,10 @@ package org.apache.sis.internal.referenc
 import javax.measure.Unit;
 import javax.measure.quantity.Length;
 import org.opengis.util.FactoryException;
+import org.opengis.parameter.ParameterValue;
 import org.opengis.parameter.ParameterValueGroup;
+import org.opengis.parameter.ParameterDescriptor;
 import org.opengis.parameter.ParameterDescriptorGroup;
-import org.opengis.parameter.ParameterValue;
 import org.opengis.referencing.cs.CartesianCS;
 import org.opengis.referencing.cs.EllipsoidalCS;
 import org.opengis.referencing.operation.Conversion;
@@ -30,6 +31,8 @@ import org.opengis.referencing.operation
 import org.apache.sis.referencing.operation.transform.EllipsoidToCentricTransform;
 import org.apache.sis.referencing.operation.transform.DefaultMathTransformFactory;
 import org.apache.sis.metadata.iso.citation.Citations;
+import org.apache.sis.parameter.ParameterBuilder;
+import org.apache.sis.parameter.Parameters;
 import org.apache.sis.internal.util.Constants;
 
 
@@ -45,28 +48,43 @@ import org.apache.sis.internal.util.Cons
  * @since 0.7
  * @module
  */
-public final class GeographicToGeocentric extends AbstractProvider {
+public final class GeographicToGeocentric extends GeodeticOperation {
     /**
      * Serial number for inter-operability with different versions.
      */
     private static final long serialVersionUID = -5690807111952562344L;
 
     /**
-     * The OGC name used for this operation method. The OGC name is preferred to the EPSG name
-     * because it allows to distinguish between the forward and the inverse conversion.
+     * The OGC name used for this operation method. The OGC name is preferred to the EPSG name in Apache SIS
+     * implementation because it allows to distinguish between the forward and the inverse conversion.
      */
-    static final String NAME = "Ellipsoid_To_Geocentric";
+    public static final String NAME = "Ellipsoid_To_Geocentric";
+
+    /**
+     * An Apache SIS specific parameter for the number of dimensions (2 or 3).
+     * This parameter is practically the same than {@link GeocentricAffineBetweenGeographic#DIMENSION} except:
+     *
+     * <ul>
+     *   <li>The code space is {@code "SIS"} instead than {@code "OGC"} since this parameter is not defined in OGC 01-009.</li>
+     *   <li>The default number of dimensions is 3 instead of unspecified.</li>
+     * </ul>
+     *
+     * @see GeocentricAffineBetweenGeographic#DIMENSION
+     */
+    public static final ParameterDescriptor<Integer> DIMENSION;
 
     /**
      * The group of all parameters expected by this coordinate operation.
      */
     public static final ParameterDescriptorGroup PARAMETERS;
     static {
-        PARAMETERS = builder()
+        final ParameterBuilder builder = builder();
+        DIMENSION = builder.addName(Citations.SIS, "dim").setRequired(false).createBounded(Integer.class, 2, 3, 3);
+        PARAMETERS = builder
                 .addIdentifier("9602")
                 .addName("Geographic/geocentric conversions")
                 .addName(Citations.OGC, NAME)
-                .createGroupForMapProjection();
+                .createGroupForMapProjection(DIMENSION);
                 // Not really a map projection, but we leverage the same axis parameters.
     }
 
@@ -74,7 +92,19 @@ public final class GeographicToGeocentri
      * Constructs a provider for the 3-dimensional case.
      */
     public GeographicToGeocentric() {
-        super(3, 3, PARAMETERS);
+        this(3, new GeographicToGeocentric[4]);
+        redimensioned[1] = new GeographicToGeocentric(2, redimensioned);
+        redimensioned[3] = this;
+    }
+
+    /**
+     * Constructs a provider for the given dimensions.
+     *
+     * @param sourceDimensions  number of dimensions in the source CRS of this operation method.
+     * @param redimensioned     providers for all combinations between 2D and 3D cases.
+     */
+    private GeographicToGeocentric(int sourceDimensions, GeodeticOperation[] redimensioned) {
+        super(sourceDimensions, 3, PARAMETERS, redimensioned);
     }
 
     /**
@@ -121,6 +151,16 @@ public final class GeographicToGeocentri
     }
 
     /**
+     * Specifies that the inverse of this operation is a different kind of operation.
+     *
+     * @return {@code false}.
+     */
+    @Override
+    public boolean isInvertible() {
+        return false;
+    }
+
+    /**
      * Creates a transform from the specified group of parameter values.
      *
      * @param  factory  the factory to use for creating the transform.
@@ -132,20 +172,20 @@ public final class GeographicToGeocentri
     public MathTransform createMathTransform(final MathTransformFactory factory, final ParameterValueGroup values)
             throws FactoryException
     {
-        return create(factory, values);
+        return create(factory, Parameters.castOrWrap(values));
     }
 
     /**
      * Implementation of {@link #createMathTransform(MathTransformFactory, ParameterValueGroup)}
      * shared with {@link GeocentricToGeographic}.
      */
-    static MathTransform create(final MathTransformFactory factory, final ParameterValueGroup values)
+    static MathTransform create(final MathTransformFactory factory, final Parameters values)
             throws FactoryException
     {
         final ParameterValue<?> semiMajor = values.parameter(Constants.SEMI_MAJOR);
         final Unit<Length> unit = semiMajor.getUnit().asType(Length.class);
         return EllipsoidToCentricTransform.createGeodeticConversion(factory, semiMajor.doubleValue(),
-                values.parameter(Constants.SEMI_MINOR).doubleValue(unit), unit, true,
+                values.parameter(Constants.SEMI_MINOR).doubleValue(unit), unit, values.intValue(DIMENSION) >= 3,
                 EllipsoidToCentricTransform.TargetType.CARTESIAN);
     }
 }

Modified: sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/LongitudeRotation.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/LongitudeRotation.java?rev=1801973&r1=1801972&r2=1801973&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/LongitudeRotation.java [UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/LongitudeRotation.java [UTF-8] Fri Jul 14 15:46:34 2017
@@ -65,7 +65,6 @@ public final class LongitudeRotation ext
     /**
      * Constructs a provider with default parameters.
      */
-    @SuppressWarnings("ThisEscapedInObjectConstruction")
     public LongitudeRotation() {
         this(2, 2, new LongitudeRotation[4]);
         redimensioned[0] = this;

Modified: sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/Molodensky.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/Molodensky.java?rev=1801973&r1=1801972&r2=1801973&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/Molodensky.java [UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/Molodensky.java [UTF-8] Fri Jul 14 15:46:34 2017
@@ -133,7 +133,6 @@ public final class Molodensky extends Ge
     /**
      * Constructs a new provider.
      */
-    @SuppressWarnings("ThisEscapedInObjectConstruction")
     public Molodensky() {
         this(3, 3, new Molodensky[4]);
         redimensioned[0] = new Molodensky(2, 2, redimensioned);

Modified: sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/MolodenskyInterpolation.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/MolodenskyInterpolation.java?rev=1801973&r1=1801972&r2=1801973&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/MolodenskyInterpolation.java [UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/MolodenskyInterpolation.java [UTF-8] Fri Jul 14 15:46:34 2017
@@ -54,7 +54,6 @@ public final class MolodenskyInterpolati
     /**
      * Constructs a provider.
      */
-    @SuppressWarnings("ThisEscapedInObjectConstruction")
     public MolodenskyInterpolation() {
         super(2, 2, builder().setCodeSpace(null, Constants.SIS).addName("Molodensky interpolation")
                         .createGroupWithSameParameters(PARAMETERS), new MolodenskyInterpolation[4]);

Modified: sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/PositionVector7Param3D.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/PositionVector7Param3D.java?rev=1801973&r1=1801972&r2=1801973&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/PositionVector7Param3D.java [UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/PositionVector7Param3D.java [UTF-8] Fri Jul 14 15:46:34 2017
@@ -54,7 +54,6 @@ public final class PositionVector7Param3
     /**
      * Constructs the provider.
      */
-    @SuppressWarnings("ThisEscapedInObjectConstruction")
     public PositionVector7Param3D() {
         this(3, 3, new GeocentricAffineBetweenGeographic[4]);
         redimensioned[0] = new PositionVector7Param2D(      redimensioned);

Modified: sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/CoordinateOperationFinder.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/CoordinateOperationFinder.java?rev=1801973&r1=1801972&r2=1801973&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/CoordinateOperationFinder.java [UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/CoordinateOperationFinder.java [UTF-8] Fri Jul 14 15:46:34 2017
@@ -118,8 +118,8 @@ public class CoordinateOperationFinder e
      * The accuracy threshold (in metres) for allowing the use of Molodensky approximation instead than the
      * Geocentric Translation method. The accuracy of datum shifts with Molodensky approximation is about 5
      * or 10 metres. However for this constant, we are not interested in absolute accuracy but rather in the
-     * difference between Molodensky and Geocentric Translation methods, which is much lower. We nevertheless
-     * use a relatively high threshold as a conservative approach.
+     * difference between Molodensky and Geocentric Translation methods, which is much lower (less than 1 m).
+     * We nevertheless use a relatively high threshold as a conservative approach.
      *
      * @see #desiredAccuracy
      */
@@ -501,8 +501,8 @@ public class CoordinateOperationFinder e
             if (parameters == null) {
                 parameters = TensorParameters.WKT1.createValueGroup(properties(Constants.AFFINE), datumShift);
                 final CoordinateSystem normalized = CommonCRS.WGS84.geocentric().getCoordinateSystem();
-                before = mtFactory.createCoordinateSystemChange(sourceCS, normalized);
-                after  = mtFactory.createCoordinateSystemChange(normalized, targetCS);
+                before = mtFactory.createCoordinateSystemChange(sourceCS, normalized, sourceDatum.getEllipsoid());
+                after  = mtFactory.createCoordinateSystemChange(normalized, targetCS, targetDatum.getEllipsoid());
                 context.setSource(normalized);
                 context.setTarget(normalized);
             }
@@ -522,7 +522,13 @@ public class CoordinateOperationFinder e
                 parameters = TensorParameters.WKT1.createValueGroup(properties(Constants.AFFINE));      // Initialized to identity.
                 parameters.parameter(Constants.NUM_COL).setValue(targetDim + 1);
                 parameters.parameter(Constants.NUM_ROW).setValue(targetDim + 1);
-                before = mtFactory.createCoordinateSystemChange(sourceCS, targetCS);
+                /*
+                 * createCoordinateSystemChange(…) needs the ellipsoid associated to the ellipsoidal coordinate system,
+                 * if any. If none or both coordinate systems are ellipsoidal, then the ellipsoid will be ignored (see
+                 * createCoordinateSystemChange(…) javadoc for the rational) so it does not matter which one we pick.
+                 */
+                before = mtFactory.createCoordinateSystemChange(sourceCS, targetCS,
+                        (sourceCS instanceof EllipsoidalCS ? sourceDatum : targetDatum).getEllipsoid());
                 context.setSource(targetCS);
             }
         }

Modified: sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/DefaultMathTransformFactory.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/DefaultMathTransformFactory.java?rev=1801973&r1=1801972&r2=1801973&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/DefaultMathTransformFactory.java [UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/DefaultMathTransformFactory.java [UTF-8] Fri Jul 14 15:46:34 2017
@@ -42,6 +42,7 @@ import org.opengis.parameter.InvalidPara
 import org.opengis.referencing.crs.CoordinateReferenceSystem;
 import org.opengis.referencing.cs.CoordinateSystem;
 import org.opengis.referencing.cs.EllipsoidalCS;
+import org.opengis.referencing.cs.CartesianCS;
 import org.opengis.referencing.datum.Ellipsoid;
 import org.opengis.referencing.operation.Matrix;
 import org.opengis.referencing.operation.MathTransform;
@@ -61,6 +62,8 @@ import org.apache.sis.internal.referenci
 import org.apache.sis.internal.referencing.provider.AbstractProvider;
 import org.apache.sis.internal.referencing.provider.VerticalOffset;
 import org.apache.sis.internal.referencing.provider.Providers;
+import org.apache.sis.internal.referencing.provider.GeographicToGeocentric;
+import org.apache.sis.internal.referencing.provider.GeocentricToGeographic;
 import org.apache.sis.internal.referencing.Resources;
 import org.apache.sis.internal.system.Loggers;
 import org.apache.sis.metadata.iso.citation.Citations;
@@ -1207,13 +1210,71 @@ public class DefaultMathTransformFactory
      * @return a conversion from the given source to the given target coordinate system.
      * @throws FactoryException if the conversion can not be created.
      *
+     * @deprecated Replaced by {@link #createCoordinateSystemChange(CoordinateSystem, CoordinateSystem, Ellipsoid)}
+     *
      * @since 0.7
      */
+    @Deprecated
     public MathTransform createCoordinateSystemChange(final CoordinateSystem source, final CoordinateSystem target)
             throws FactoryException
     {
+        return createCoordinateSystemChange(source, target, null);
+    }
+
+    /**
+     * Creates a math transform that represent a change of coordinate system. If exactly one argument is
+     * an {@linkplain org.apache.sis.referencing.cs.DefaultEllipsoidalCS ellipsoidal coordinate systems},
+     * then the {@code ellipsoid} argument is mandatory. In all other cases (including the case where both
+     * coordinate systems are ellipsoidal), the ellipsoid argument is ignored and can be {@code null}.
+     *
+     * <div class="note"><b>Design note:</b>
+     * this method does not accept separated ellipsoid arguments for {@code source} and {@code target} because
+     * this method should not be used for datum shifts. If the two given coordinate systems are ellipsoidal,
+     * then they are assumed to use the same ellipsoid. If different ellipsoids are desired, then a
+     * {@linkplain #createParameterizedTransform parameterized transform} like <cite>"Molodensky"</cite>,
+     * <cite>"Geocentric translations"</cite>, <cite>"Coordinate Frame Rotation"</cite> or
+     * <cite>"Position Vector transformation"</cite> should be used instead.</div>
+     *
+     * @param  source     the source coordinate system.
+     * @param  target     the target coordinate system.
+     * @param  ellipsoid  the ellipsoid of {@code EllipsoidalCS}, or {@code null} if none.
+     * @return a conversion from the given source to the given target coordinate system.
+     * @throws FactoryException if the conversion can not be created.
+     *
+     * @since 0.8
+     */
+    public MathTransform createCoordinateSystemChange(final CoordinateSystem source, final CoordinateSystem target,
+            final Ellipsoid ellipsoid) throws FactoryException
+    {
         ArgumentChecks.ensureNonNull("source", source);
         ArgumentChecks.ensureNonNull("target", target);
+        if (ellipsoid != null) {
+            final boolean isEllipsoidalSource = (source instanceof EllipsoidalCS);
+            if (isEllipsoidalSource != (target instanceof EllipsoidalCS)) {
+                /*
+                 * For now we support only conversion between EllipsoidalCS and CartesianCS.
+                 * But future Apache SIS versions could add support for conversions between
+                 * EllipsoidalCS and SphericalCS or other coordinate systems.
+                 */
+                if ((isEllipsoidalSource ? target : source) instanceof CartesianCS) {
+                    final Context context = new Context();
+                    final EllipsoidalCS cs;
+                    final String operation;
+                    if (isEllipsoidalSource) {
+                        operation = GeographicToGeocentric.NAME;
+                        context.setSource(cs = (EllipsoidalCS) source, ellipsoid);
+                        context.setTarget(target);
+                    } else {
+                        operation = GeocentricToGeographic.NAME;
+                        context.setSource(source);
+                        context.setTarget(cs = (EllipsoidalCS) target, ellipsoid);
+                    }
+                    final ParameterValueGroup pg = getDefaultParameters(operation);
+                    if (cs.getDimension() < 3) pg.parameter("dim").setValue(2);       // Apache SIS specific parameter.
+                    return createParameterizedTransform(pg, context);
+                }
+            }
+        }
         return CoordinateSystemTransform.create(this, source, target);
         // No need to use unique(…) here.
     }

Modified: sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/CoordinateOperationFinderTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/CoordinateOperationFinderTest.java?rev=1801973&r1=1801972&r2=1801973&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/CoordinateOperationFinderTest.java [UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/CoordinateOperationFinderTest.java [UTF-8] Fri Jul 14 15:46:34 2017
@@ -67,6 +67,7 @@ import static org.apache.sis.test.Assert
 
 /**
  * Tests {@link CoordinateOperationFinder}.
+ * Contrarily to {@link CoordinateOperationRegistryTest}, tests in this class are run without EPSG geodetic dataset.
  *
  * @author  Martin Desruisseaux (Geomatys)
  * @version 0.8
@@ -103,7 +104,7 @@ public final strictfp class CoordinateOp
     /**
      * The instance on which to execute the tests.
      */
-    private CoordinateOperationFinder inference;
+    private CoordinateOperationFinder finder;
 
     /**
      * Creates a new test case.
@@ -111,7 +112,7 @@ public final strictfp class CoordinateOp
      * @throws FactoryException if an error occurred while initializing the finder to test.
      */
     public CoordinateOperationFinderTest() throws FactoryException {
-        inference = new CoordinateOperationFinder(null, factory, null);
+        finder = new CoordinateOperationFinder(null, factory, null);
     }
 
     /**
@@ -184,13 +185,13 @@ public final strictfp class CoordinateOp
      * Implementation of {@link #testIdentityTransform()} using the given CRS.
      */
     private void testIdentityTransform(final CoordinateReferenceSystem crs) throws FactoryException {
-        final CoordinateOperation operation = inference.createOperation(crs, crs);
+        final CoordinateOperation operation = finder.createOperation(crs, crs);
         assertSame      ("sourceCRS",  crs, operation.getSourceCRS());
         assertSame      ("targetCRS",  crs, operation.getTargetCRS());
         assertTrue      ("isIdentity", operation.getMathTransform().isIdentity());
         assertTrue      ("accuracy",   operation.getCoordinateOperationAccuracy().isEmpty());
         assertInstanceOf("operation",  Conversion.class, operation);
-        inference = new CoordinateOperationFinder(null, factory, null);        // Reset for next call.
+        finder = new CoordinateOperationFinder(null, factory, null);        // Reset for next call.
     }
 
     /**
@@ -265,7 +266,7 @@ public final strictfp class CoordinateOp
             final GeographicCRS sourceCRS, final GeographicCRS targetCRS)
             throws ParseException, FactoryException, TransformException
     {
-        final CoordinateOperation operation = inference.createOperation(sourceCRS, targetCRS);
+        final CoordinateOperation operation = finder.createOperation(sourceCRS, targetCRS);
         assertSame      ("sourceCRS",  sourceCRS,            operation.getSourceCRS());
         assertSame      ("targetCRS",  targetCRS,            operation.getTargetCRS());
         assertFalse     ("isIdentity",                       operation.getMathTransform().isIdentity());
@@ -325,7 +326,7 @@ public final strictfp class CoordinateOp
                 "  Id[“EPSG”, “4807”]]");
 
         final GeographicCRS       targetCRS = CommonCRS.WGS84.geographic();
-        final CoordinateOperation operation = inference.createOperation(sourceCRS, targetCRS);
+        final CoordinateOperation operation = finder.createOperation(sourceCRS, targetCRS);
 
         assertSame      ("sourceCRS",  sourceCRS,            operation.getSourceCRS());
         assertSame      ("targetCRS",  targetCRS,            operation.getTargetCRS());
@@ -371,7 +372,7 @@ public final strictfp class CoordinateOp
                 "    Unit[“kilometre”, 1000]]");
 
         final GeocentricCRS       targetCRS = CommonCRS.WGS84.geocentric();
-        final CoordinateOperation operation = inference.createOperation(sourceCRS, targetCRS);
+        final CoordinateOperation operation = finder.createOperation(sourceCRS, targetCRS);
 
         assertSame      ("sourceCRS",  sourceCRS,            operation.getSourceCRS());
         assertSame      ("targetCRS",  targetCRS,            operation.getTargetCRS());
@@ -425,7 +426,7 @@ public final strictfp class CoordinateOp
                 "    Axis[“y”, NORTH],\n" +
                 "    Unit[“US survey foot”, 0.304800609601219]]");
 
-        final CoordinateOperation operation = inference.createOperation(sourceCRS, targetCRS);
+        final CoordinateOperation operation = finder.createOperation(sourceCRS, targetCRS);
         assertSame      ("sourceCRS", sourceCRS,        operation.getSourceCRS());
         assertSame      ("targetCRS", targetCRS,        operation.getTargetCRS());
         assertEquals    ("name",      "TM",             operation.getName().getCode());
@@ -453,6 +454,72 @@ public final strictfp class CoordinateOp
     }
 
     /**
+     * Tests a datum shift applied as a position vector transformation in geocentric domain.
+     * This test does not use the the EPSG geodetic dataset.
+     *
+     * @throws ParseException if a CRS used in this test can not be parsed.
+     * @throws FactoryException if the operation can not be created.
+     * @throws TransformException if an error occurred while converting the test points.
+     *
+     * @see DefaultCoordinateOperationFactoryTest#testPositionVectorTransformation()
+     * @see <a href="https://issues.apache.org/jira/browse/SIS-364">SIS-364</a>
+     *
+     * @since 0.8
+     */
+    @Test
+    @DependsOnMethod("testGeographicToProjected")
+    public void testPositionVectorTransformation() throws ParseException, FactoryException, TransformException {
+        final CoordinateReferenceSystem sourceCRS = CommonCRS.WGS84.geographic();
+        final CoordinateReferenceSystem targetCRS = parse(AGD66());
+        final CoordinateOperation operation = finder.createOperation(sourceCRS, targetCRS);
+        transform  = operation.getMathTransform();
+        tolerance  = LINEAR_TOLERANCE;
+        λDimension = new int[] {0};
+        verifyTransform(expectedAGD66(true), expectedAGD66(false));
+        validate();
+    }
+
+    /**
+     * Returns test coordinates for a transformation between {@link #AGD66()} and WGS84.
+     * We use this method for ensuring that {@link #testPositionVectorTransformation()}
+     * and {@link DefaultCoordinateOperationFactoryTest#testPositionVectorTransformation()}
+     * use the same data, as specified in {@link #AGD66()} contract.
+     *
+     * @param  WGS84  {@code true} for the WGS84 input, or {@code false} for the AGD66 output.
+     */
+    static double[] expectedAGD66(final boolean WGS84) {
+        return WGS84 ? new double[] {-37.84, 114.0} : new double[] {763850.64, 5807560.94};
+    }
+
+    /**
+     * Returns the WKT for a CRS using the Australian Geodetic Datum 1966. This method returns a WKT 1 string
+     * with a {@code TOWGS84} element that should help Apache SIS to produce the same result regardless if an
+     * EPSG geodetic dataset is used or not.
+     *
+     * @see <a href="https://issues.apache.org/jira/browse/SIS-364">SIS-364</a>
+     */
+    static String AGD66() {
+        return "PROJCS[“AGD66 / AMG zone 49”,"
+                + "GEOGCS[“AGD66”, "
+                +   "DATUM[“Australian_Geodetic_Datum_1966”, "
+                +     "SPHEROID[“Australian National Spheroid”,6378160, 298.25, AUTHORITY[“EPSG”,“7003”]],"
+                +     "TOWGS84[-117.808,-51.536,137.784,0.303,0.446,0.234,-0.29], AUTHORITY[“EPSG”,“6202”]],"
+                +     "PRIMEM[“Greenwich”, 0, AUTHORITY[“EPSG”,“8901”]],"
+                +     "UNIT[“degree”, 0.0174532925199433, AUTHORITY[“EPSG”,“9122”]],"
+                +   "AUTHORITY[“EPSG”,“4202”]],"
+                +   "PROJECTION[“Transverse_Mercator”],"
+                +   "PARAMETER[“latitude_of_origin”, 0],"
+                +   "PARAMETER[“central_meridian”, 111],"
+                +   "PARAMETER[“scale_factor”, 0.9996],"
+                +   "PARAMETER[“false_easting”, 500000],"
+                +   "PARAMETER[“false_northing”, 10000000],"
+                +   "UNIT[“metre”,1,AUTHORITY[“EPSG”,“9001”]],"
+                +   "AXIS[“Easting”,EAST],"
+                +   "AXIS[“Northing”,NORTH],"
+                + "AUTHORITY[“EPSG”,“20249”]]";
+    }
+
+    /**
      * 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.
@@ -463,7 +530,7 @@ public final strictfp class CoordinateOp
         final VerticalCRS sourceCRS = CommonCRS.Vertical.NAVD88.crs();
         final VerticalCRS targetCRS = CommonCRS.Vertical.MEAN_SEA_LEVEL.crs();
         try {
-            inference.createOperation(sourceCRS, targetCRS);
+            finder.createOperation(sourceCRS, targetCRS);
             fail("The operation should have failed.");
         } catch (OperationNotFoundException e) {
             final String message = e.getMessage();
@@ -485,7 +552,7 @@ public final strictfp class CoordinateOp
     public void testTemporalConversion() throws FactoryException, TransformException {
         final TemporalCRS sourceCRS = CommonCRS.Temporal.UNIX.crs();
         final TemporalCRS targetCRS = CommonCRS.Temporal.MODIFIED_JULIAN.crs();
-        final CoordinateOperation operation = inference.createOperation(sourceCRS, targetCRS);
+        final CoordinateOperation operation = finder.createOperation(sourceCRS, targetCRS);
         assertSame      ("sourceCRS", sourceCRS,        operation.getSourceCRS());
         assertSame      ("targetCRS", targetCRS,        operation.getTargetCRS());
         assertEquals    ("name",      "Axis changes",   operation.getName().getCode());
@@ -524,7 +591,7 @@ public final strictfp class CoordinateOp
         // NOTE: make sure that the 'sourceCRS' below is not equal to any other 'sourceCRS' created in this class.
         final CompoundCRS   sourceCRS = compound("Test4D", CommonCRS.WGS84.geographic3D(), CommonCRS.Temporal.UNIX.crs());
         final GeographicCRS targetCRS = CommonCRS.WGS84.geographic();
-        final CoordinateOperation operation = inference.createOperation(sourceCRS, targetCRS);
+        final CoordinateOperation operation = finder.createOperation(sourceCRS, targetCRS);
         assertSame      ("sourceCRS", sourceCRS,        operation.getSourceCRS());
         assertSame      ("targetCRS", targetCRS,        operation.getTargetCRS());
 
@@ -561,7 +628,7 @@ public final strictfp class CoordinateOp
     public void testGeographic3D_to_2D() throws FactoryException, TransformException {
         final GeographicCRS sourceCRS = CommonCRS.WGS84.geographic3D();
         final GeographicCRS targetCRS = CommonCRS.WGS84.geographic();
-        final CoordinateOperation operation = inference.createOperation(sourceCRS, targetCRS);
+        final CoordinateOperation operation = finder.createOperation(sourceCRS, targetCRS);
         assertSame      ("sourceCRS", sourceCRS,        operation.getSourceCRS());
         assertSame      ("targetCRS", targetCRS,        operation.getTargetCRS());
         assertEquals    ("name",      "Axis changes",   operation.getName().getCode());
@@ -604,7 +671,7 @@ public final strictfp class CoordinateOp
     public void testGeographic2D_to_3D() throws FactoryException, TransformException {
         final GeographicCRS sourceCRS = CommonCRS.WGS84.geographic();
         final GeographicCRS targetCRS = CommonCRS.WGS84.geographic3D();
-        final CoordinateOperation operation = inference.createOperation(sourceCRS, targetCRS);
+        final CoordinateOperation operation = finder.createOperation(sourceCRS, targetCRS);
         assertSame      ("sourceCRS", sourceCRS,        operation.getSourceCRS());
         assertSame      ("targetCRS", targetCRS,        operation.getTargetCRS());
         assertEquals    ("name",      "Axis changes",   operation.getName().getCode());
@@ -648,7 +715,7 @@ public final strictfp class CoordinateOp
     public void testGeographic3D_to_EllipsoidalHeight() throws FactoryException, TransformException {
         final CoordinateReferenceSystem sourceCRS = CommonCRS.WGS84.geographic3D();
         final CoordinateReferenceSystem targetCRS = HardCodedCRS.ELLIPSOIDAL_HEIGHT_cm;
-        final CoordinateOperation operation = inference.createOperation(sourceCRS, targetCRS);
+        final CoordinateOperation operation = finder.createOperation(sourceCRS, targetCRS);
         assertSame      ("sourceCRS", sourceCRS,        operation.getSourceCRS());
         assertSame      ("targetCRS", targetCRS,        operation.getTargetCRS());
         assertEquals    ("name",      "Axis changes",   operation.getName().getCode());
@@ -688,7 +755,7 @@ public final strictfp class CoordinateOp
         // NOTE: make sure that the 'sourceCRS' below is not equal to any other 'sourceCRS' created in this class.
         final CompoundCRS sourceCRS = compound("Test4D", CommonCRS.WGS84.geographic3D(), CommonCRS.Temporal.JULIAN.crs());
         final VerticalCRS targetCRS = CommonCRS.Vertical.ELLIPSOIDAL.crs();
-        final CoordinateOperation operation = inference.createOperation(sourceCRS, targetCRS);
+        final CoordinateOperation operation = finder.createOperation(sourceCRS, targetCRS);
         assertSame      ("sourceCRS", sourceCRS,        operation.getSourceCRS());
         assertSame      ("targetCRS", targetCRS,        operation.getTargetCRS());
         assertEquals    ("name",      "Axis changes",   operation.getName().getCode());
@@ -750,7 +817,7 @@ public final strictfp class CoordinateOp
         sourceCRS = compound("Mercator 3D", sourceCRS, CommonCRS.Vertical.ELLIPSOIDAL.crs());
         sourceCRS = compound("Mercator 4D", sourceCRS, CommonCRS.Temporal.MODIFIED_JULIAN.crs());
 
-        final CoordinateOperation operation = inference.createOperation(sourceCRS, targetCRS);
+        final CoordinateOperation operation = finder.createOperation(sourceCRS, targetCRS);
         assertSame("sourceCRS", sourceCRS, operation.getSourceCRS());
         assertSame("targetCRS", targetCRS, operation.getTargetCRS());
 
@@ -793,7 +860,7 @@ public final strictfp class CoordinateOp
         // NOTE: make sure that the 'sourceCRS' below is not equal to any other 'sourceCRS' created in this class.
         final CompoundCRS sourceCRS = compound("Test3D", CommonCRS.WGS84.geographic(),   CommonCRS.Temporal.UNIX.crs());
         final CompoundCRS targetCRS = compound("Test4D", CommonCRS.WGS84.geographic3D(), CommonCRS.Temporal.MODIFIED_JULIAN.crs());
-        final CoordinateOperation operation = inference.createOperation(sourceCRS, targetCRS);
+        final CoordinateOperation operation = finder.createOperation(sourceCRS, targetCRS);
         assertSame      ("sourceCRS", sourceCRS, operation.getSourceCRS());
         assertSame      ("targetCRS", targetCRS, operation.getTargetCRS());
         assertInstanceOf("operation", ConcatenatedOperation.class, operation);
@@ -843,7 +910,7 @@ public final strictfp class CoordinateOp
                     0,   0,   1
                 })), HardCodedCS.DISPLAY);
 
-        final CoordinateOperation operation = inference.createOperation(sourceCRS, targetCRS);
+        final CoordinateOperation operation = finder.createOperation(sourceCRS, targetCRS);
         assertSame("sourceCRS", sourceCRS, operation.getSourceCRS());
         assertSame("targetCRS", targetCRS, operation.getTargetCRS());
 

Modified: sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/CoordinateOperationRegistryTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/CoordinateOperationRegistryTest.java?rev=1801973&r1=1801972&r2=1801973&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/CoordinateOperationRegistryTest.java [UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/CoordinateOperationRegistryTest.java [UTF-8] Fri Jul 14 15:46:34 2017
@@ -49,9 +49,11 @@ import static org.junit.Assume.*;
 
 
 /**
- * Tests {@link CoordinateOperationRegistry}.
- * This class tests the following operations:
+ * Tests {@link CoordinateOperationRegistry} using the EPSG geodetic dataset.
+ * If no EPSG geodetic dataset is available in the running environment, then tests are skipped.
+ * For tests without the need of an EPSG database, see {@link CoordinateOperationFinderTest}.
  *
+ * <p>This class tests the following operations:</p>
  * <ul>
  *   <li><cite>"NTF (Paris) to WGS 84 (1)"</cite> operation (EPSG:8094), which implies a longitude rotation
  *       followed by a geocentric translation in the geographic domain.</li>

Modified: sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/DefaultCoordinateOperationFactoryTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/DefaultCoordinateOperationFactoryTest.java?rev=1801973&r1=1801972&r2=1801973&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/DefaultCoordinateOperationFactoryTest.java [UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/DefaultCoordinateOperationFactoryTest.java [UTF-8] Fri Jul 14 15:46:34 2017
@@ -32,6 +32,7 @@ import org.apache.sis.internal.util.Cons
 import org.apache.sis.geometry.DirectPosition2D;
 import org.apache.sis.io.wkt.WKTFormat;
 import org.apache.sis.referencing.CRS;
+import org.apache.sis.referencing.CommonCRS;
 
 // Test dependencies
 import org.apache.sis.referencing.operation.transform.MathTransformTestCase;
@@ -45,10 +46,17 @@ import static org.apache.sis.test.Refere
 
 
 /**
- * Tests {@link DefaultCoordinateOperationFactory}.
+ * Tests {@link DefaultCoordinateOperationFactory}, with or without EPSG geodetic dataset.
+ *
+ * <p><b>Relationship with other tests:</b></p>
+ * <ul>
+ *   <li>{@link CoordinateOperationRegistryTest} requires an EPSG geodetic dataset (otherwise tests are skipped).</li>
+ *   <li>{@link CoordinateOperationFinderTest} do not use any EPSG geodetic dataset.</li>
+ *   <li>{@code DefaultCoordinateOperationFactoryTest} is a mix of both.</li>
+ * </ul>
  *
  * @author  Martin Desruisseaux (Geomatys)
- * @version 0.7
+ * @version 0.8
  * @since   0.7
  * @module
  */
@@ -314,4 +322,32 @@ public final strictfp class DefaultCoord
         assertEquals("Easting should be unchanged", sourcePt.getX(),  targetPt.getX(), STRICT);
         assertEquals("Expected 27 km shift", 27476, targetPt.getY() - sourcePt.getY(), tolerance);
     }
+
+    /**
+     * Tests a datum shift applied as a position vector transformation in geocentric domain.  This method performs
+     * the same test than {@link CoordinateOperationFinderTest#testPositionVectorTransformation()} except that the
+     * EPSG geodetic dataset may be used. The result however should be the same because of the {@code TOWGS84}
+     * parameter in the WKT used for the test.
+     *
+     * @throws ParseException if a CRS used in this test can not be parsed.
+     * @throws FactoryException if the operation can not be created.
+     * @throws TransformException if an error occurred while converting the test points.
+     *
+     * @see CoordinateOperationFinderTest#testPositionVectorTransformation()
+     * @see <a href="https://issues.apache.org/jira/browse/SIS-364">SIS-364</a>
+     *
+     * @since 0.8
+     */
+    @Test
+    public void testPositionVectorTransformation() throws ParseException, FactoryException, TransformException {
+        final CoordinateReferenceSystem sourceCRS = CommonCRS.WGS84.geographic();
+        final CoordinateReferenceSystem targetCRS = parse(CoordinateOperationFinderTest.AGD66());
+        final CoordinateOperation operation = factory.createOperation(sourceCRS, targetCRS);
+        transform  = operation.getMathTransform();
+        tolerance  = Formulas.LINEAR_TOLERANCE;
+        λDimension = new int[] {0};
+        verifyTransform(CoordinateOperationFinderTest.expectedAGD66(true),
+                        CoordinateOperationFinderTest.expectedAGD66(false));
+        validate();
+    }
 }



Mime
View raw message