sis-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From desruisse...@apache.org
Subject svn commit: r1679630 [2/3] - in /sis/branches/JDK7: ./ core/sis-feature/src/main/java/org/apache/sis/feature/ core/sis-metadata/src/main/java/org/apache/sis/io/wkt/ core/sis-metadata/src/test/java/org/apache/sis/metadata/ core/sis-metadata/src/test/jav...
Date Fri, 15 May 2015 19:11:11 GMT
Modified: sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/AbstractCoordinateOperation.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/AbstractCoordinateOperation.java?rev=1679630&r1=1679629&r2=1679630&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/AbstractCoordinateOperation.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/AbstractCoordinateOperation.java [UTF-8] Fri May 15 19:11:09 2015
@@ -32,19 +32,20 @@ import org.opengis.referencing.operation
 import org.opengis.referencing.operation.MathTransform;
 import org.opengis.metadata.Identifier;
 import org.apache.sis.parameter.Parameterized;
+import org.opengis.parameter.GeneralParameterValue;
 import org.opengis.parameter.ParameterDescriptorGroup;
 import org.opengis.parameter.ParameterValueGroup;
 import org.apache.sis.io.wkt.Formatter;
 import org.apache.sis.io.wkt.FormattableObject;
 import org.apache.sis.util.iso.Types;
 import org.apache.sis.util.Classes;
-import org.apache.sis.util.ArgumentChecks;
 import org.apache.sis.util.ComparisonMode;
 import org.apache.sis.util.resources.Errors;
 import org.apache.sis.util.collection.Containers;
 import org.apache.sis.util.UnsupportedImplementationException;
 import org.apache.sis.referencing.AbstractIdentifiedObject;
 import org.apache.sis.referencing.operation.transform.PassThroughTransform;
+import org.apache.sis.internal.referencing.ReferencingUtilities;
 import org.apache.sis.internal.referencing.OperationMethods;
 import org.apache.sis.internal.referencing.WKTUtilities;
 import org.apache.sis.internal.metadata.WKTKeywords;
@@ -75,7 +76,7 @@ import java.util.Objects;
  * <div class="section">Instantiation</div>
  * This class is conceptually <cite>abstract</cite>, even if it is technically possible to instantiate it.
  * Typical applications should create instances of the most specific subclass prefixed by {@code Default} instead.
- * An exception to this rule may occur when it is not possible to identify the exact CRS type.
+ * An exception to this rule may occur when it is not possible to identify the exact operation type.
  *
  * <div class="section">Immutability and thread safety</div>
  * This base class is immutable and thus thread-safe if the property <em>values</em> (not necessarily the map itself)
@@ -200,7 +201,7 @@ public class AbstractCoordinateOperation
         this.domainOfValidity            = definition.getDomainOfValidity();
         this.scope                       = definition.getScope();
         this.transform                   = transform;
-        checkDimensions();
+        checkDimensions(null);
     }
 
     /**
@@ -312,27 +313,39 @@ public class AbstractCoordinateOperation
         } else {
             coordinateOperationAccuracy = (value != null) ? Collections.singleton((PositionalAccuracy) value) : null;
         }
-        checkDimensions();
+        checkDimensions(properties);
     }
 
     /**
      * Ensures that {@link #sourceCRS}, {@link #targetCRS} and {@link #interpolationCRS} dimensions
      * are consistent with {@link #transform} input and output dimensions.
      */
-    private void checkDimensions() {
+    private void checkDimensions(final Map<String,?> properties) {
         if (transform != null) {
-            int sourceDim = transform.getSourceDimensions();
-            int targetDim = transform.getTargetDimensions();
-            if (interpolationCRS != null) {
-                final int dim = interpolationCRS.getCoordinateSystem().getDimension();
-                sourceDim -= dim;
-                targetDim -= dim;
-                if (sourceDim <= 0 || targetDim <= 0) {
-                    throw new IllegalArgumentException(Errors.format(Errors.Keys.MissingInterpolationOrdinates));
+            final int interpDim = ReferencingUtilities.getDimension(interpolationCRS);
+check:      for (int isTarget=0; ; isTarget++) {        // 0 == source check; 1 == target check.
+                final CoordinateReferenceSystem crs;    // Will determine the expected dimensions.
+                int actual;                             // The MathTransform number of dimensions.
+                switch (isTarget) {
+                    case 0: crs = sourceCRS; actual = transform.getSourceDimensions(); break;
+                    case 1: crs = targetCRS; actual = transform.getTargetDimensions(); break;
+                    default: break check;
+                }
+                int expected = ReferencingUtilities.getDimension(crs);
+                if (interpDim != 0) {
+                    if (actual == expected || actual < interpDim) {
+                        // This check is not strictly necessary as the next check below would catch the error,
+                        // but we provide here a hopefully more helpful error message for a common mistake.
+                        throw new IllegalArgumentException(Errors.getResources(properties)
+                                .getString(Errors.Keys.MissingInterpolationOrdinates));
+                    }
+                    expected += interpDim;
+                }
+                if (crs != null && actual != expected) {
+                    throw new IllegalArgumentException(Errors.getResources(properties).getString(
+                            Errors.Keys.MismatchedTransformDimension_3, isTarget, expected, actual));
                 }
             }
-            ArgumentChecks.ensureDimensionMatches("sourceCRS", sourceDim, sourceCRS);
-            ArgumentChecks.ensureDimensionMatches("targetCRS", targetDim, targetCRS);
         }
     }
 
@@ -449,7 +462,7 @@ public class AbstractCoordinateOperation
     /**
      * Returns the interpolation CRS of the given coordinate operation, or {@code null} if none.
      */
-    private static CoordinateReferenceSystem getInterpolationCRS(final CoordinateOperation operation) {
+    static CoordinateReferenceSystem getInterpolationCRS(final CoordinateOperation operation) {
         return (operation instanceof AbstractCoordinateOperation)
                ? ((AbstractCoordinateOperation) operation).getInterpolationCRS() : null;
     }
@@ -572,6 +585,8 @@ public class AbstractCoordinateOperation
     /**
      * Returns the operation method. This apply only to {@link AbstractSingleOperation} subclasses,
      * which will make this method public.
+     *
+     * @return The operation method, or {@code null} if none.
      */
     OperationMethod getMethod() {
         return null;
@@ -587,13 +602,13 @@ public class AbstractCoordinateOperation
         while (mt != null) {
             if (mt instanceof Parameterized) {
                 final ParameterDescriptorGroup param;
-                if (Semaphores.queryAndSet(Semaphores.PROJCS)) {
+                if (Semaphores.queryAndSet(Semaphores.ENCLOSED_IN_OPERATION)) {
                     throw new AssertionError(); // Should never happen.
                 }
                 try {
                     param = ((Parameterized) mt).getParameterDescriptors();
                 } finally {
-                    Semaphores.clear(Semaphores.PROJCS);
+                    Semaphores.clear(Semaphores.ENCLOSED_IN_OPERATION);
                 }
                 if (param != null) {
                     return param;
@@ -613,6 +628,7 @@ public class AbstractCoordinateOperation
      * Returns the parameter values. The default implementation infers the
      * parameter values from the {@linkplain #transform}, if possible.
      *
+     * @return The parameter values (never {@code null}).
      * @throws UnsupportedOperationException if the parameter values can not
      *         be determined for the current math transform implementation.
      */
@@ -621,13 +637,13 @@ public class AbstractCoordinateOperation
         while (mt != null) {
             if (mt instanceof Parameterized) {
                 final ParameterValueGroup param;
-                if (Semaphores.queryAndSet(Semaphores.PROJCS)) {
+                if (Semaphores.queryAndSet(Semaphores.ENCLOSED_IN_OPERATION)) {
                     throw new AssertionError(); // Should never happen.
                 }
                 try {
                     param = ((Parameterized) mt).getParameterValues();
                 } finally {
-                    Semaphores.clear(Semaphores.PROJCS);
+                    Semaphores.clear(Semaphores.ENCLOSED_IN_OPERATION);
                 }
                 if (param != null) {
                     return param;
@@ -729,9 +745,17 @@ public class AbstractCoordinateOperation
     @Override
     protected String formatTo(final Formatter formatter) {
         super.formatTo(formatter);
+        formatter.newLine();
         append(formatter, getSourceCRS(), WKTKeywords.SourceCRS);
         append(formatter, getTargetCRS(), WKTKeywords.TargetCRS);
         formatter.append(DefaultOperationMethod.castOrCopy(getMethod()));
+        final ParameterValueGroup parameters = getParameterValues();
+        if (parameters != null) {
+            formatter.newLine();
+            for (final GeneralParameterValue param : parameters.values()) {
+                WKTUtilities.append(param, formatter);
+            }
+        }
         append(formatter, getInterpolationCRS(), WKTKeywords.InterpolationCRS);
         final double accuracy = getLinearAccuracy();
         if (accuracy > 0) {
@@ -759,7 +783,9 @@ public class AbstractCoordinateOperation
         if (crs != null) {
             formatter.append(new FormattableObject() {
                 @Override protected String formatTo(final Formatter formatter) {
+                    formatter.indent(-1);
                     formatter.append(WKTUtilities.toFormattable(crs));
+                    formatter.indent(+1);
                     return type;
                 }
             });

Modified: sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/AbstractSingleOperation.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/AbstractSingleOperation.java?rev=1679630&r1=1679629&r2=1679630&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/AbstractSingleOperation.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/AbstractSingleOperation.java [UTF-8] Fri May 15 19:11:09 2015
@@ -31,6 +31,7 @@ import org.apache.sis.parameter.Paramete
 import org.apache.sis.referencing.IdentifiedObjects;
 import org.apache.sis.referencing.operation.transform.MathTransforms;
 import org.apache.sis.referencing.operation.transform.PassThroughTransform;
+import org.apache.sis.internal.referencing.ReferencingUtilities;
 import org.apache.sis.internal.referencing.OperationMethods;
 import org.apache.sis.internal.util.Constants;
 import org.apache.sis.util.collection.Containers;
@@ -100,7 +101,7 @@ class AbstractSingleOperation extends Ab
         super(properties, sourceCRS, targetCRS, interpolationCRS, transform);
         ArgumentChecks.ensureNonNull("method",    method);
         ArgumentChecks.ensureNonNull("transform", transform);
-        checkDimensions(method, transform, properties);
+        checkDimensions(method, ReferencingUtilities.getDimension(interpolationCRS), transform, properties);
         this.method = method;
         /*
          * Undocumented property, because SIS usually infers the parameters from the MathTransform.
@@ -124,9 +125,10 @@ class AbstractSingleOperation extends Ab
         super(properties, null, null, null, transform);
         ArgumentChecks.ensureNonNull("method", method);
         if (transform != null) {
-            checkDimensions(method, transform, properties);
+            checkDimensions(method, 0, transform, properties);
         } else if (parameters == null) {
-            throw new IllegalArgumentException(Errors.format(Errors.Keys.UnspecifiedParameterValues));
+            throw new IllegalArgumentException(Errors.getResources(properties)
+                    .getString(Errors.Keys.UnspecifiedParameterValues));
         }
         this.method = method;
         this.parameters = (parameters != null) ? parameters.clone() : null;
@@ -186,16 +188,17 @@ class AbstractSingleOperation extends Ab
      * </ul>
      *
      * @param  method     The operation method to compare to the math transform.
+     * @param  interpDim  The number of interpolation dimension, or 0 if none.
      * @param  transform  The math transform to compare to the operation method.
      * @param  properties Properties of the caller object being constructed, used only for formatting error message.
      * @throws IllegalArgumentException if the number of dimensions are incompatible.
      */
-    static void checkDimensions(final OperationMethod method, MathTransform transform,
+    static void checkDimensions(final OperationMethod method, final int interpDim, MathTransform transform,
             final Map<String,?> properties) throws IllegalArgumentException
     {
         int actual = transform.getSourceDimensions();
         Integer expected = method.getSourceDimensions();
-        if (expected != null && actual > expected) {
+        if (expected != null && actual > expected + interpDim) {
             /*
              * The given MathTransform uses more dimensions than the OperationMethod.
              * Try to locate one and only one sub-transform, ignoring axis swapping and scaling.
@@ -218,16 +221,17 @@ class AbstractSingleOperation extends Ab
         }
         /*
          * Now verify if the MathTransform dimensions are equal to the OperationMethod ones,
-         * ignoring null java.lang.Integer instances.
+         * ignoring null java.lang.Integer instances.  We do not specify whether the method
+         * dimensions should include the interpolation dimensions or not, so we accept both.
          */
-        byte isTarget = 0; // false: wrong dimension is the source one.
-        if (expected == null || actual == expected) {
+        int isTarget = 0;   // 0 == false: the wrong dimension is the source one.
+        if (expected == null || (actual == expected) || (actual == expected + interpDim)) {
             actual = transform.getTargetDimensions();
             expected = method.getTargetDimensions();
-            if (expected == null || actual == expected) {
+            if (expected == null || (actual == expected) || (actual == expected + interpDim)) {
                 return;
             }
-            isTarget = 1; // true: wrong dimension is the target one.
+            isTarget = 1;   // 1 == true: the wrong dimension is the target one.
         }
         /*
          * At least one dimension does not match.  In principle this is an error, but we make an exception for the
@@ -268,9 +272,10 @@ class AbstractSingleOperation extends Ab
     }
 
     /**
-     * Returns the operation method.
+     * Returns a description of the operation method, including a list of expected parameter names.
+     * The returned object does not contains any parameter value.
      *
-     * @return The operation method.
+     * @return A description of the operation method.
      */
     @Override
     public OperationMethod getMethod() {
@@ -278,9 +283,15 @@ class AbstractSingleOperation extends Ab
     }
 
     /**
-     * Returns a description of the parameters. The default implementation tries to infer the
-     * description from the {@linkplain #getMathTransform() math transform} itself before to
-     * fallback on the {@linkplain DefaultOperationMethod#getParameters() method parameters}.
+     * Returns a description of the parameters. The default implementation performs the following choice:
+     *
+     * <ul>
+     *   <li>If parameter values were specified explicitely at construction time,
+     *       then the descriptor of those parameters is returned.</li>
+     *   <li>Otherwise if this method can infer the parameter descriptor from the
+     *       {@linkplain #getMathTransform() math transform}, then that descriptor is returned.</li>
+     *   <li>Otherwise fallback on the {@linkplain DefaultOperationMethod#getParameters() method parameters}.</li>
+     * </ul>
      *
      * <div class="note"><b>Note:</b>
      * the two parameter descriptions (from the {@code MathTransform} or from the {@code OperationMethod})
@@ -298,8 +309,16 @@ class AbstractSingleOperation extends Ab
     }
 
     /**
-     * Returns the parameter values. The default implementation infers the parameter values from the
-     * {@linkplain #getMathTransform() math transform}, if possible.
+     * Returns the parameter values. The default implementation performs the following choice:
+     *
+     * <ul>
+     *   <li>If parameter values were specified explicitely at construction time, then a
+     *       {@linkplain org.apache.sis.parameter.DefaultParameterValueGroup#clone() clone}
+     *       of those parameters is returned.</li>
+     *   <li>Otherwise if this method can infer the parameter values from the
+     *       {@linkplain #getMathTransform() math transform}, then those parameters are returned.</li>
+     *   <li>Otherwise throw {@link org.apache.sis.util.UnsupportedImplementationException}.</li>
+     * </ul>
      *
      * @return The parameter values.
      * @throws UnsupportedOperationException if the parameter values can not be determined

Modified: sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/DefaultConcatenatedOperation.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/DefaultConcatenatedOperation.java?rev=1679630&r1=1679629&r2=1679630&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/DefaultConcatenatedOperation.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/DefaultConcatenatedOperation.java [UTF-8] Fri May 15 19:11:09 2015
@@ -117,7 +117,7 @@ public class DefaultConcatenatedOperatio
                                          final MathTransformFactory factory)
             throws FactoryException
     {
-        this(properties, expand(operations, list, factory, true), list);
+        this(properties, expand(properties, operations, list, factory, true), list);
     }
 
     /**
@@ -148,10 +148,11 @@ public class DefaultConcatenatedOperatio
      * @return The concatenated math transform, or {@code null} if {@code wantTransform} was {@code false}.
      * @throws FactoryException if the factory can not concatenate the math transforms.
      */
-    private static MathTransform expand(final CoordinateOperation[] operations,
-                                        final List<SingleOperation> target,
-                                        final MathTransformFactory  factory,
-                                        final boolean wantTransform)
+    private static MathTransform expand(final Map<String,?> properties,
+            final CoordinateOperation[] operations,
+            final List<SingleOperation> target,
+            final MathTransformFactory  factory,
+            final boolean wantTransform)
             throws FactoryException
     {
         MathTransform transform = null;
@@ -164,9 +165,9 @@ public class DefaultConcatenatedOperatio
             } else if (op instanceof ConcatenatedOperation) {
                 final ConcatenatedOperation cop = (ConcatenatedOperation) op;
                 final List<SingleOperation> cops = cop.getOperations();
-                expand(cops.toArray(new CoordinateOperation[cops.size()]), target, factory, false);
+                expand(properties, cops.toArray(new CoordinateOperation[cops.size()]), target, factory, false);
             } else {
-                throw new IllegalArgumentException(Errors.format(
+                throw new IllegalArgumentException(Errors.getResources(properties).getString(
                         Errors.Keys.IllegalArgumentClass_2, "operations[" + i + ']', op.getClass()));
             }
             /*
@@ -180,8 +181,8 @@ public class DefaultConcatenatedOperatio
                         final int dim1 = previous.getCoordinateSystem().getDimension();
                         final int dim2 = next.getCoordinateSystem().getDimension();
                         if (dim1 != dim2) {
-                            throw new IllegalArgumentException(Errors.format(Errors.Keys.MismatchedDimension_3,
-                                    "operations[" + i + "].sourceCRS", dim1, dim2));
+                            throw new IllegalArgumentException(Errors.getResources(properties).getString(
+                                    Errors.Keys.MismatchedDimension_3, "operations[" + i + "].sourceCRS", dim1, dim2));
                         }
                     }
                 }
@@ -199,7 +200,7 @@ public class DefaultConcatenatedOperatio
             }
         }
         if (wantTransform && target.size() <= 1) {
-            throw new IllegalArgumentException(Errors.format(
+            throw new IllegalArgumentException(Errors.getResources(properties).getString(
                     Errors.Keys.TooFewOccurrences_2, 2, CoordinateOperation.class));
         }
         return transform;

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=1679630&r1=1679629&r2=1679630&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 19:11:09 2015
@@ -27,13 +27,19 @@ import org.opengis.referencing.operation
 import org.opengis.referencing.operation.MathTransform;
 import org.opengis.referencing.operation.MathTransformFactory;
 import org.opengis.referencing.operation.Matrix;
+import org.opengis.referencing.crs.SingleCRS;
+import org.opengis.referencing.crs.GeneralDerivedCRS;
 import org.opengis.referencing.crs.CoordinateReferenceSystem;
 import org.opengis.referencing.cs.CoordinateSystem;
+import org.opengis.referencing.datum.Datum;
 import org.apache.sis.referencing.cs.CoordinateSystems;
 import org.apache.sis.referencing.operation.transform.DefaultMathTransformFactory;
+import org.apache.sis.referencing.operation.matrix.Matrices;
+import org.apache.sis.internal.referencing.ReferencingUtilities;
 import org.apache.sis.util.resources.Errors;
 import org.apache.sis.util.ArgumentChecks;
 import org.apache.sis.util.Workaround;
+import org.apache.sis.util.Utilities;
 
 
 /**
@@ -44,10 +50,9 @@ import org.apache.sis.util.Workaround;
  *
  * <p>This coordinate operation contains an {@linkplain DefaultOperationMethod operation method}, usually
  * with associated {@linkplain org.apache.sis.parameter.DefaultParameterValueGroup parameter values}.
- * In the SIS default implementation, the parameter values are inferred from the
- * {@linkplain org.apache.sis.referencing.operation.transform.AbstractMathTransform math transform}.
- * Subclasses may have to override the {@link #getParameterValues()} method if they need to provide
- * a different set of parameters.</p>
+ * In the SIS implementation, the parameter values can be either inferred from the
+ * {@linkplain org.apache.sis.referencing.operation.transform.AbstractMathTransform math transform}
+ * or explicitely provided at construction time in a <cite>defining conversion</cite> (see below).</p>
  *
  * <div class="section">Defining conversions</div>
  * {@code OperationMethod} instances are generally created for a pair of existing {@linkplain #getSourceCRS() source}
@@ -129,10 +134,12 @@ public class DefaultConversion extends A
      *
      * @param properties The properties to be given to the identified object.
      * @param sourceCRS  The source CRS.
-     * @param targetCRS  The target CRS.
+     * @param targetCRS  The target CRS, which shall use a datum
+     *                   {@linkplain Utilities#equalsIgnoreMetadata equals (ignoring metadata)} to the source CRS datum.
      * @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,
@@ -144,13 +151,14 @@ public class DefaultConversion extends A
         super(properties, sourceCRS, targetCRS, interpolationCRS, method, transform);
         ArgumentChecks.ensureNonNull("sourceCRS", sourceCRS);
         ArgumentChecks.ensureNonNull("targetCRS", targetCRS);
+        ensureCompatibleDatum("targetCRS", sourceCRS, targetCRS);
     }
 
     /**
      * Creates a defining conversion from the given transform and/or parameters.
      * This conversion has no source and target CRS since those elements are usually unknown
-     * at <cite>defining conversion</cite> construction time. The source and target CRS will
-     * become known later, at the
+     * at <cite>defining conversion</cite> construction time.
+     * The source and target CRS will become known later, at the
      * {@linkplain org.apache.sis.referencing.crs.DefaultDerivedCRS Derived CRS} or
      * {@linkplain org.apache.sis.referencing.crs.DefaultProjectedCRS Projected CRS}
      * construction time.
@@ -167,7 +175,7 @@ public class DefaultConversion extends A
      * for more information about what Apache SIS means by "normalized".
      *
      * <p>If the caller can not yet supply a {@code MathTransform}, then (s)he shall supply the parameter values needed
-     * for creating that transform, with the possible omission of {@code "semi-major"} and {@code "semi-minor"} values.
+     * for creating that transform, with the possible omission of {@code "semi_major"} and {@code "semi_minor"} values.
      * The semi-major and semi-minor parameter values will be set automatically when the
      * {@link #specialize specialize(…)} method will be invoked.</p>
      *
@@ -269,8 +277,8 @@ public class DefaultConversion extends A
     /**
      * Returns a specialization of this conversion with a more specific type, source and target CRS.
      * This {@code specialize(…)} method is typically invoked on {@linkplain #DefaultConversion(Map,
-     * OperationMethod, MathTransform) defining conversion} instances, when more information become
-     * available about the conversion to create.
+     * OperationMethod, MathTransform, ParameterValueGroup) defining conversion} instances,
+     * when more information become available about the conversion to create.
      *
      * <p>The given {@code baseType} argument can be one of the following values:</p>
      * <ul>
@@ -294,6 +302,8 @@ public class DefaultConversion extends A
      * @throws ClassCastException if a contradiction is found between the given {@code baseType},
      *         the defining {@linkplain DefaultConversion#getInterface() conversion type} and
      *         the {@linkplain DefaultOperationMethod#getOperationType() method operation type}.
+     * @throws MismatchedDatumException if the given CRS do not use the same datum than the source and target CRS
+     *         of this conversion.
      * @throws FactoryException if the creation of a {@link MathTransform} from the {@linkplain #getParameterValues()
      *         parameter values}, or a {@linkplain CoordinateSystems#swapAndScaleAxes change of axis order or units}
      *         failed.
@@ -308,10 +318,54 @@ public class DefaultConversion extends A
         ArgumentChecks.ensureNonNull("sourceCRS", sourceCRS);
         ArgumentChecks.ensureNonNull("targetCRS", targetCRS);
         ArgumentChecks.ensureNonNull("factory",   factory);
+        /*
+         * Conceptual consistency check: verify that the new CRS use the same datum than the previous ones,
+         * since the purpose of this method is not to apply datum changes. Datum changes are the purpose of
+         * a dedicated kind of operations, namely Transformation.
+         */
+        ensureCompatibleDatum("sourceCRS", super.getSourceCRS(), sourceCRS);
+        if (!(targetCRS instanceof GeneralDerivedCRS)) {
+            ensureCompatibleDatum("targetCRS", super.getTargetCRS(), targetCRS);
+        } else {
+            /*
+             * Special case for derived and projected CRS: we can not check directly the datum of the target CRS
+             * of a derived CRS, because this method is invoked indirectly by SIS AbstractDerivedCRS constructor
+             * before its 'conversionFromBase' field is set. Since the Apache SIS implementations of derived CRS
+             * map the datum to getConversionFromBase().getSourceCRS().getDatum(), invoking targetCRS.getDatum()
+             * below may result in a NullPointerException. Instead we verify that 'this' conversion use the same
+             * datum for source and target CRS, since DerivedCRS and ProjectedCRS are expected to have the same
+             * datum than their source CRS.
+             */
+            if (super.getTargetCRS() != null) {
+                ensureCompatibleDatum("targetCRS", sourceCRS, super.getTargetCRS());
+            }
+        }
         return SubTypes.create(baseType, this, sourceCRS, targetCRS, factory);
     }
 
     /**
+     * Ensures that the {@code actual} CRS uses a datum which is equals, ignoring metadata,
+     * to the datum of the {@code expected} CRS.
+     *
+     * @param param     The parameter name, used only in case of error.
+     * @param expected  The CRS containing the expected datum, or {@code null}.
+     * @param actual    The CRS for which to check the datum, or {@code null}.
+     * @throws MismatchedDatumException if the two CRS use different datum.
+     */
+    private static void ensureCompatibleDatum(final String param,
+            final CoordinateReferenceSystem expected,
+            final CoordinateReferenceSystem actual)
+    {
+        if ((expected instanceof SingleCRS) && (actual instanceof SingleCRS)) {
+            final Datum datum = ((SingleCRS) expected).getDatum();
+            if (datum != null && !Utilities.equalsIgnoreMetadata(datum, ((SingleCRS) actual).getDatum())) {
+                throw new MismatchedDatumException(Errors.format(
+                        Errors.Keys.IncompatibleDatum_2, datum.getName(), param));
+            }
+        }
+    }
+
+    /**
      * Creates the math transform to be given to the sub-class constructor.
      * This method is a workaround for RFE #4093999 in Sun's bug database
      * ("Relax constraint on placement of this()/super() call in constructors").
@@ -323,6 +377,7 @@ public class DefaultConversion extends A
             final CoordinateReferenceSystem targetCRS,
             final MathTransformFactory factory) throws FactoryException
     {
+        final int interpDim = ReferencingUtilities.getDimension(getInterpolationCRS(definition));
         MathTransform mt = definition.getMathTransform();
         if (mt == null) {
             /*
@@ -358,10 +413,14 @@ public class DefaultConversion extends A
                  * math transform may not be normalized), then we fallback on a simpler swapAndScaleAxes(…)
                  * method defined in this class. This is needed for AbstractCRS.forConvention(AxisConvention).
                  */
-                mt = swapAndScaleAxes(mt, sourceCRS, mtSource, true,  factory);
-                mt = swapAndScaleAxes(mt, mtTarget, targetCRS, false, factory);
+                mt = swapAndScaleAxes(mt, sourceCRS, mtSource, interpDim, true,  factory);
+                mt = swapAndScaleAxes(mt, mtTarget, targetCRS, interpDim, false, factory);
+                return mt;  // Skip createPassThroughTransform(…) since it was handled by swapAndScaleAxes(…).
             }
         }
+        if (interpDim != 0) {
+            mt = factory.createPassThroughTransform(interpDim, mt, 0);
+        }
         return mt;
     }
 
@@ -374,18 +433,23 @@ public class DefaultConversion extends A
      * @param transform The transform to which to concatenate axis changes.
      * @param sourceCRS The first CRS of the pair for which to check for axes changes.
      * @param targetCRS The second CRS of the pair for which to check for axes changes.
+     * @param interpDim The number of dimensions of the interpolation CRS, or 0 if none.
      * @param isSource  {@code true} for pre-concatenating the changes, or {@code false} for post-concatenating.
      * @param factory   The factory to use for performing axis changes.
      */
     private static MathTransform swapAndScaleAxes(MathTransform transform,
             final CoordinateReferenceSystem sourceCRS,
             final CoordinateReferenceSystem targetCRS,
-            final boolean isSource, final MathTransformFactory factory) throws FactoryException
+            final int interpDim, final boolean isSource,
+            final MathTransformFactory factory) throws FactoryException
     {
         if (sourceCRS != null && targetCRS != null && sourceCRS != targetCRS) try {
-            final Matrix m = CoordinateSystems.swapAndScaleAxes(sourceCRS.getCoordinateSystem(),
-                                                                targetCRS.getCoordinateSystem());
+            Matrix m = CoordinateSystems.swapAndScaleAxes(sourceCRS.getCoordinateSystem(),
+                                                          targetCRS.getCoordinateSystem());
             if (!m.isIdentity()) {
+                if (interpDim != 0) {
+                    m = Matrices.createPassThrough(interpDim, m, 0);
+                }
                 final MathTransform s = factory.createAffineTransform(m);
                 transform = factory.createConcatenatedTransform(isSource ? s : transform,
                                                                 isSource ? transform : s);

Modified: sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/DefaultOperationMethod.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/DefaultOperationMethod.java?rev=1679630&r1=1679629&r2=1679630&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/DefaultOperationMethod.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/DefaultOperationMethod.java [UTF-8] Fri May 15 19:11:09 2015
@@ -104,7 +104,8 @@ import java.util.Objects;
  * @since   0.5
  * @module
  *
- * @see DefaultSingleOperation
+ * @see DefaultConversion
+ * @see DefaultTransformation
  * @see org.apache.sis.referencing.operation.transform.MathTransformProvider
  */
 public class DefaultOperationMethod extends AbstractIdentifiedObject implements OperationMethod {

Modified: sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/SubTypes.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/SubTypes.java?rev=1679630&r1=1679629&r2=1679630&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/SubTypes.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/SubTypes.java [UTF-8] Fri May 15 19:11:09 2015
@@ -145,8 +145,10 @@ final class SubTypes {
             }
         }
         final Conversion conversion;
-        if (type.isInstance(definition) && definition.getSourceCRS() == sourceCRS
-                                        && definition.getTargetCRS() == targetCRS)
+        if (type.isInstance(definition)
+                && definition.getSourceCRS() == sourceCRS
+                && definition.getTargetCRS() == targetCRS
+                && definition.getMathTransform() != null)
         {
             conversion = definition;
         } else if (CylindricalProjection.class.isAssignableFrom(type)) {

Modified: sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/package-info.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/package-info.java?rev=1679630&r1=1679629&r2=1679630&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/package-info.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/package-info.java [UTF-8] Fri May 15 19:11:09 2015
@@ -25,16 +25,18 @@
  * sub-packages, but most users will not need to deal with them directly:</p>
  *
  * <ul>
- *   <li>{@link org.apache.sis.referencing.operation.projection} for map projections</li>
- *   <li>{@link org.apache.sis.referencing.operation.transform} for any transform other than map projections</li>
+ *   <li>{@link org.apache.sis.referencing.operation.projection} — map projections,</li>
+ *   <li>{@link org.apache.sis.referencing.operation.transform} — any transform other than map projections.</li>
  * </ul>
  *
  * <div class="section">Apache SIS extensions</div>
  * Some SIS implementations provide additional methods that are not part of OGC/ISO specifications:
  *
  * <ul>
- *   <li>{@link org.apache.sis.referencing.operation.AbstractCoordinateOperation#getLinearAccuracy() AbstractCoordinateOperation.getLinearAccuracy()}</li>
- *   <li>{@link org.apache.sis.referencing.operation.DefaultConversion#specialize DefaultConversion.specialize(Class, CoordinateReferenceSystem, CoordinateReferenceSystem, MathTransformFactory)}</li>
+ *   <li>{@link org.apache.sis.referencing.operation.AbstractCoordinateOperation#getLinearAccuracy() AbstractCoordinateOperation.getLinearAccuracy()}
+ *     — tries to convert the accuracy to metres,</li>
+ *   <li>{@link org.apache.sis.referencing.operation.DefaultConversion#specialize DefaultConversion.specialize(…)}
+ *     — changes a <cite>defining conversion</cite> into a complete conversion.</li>
  * </ul>
  *
  * <div class="section">Apache SIS specific behavior</div>
@@ -78,6 +80,5 @@ import javax.xml.bind.annotation.adapter
 import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapters;
 import org.apache.sis.xml.Namespaces;
 import org.apache.sis.internal.jaxb.gco.*;
-import org.apache.sis.internal.jaxb.referencing.*;
 import org.apache.sis.internal.jaxb.metadata.EX_Extent;
 import org.apache.sis.internal.jaxb.metadata.DQ_PositionalAccuracy;

Modified: sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/ConcatenatedTransform.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/ConcatenatedTransform.java?rev=1679630&r1=1679629&r2=1679630&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/ConcatenatedTransform.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/ConcatenatedTransform.java [UTF-8] Fri May 15 19:11:09 2015
@@ -459,22 +459,20 @@ class ConcatenatedTransform extends Abst
      * is more than one remaining step, even if all other transform steps are not parameterizable,
      * would be a contract violation.</p>
      *
-     * <p>However in the special case where we are formatting {@code PROJCS} element, the above rule
-     * is slightly relaxed. More specifically we ignore affine transforms in order to accept axis
-     * swapping or unit conversions. This special case is internal to SIS implementation of WKT
-     * formatter and should be unknown to users.</p>
-     *
-     * <p>See {@link org.apache.sis.referencing.operation.DefaultSingleOperation#getParameterValues()}
-     * for the code where the above-cited special case is applied.</p>
+     * <p>However in the special case where we are getting the parameters of a {@code CoordinateOperation} instance
+     * through {@link org.apache.sis.referencing.operation.AbstractCoordinateOperation#getParameterValues()} method
+     * (often indirectly trough WKT formatting of a {@code "ProjectedCRS"} element), then the above rule is slightly
+     * relaxed: we ignore affine transforms in order to accept axis swapping or unit conversions. We do that in that
+     * particular case only because the coordinate systems given with the enclosing {@code CoordinateOperation} or
+     * {@code GeneralDerivedCRS} specify the axis swapping and unit conversions.
+     * This special case is internal to SIS implementation and should be unknown to users.</p>
      *
      * @return The parameterizable transform step, or {@code null} if none.
-     *
-     * @see org.apache.sis.referencing.operation.DefaultSingleOperation#simplify(MathTransform)
      */
     private Parameterized getParameterised() {
         Parameterized param = null;
         final List<Object> transforms = getPseudoSteps();
-        if (transforms.size() == 1 || Semaphores.query(Semaphores.PROJCS)) {
+        if (transforms.size() == 1 || Semaphores.query(Semaphores.ENCLOSED_IN_OPERATION)) {
             for (final Object candidate : transforms) {
                 /*
                  * Search for non-linear parameters only, ignoring affine transforms and the matrices

Modified: sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/ContextualParameters.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/ContextualParameters.java?rev=1679630&r1=1679629&r2=1679630&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/ContextualParameters.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/ContextualParameters.java [UTF-8] Fri May 15 19:11:09 2015
@@ -178,7 +178,7 @@ public class ContextualParameters extend
      *
      * <ul>
      *   <li>Set the relevant parameter values by calls to
-     *     <code>{@linkplain #parameter(ParameterDescriptor) parameter(…)}.setValue(…)</code>.</li>
+     *     <code>{@linkplain #parameter(String) parameter(…)}.setValue(…)</code>.</li>
      *   <li>Modify the element values in {@linkplain #getMatrix(boolean) normalization / denormalization}
      *     affine transforms, optionally by calls to the convenience methods in this class.</li>
      *   <li>Get the complete transforms chain with a call

Modified: sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/geometry/AbstractEnvelopeTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/geometry/AbstractEnvelopeTest.java?rev=1679630&r1=1679629&r2=1679630&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/geometry/AbstractEnvelopeTest.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/geometry/AbstractEnvelopeTest.java [UTF-8] Fri May 15 19:11:09 2015
@@ -43,11 +43,6 @@ import static org.apache.sis.test.Refere
 @DependsOn(GeneralDirectPositionTest.class)
 public final strictfp class AbstractEnvelopeTest extends TestCase {
     /**
-     * Tolerance threshold for strict floating point comparisons.
-     */
-    static final double STRICT = 0;
-
-    /**
      * Enumeration of implementations to be tested.
      * The {@code LAST} constant is for stopping the loops.
      */

Modified: sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/geometry/Envelope2DTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/geometry/Envelope2DTest.java?rev=1679630&r1=1679629&r2=1679630&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/geometry/Envelope2DTest.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/geometry/Envelope2DTest.java [UTF-8] Fri May 15 19:11:09 2015
@@ -25,7 +25,6 @@ import org.junit.Test;
 import static org.opengis.test.Validators.*;
 import static org.apache.sis.test.ReferencingAssert.*;
 import static org.apache.sis.geometry.AbstractEnvelopeTest.WGS84;
-import static org.apache.sis.geometry.AbstractEnvelopeTest.STRICT;
 
 
 /**

Modified: sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/geometry/GeneralEnvelopeTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/geometry/GeneralEnvelopeTest.java?rev=1679630&r1=1679629&r2=1679630&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/geometry/GeneralEnvelopeTest.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/geometry/GeneralEnvelopeTest.java [UTF-8] Fri May 15 19:11:09 2015
@@ -28,7 +28,6 @@ import static java.lang.Double.NaN;
 import static org.opengis.test.Validators.*;
 import static org.apache.sis.test.ReferencingAssert.*;
 import static org.apache.sis.geometry.AbstractEnvelopeTest.WGS84;
-import static org.apache.sis.geometry.AbstractEnvelopeTest.STRICT;
 
 
 /**

Modified: sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/geometry/SubEnvelopeTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/geometry/SubEnvelopeTest.java?rev=1679630&r1=1679629&r2=1679630&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/geometry/SubEnvelopeTest.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/geometry/SubEnvelopeTest.java [UTF-8] Fri May 15 19:11:09 2015
@@ -23,7 +23,6 @@ import static java.lang.Double.NaN;
 import static org.junit.Assert.*;
 import static org.opengis.test.Validators.validate;
 import static org.apache.sis.geometry.AbstractEnvelopeTest.WGS84;
-import static org.apache.sis.geometry.AbstractEnvelopeTest.STRICT;
 
 
 /**

Modified: sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/internal/referencing/ReferencingUtilitiesTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/internal/referencing/ReferencingUtilitiesTest.java?rev=1679630&r1=1679629&r2=1679630&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/internal/referencing/ReferencingUtilitiesTest.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/internal/referencing/ReferencingUtilitiesTest.java [UTF-8] Fri May 15 19:11:09 2015
@@ -45,11 +45,6 @@ import static org.apache.sis.internal.re
  */
 public final strictfp class ReferencingUtilitiesTest extends TestCase {
     /**
-     * Tolerance threshold for strict floating point comparisons.
-     */
-    private static final double STRICT = 0;
-
-    /**
      * Tests {@link ReferencingUtilities#isGreenwichLongitudeEquals(PrimeMeridian, PrimeMeridian)}.
      */
     @Test

Modified: sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/internal/referencing/ServicesForMetadataTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/internal/referencing/ServicesForMetadataTest.java?rev=1679630&r1=1679629&r2=1679630&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/internal/referencing/ServicesForMetadataTest.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/internal/referencing/ServicesForMetadataTest.java [UTF-8] Fri May 15 19:11:09 2015
@@ -50,11 +50,6 @@ import static org.apache.sis.test.TestUt
 })
 public final strictfp class ServicesForMetadataTest extends TestCase {
     /**
-     * Tolerance threshold for strict floating point comparisons.
-     */
-    private static final double STRICT = 0;
-
-    /**
      * Creates a test envelope with the given CRS and initialized with
      * [-10 … 70]° of longitude, [-20 … 30]° of latitude, [-40 … 60] metres of elevation
      * and [51000 … 52000] modified Julian days.

Modified: sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/parameter/DefaultParameterDescriptorTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/parameter/DefaultParameterDescriptorTest.java?rev=1679630&r1=1679629&r2=1679630&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/parameter/DefaultParameterDescriptorTest.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/parameter/DefaultParameterDescriptorTest.java [UTF-8] Fri May 15 19:11:09 2015
@@ -144,7 +144,7 @@ public final strictfp class DefaultParam
      * @param  code The parameter identifier.
      * @return The descriptor with the given EPSG identifier.
      */
-    static DefaultParameterDescriptor<Double> createEPSG(final String name, final short code) {
+    public static DefaultParameterDescriptor<Double> createEPSG(final String name, final short code) {
         final Map<String, Object> properties = properties(name);
         assertNull(properties.put(DefaultParameterDescriptor.IDENTIFIERS_KEY,
                 new ImmutableIdentifier(HardCodedCitations.IOGP, Constants.EPSG, Short.toString(code))));

Modified: sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/parameter/DefaultParameterValueTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/parameter/DefaultParameterValueTest.java?rev=1679630&r1=1679629&r2=1679630&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/parameter/DefaultParameterValueTest.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/parameter/DefaultParameterValueTest.java [UTF-8] Fri May 15 19:11:09 2015
@@ -47,13 +47,6 @@ import static org.apache.sis.test.Metada
 @DependsOn(DefaultParameterDescriptorTest.class)
 public final strictfp class DefaultParameterValueTest extends TestCase {
     /**
-     * Strict tolerance factor for floating point comparisons. In the particular
-     * case of this test suite, we can afford to be strict since we will perform
-     * arithmetic only on integer values.
-     */
-    private static final double STRICT = 0.0;
-
-    /**
      * Small tolerance factor for floating point comparisons resulting from some calculation.
      */
     private static final double EPS = 1E-10;

Modified: sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/parameter/UnmodifiableParameterValueTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/parameter/UnmodifiableParameterValueTest.java?rev=1679630&r1=1679629&r2=1679630&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/parameter/UnmodifiableParameterValueTest.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/parameter/UnmodifiableParameterValueTest.java [UTF-8] Fri May 15 19:11:09 2015
@@ -39,11 +39,6 @@ import static org.junit.Assert.*;
 @DependsOn(DefaultParameterValueTest.class)
 public final strictfp class UnmodifiableParameterValueTest extends TestCase {
     /**
-     * Strict tolerance factor for floating point comparisons.
-     */
-    private static final double STRICT = 0.0;
-
-    /**
      * Creates an {@link UnmodifiableParameterValue} implementation for the given parameter
      * and asserts that we got a new instance equivalent to the original one.
      */

Modified: sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/AbstractReferenceSystemTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/AbstractReferenceSystemTest.java?rev=1679630&r1=1679629&r2=1679630&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/AbstractReferenceSystemTest.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/AbstractReferenceSystemTest.java [UTF-8] Fri May 15 19:11:09 2015
@@ -108,8 +108,8 @@ public final strictfp class AbstractRefe
                 new DefaultTemporalExtent()))); // TODO: needs sis-temporal module for testing that one.
         final AbstractReferenceSystem object = new AbstractReferenceSystem(properties);
 
-        assertEquals( // Quotes (at least the closing one) conservatively omitted for WKT 1.
-                "ReferenceSystem[\"My object.\", AUTHORITY[\"EPSG\", \"4326\"]]",
+        assertEquals(
+                "ReferenceSystem[\"My “object”.\", AUTHORITY[\"EPSG\", \"4326\"]]",
                 object.toString(Convention.WKT1));
 
         assertWktEquals(Convention.WKT1,

Modified: sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/CRSTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/CRSTest.java?rev=1679630&r1=1679629&r2=1679630&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/CRSTest.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/CRSTest.java [UTF-8] Fri May 15 19:11:09 2015
@@ -43,11 +43,6 @@ import static org.apache.sis.test.Assert
 })
 public final strictfp class CRSTest extends TestCase {
     /**
-     * Tolerance threshold for strict floating point comparisons.
-     */
-    private static final double STRICT = 0;
-
-    /**
      * Asserts that the result of {@link CRS#forCode(String)} is the given CRS.
      */
     private static void verifyForCode(final SingleCRS expected, final String code) throws FactoryException {

Modified: sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/StandardDefinitionsTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/StandardDefinitionsTest.java?rev=1679630&r1=1679629&r2=1679630&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/StandardDefinitionsTest.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/StandardDefinitionsTest.java [UTF-8] Fri May 15 19:11:09 2015
@@ -48,11 +48,6 @@ import static org.junit.Assert.*;
 })
 public final strictfp class StandardDefinitionsTest extends TestCase {
     /**
-     * The tolerance threshold for strict comparisons of floating point values.
-     */
-    private static final double STRICT = 0;
-
-    /**
      * Compares the values created by {@code StandardDefinitions} against hard-coded constants.
      * This method tests the following methods:
      *

Modified: sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/crs/DefaultCompoundCRSTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/crs/DefaultCompoundCRSTest.java?rev=1679630&r1=1679629&r2=1679630&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/crs/DefaultCompoundCRSTest.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/crs/DefaultCompoundCRSTest.java [UTF-8] Fri May 15 19:11:09 2015
@@ -58,11 +58,6 @@ public final strictfp class DefaultCompo
     private static final DefaultTemporalCRS TIME = HardCodedCRS.TIME;
 
     /**
-     * Tolerance threshold for strict floating point comparisons.
-     */
-    private static final double STRICT = 0;
-
-    /**
      * Tests construction and serialization of a {@link DefaultCompoundCRS}.
      */
     @Test

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=1679630&r1=1679629&r2=1679630&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 19:11:09 2015
@@ -16,15 +16,24 @@
  */
 package org.apache.sis.referencing.crs;
 
+import java.util.Collections;
 import org.opengis.referencing.crs.SingleCRS;
 import org.opengis.referencing.cs.CoordinateSystem;
+import org.opengis.referencing.operation.Conversion;
+import org.opengis.test.Validators;
+import org.apache.sis.io.wkt.Convention;
 import org.apache.sis.internal.metadata.WKTKeywords;
+import org.apache.sis.referencing.operation.matrix.Matrix3;
+import org.apache.sis.referencing.operation.DefaultConversion;
+import org.apache.sis.referencing.operation.DefaultConversionTest;
+import org.apache.sis.referencing.operation.transform.MathTransforms;
 import org.apache.sis.referencing.cs.HardCodedCS;
+import org.apache.sis.test.DependsOnMethod;
 import org.apache.sis.test.DependsOn;
 import org.apache.sis.test.TestCase;
 import org.junit.Test;
 
-import static org.junit.Assert.*;
+import static org.apache.sis.test.MetadataAssert.*;
 
 
 /**
@@ -36,7 +45,8 @@ import static org.junit.Assert.*;
  * @module
  */
 @DependsOn({
-    DefaultProjectedCRSTest.class   // Has many similarities with DerivedCRS, but is simpler.
+    DefaultProjectedCRSTest.class,  // Has many similarities with DerivedCRS, but is simpler.
+    DefaultConversionTest.class
 })
 public final strictfp class DefaultDerivedCRSTest extends TestCase {
     /**
@@ -77,4 +87,98 @@ public final strictfp class DefaultDeriv
         assertEquals("Using illegal coordinate system type.", WKTKeywords.EngineeringCRS,
                 DefaultDerivedCRS.getType(HardCodedCRS.WGS84, HardCodedCS.GRAVITY_RELATED_HEIGHT));
     }
+
+    /**
+     * Creates a dummy derived CRS defined by a longitude rotation from Paris to Greenwich prime meridian,
+     * and swapping the axis order. The result is equivalent to {@link HardCodedCRS#WGS84_φλ},
+     * which of course makes the returned {@code DerivedCRS} totally useless.
+     * Its purpose is only to perform easy tests.
+     */
+    private static DefaultDerivedCRS createLongitudeRotation() {
+        final DefaultConversion conversion = DefaultConversionTest.createLongitudeRotation();
+        return new DefaultDerivedCRS(Collections.singletonMap(DefaultDerivedCRS.NAME_KEY, conversion.getTargetCRS().getName()),
+                (SingleCRS) conversion.getSourceCRS(), conversion, HardCodedCS.GEODETIC_φλ);
+    }
+
+    /**
+     * Tests the construction of a {@link DefaultDerivedCRS}.
+     */
+    @Test
+    public void testConstruction() {
+        final DefaultDerivedCRS crs = createLongitudeRotation();
+        Validators.validate(crs);
+
+        assertEquals("name",    "Back to Greenwich",                crs.getName().getCode());
+        assertEquals("baseCRS", "NTF (Paris)",                      crs.getBaseCRS().getName().getCode());
+        assertEquals("datum",   "Nouvelle Triangulation Française", crs.getDatum().getName().getCode());
+        assertSame  ("coordinateSystem", HardCodedCS.GEODETIC_φλ,   crs.getCoordinateSystem());
+
+        final Conversion conversion = crs.getConversionFromBase();
+        assertSame("sourceCRS", crs.getBaseCRS(), conversion.getSourceCRS());
+        assertSame("targetCRS", crs,              conversion.getTargetCRS());
+        assertMatrixEquals("Longitude rotation", new Matrix3(
+                0, 1, 0,
+                1, 0, 2.33722917,
+                0, 0, 1), MathTransforms.getMatrix(conversion.getMathTransform()), STRICT);
+    }
+
+    /**
+     * Tests the WKT 1 formatting.
+     * Note that in the particular case of {@code DerivedCRS}, WKT 1 and WKT 2 formats are very different.
+     *
+     * <div class="note"><b>Note:</b>
+     * The CRS formatted by this test is a dummy CRS which should not exist in the reality.
+     * In particular, we use <cite>"Longitude rotation"</cite> (EPSG:9601) as if it was a conversion,
+     * while in reality it is a transformation. We do that only because this operation is so simple,
+     * it is easy to create and test.</div>
+     */
+    @Test
+    @DependsOnMethod("testConstruction")
+    public void testWKT1() {
+        assertWktEquals(Convention.WKT1,
+                "FITTED_CS[“Back to Greenwich”,\n" +
+                "  PARAM_MT[“Affine”,\n" +
+                "    PARAMETER[“elt_0_0”, 0.0],\n" +
+                "    PARAMETER[“elt_0_1”, 1.0],\n" +
+                "    PARAMETER[“elt_0_2”, -2.33722917],\n" +
+                "    PARAMETER[“elt_1_0”, 1.0],\n" +
+                "    PARAMETER[“elt_1_1”, 0.0]],\n" +
+                "  GEOGCS[“NTF (Paris)”,\n" +
+                "    DATUM[“Nouvelle Triangulation Francaise”,\n" +
+                "      SPHEROID[“NTF”, 6378249.2, 293.4660212936269]],\n" +
+                "      PRIMEM[“Paris”, 2.33722917],\n" +
+                "    UNIT[“degree”, 0.017453292519943295],\n" +
+                "    AXIS[“Longitude”, EAST],\n" +
+                "    AXIS[“Latitude”, NORTH]]]",
+                createLongitudeRotation());
+    }
+
+    /**
+     * Tests the WKT 2 formatting.
+     * Note that in the particular case of {@code DerivedCRS}, WKT 1 and WKT 2 formats are very different.
+     *
+     * <div class="note"><b>Note:</b>
+     * The CRS formatted by this test is a dummy CRS which should not exist in the reality.
+     * In particular, we use <cite>"Longitude rotation"</cite> (EPSG:9601) as if it was a conversion,
+     * while in reality it is a transformation. We do that only because this operation is so simple,
+     * it is easy to create and test.</div>
+     */
+    @Test
+    @DependsOnMethod("testWKT1")
+    public void testWKT2() {
+        assertWktEquals(
+                "GeodeticCRS[“Back to Greenwich”,\n" +
+                "  BaseGeodCRS[“NTF (Paris)”,\n" +
+                "    Datum[“Nouvelle Triangulation Francaise”,\n" +
+                "      Ellipsoid[“NTF”, 6378249.2, 293.4660212936269, LengthUnit[“metre”, 1]]],\n" +
+                "      PrimeMeridian[“Paris”, 2.5969213, AngleUnit[“grade”, 0.015707963267948967]]],\n" +
+                "  DerivingConversion[“Paris to Greenwich”,\n" +
+                "    Method[“Longitude rotation”, Id[“EPSG”, 9601, Citation[“IOGP”]]],\n" +
+                "    Parameter[“Longitude offset”, 2.33722917, Id[“EPSG”, 8602]]],\n" +
+                "  CS[“ellipsoidal”, 2],\n" +
+                "    Axis[“Latitude (B)”, north, Order[1]],\n" +
+                "    Axis[“Longitude (L)”, east, Order[2]],\n" +
+                "    AngleUnit[“degree”, 0.017453292519943295]]",
+                createLongitudeRotation());
+    }
 }

Modified: sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/crs/DefaultGeographicCRSTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/crs/DefaultGeographicCRSTest.java?rev=1679630&r1=1679629&r2=1679630&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/crs/DefaultGeographicCRSTest.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/crs/DefaultGeographicCRSTest.java [UTF-8] Fri May 15 19:11:09 2015
@@ -46,11 +46,6 @@ import static org.apache.sis.test.TestUt
 })
 public final strictfp class DefaultGeographicCRSTest extends TestCase {
     /**
-     * Tolerance threshold for strict floating point comparisons.
-     */
-    private static final double STRICT = 0;
-
-    /**
      * Tests the {@link DefaultGeographicCRS#forConvention(AxesConvention)} method
      * for {@link AxesConvention#POSITIVE_RANGE}.
      */

Modified: sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/crs/DefaultProjectedCRSTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/crs/DefaultProjectedCRSTest.java?rev=1679630&r1=1679629&r2=1679630&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/crs/DefaultProjectedCRSTest.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/crs/DefaultProjectedCRSTest.java [UTF-8] Fri May 15 19:11:09 2015
@@ -45,7 +45,8 @@ import static org.apache.sis.test.Metada
  * @module
  */
 @DependsOn({
-    DefaultGeographicCRSTest.class
+    DefaultGeographicCRSTest.class,
+    org.apache.sis.referencing.operation.DefaultConversionTest.class
 })
 public final strictfp class DefaultProjectedCRSTest extends XMLTestCase {
     /**
@@ -80,7 +81,7 @@ public final strictfp class DefaultProje
     @Test
     public void testWKT1() throws FactoryException {
         final ProjectedCRS crs = create();
-        Validators.validate(crs);
+        Validators.validate(crs);   // Opportunist check.
         assertWktEquals(Convention.WKT1,
                 "PROJCS[“NTF (Paris) / Lambert zone II”,\n" +
                 "  GEOGCS[“NTF (Paris)”,\n" +

Modified: sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/crs/HardCodedCRS.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/crs/HardCodedCRS.java?rev=1679630&r1=1679629&r2=1679630&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/crs/HardCodedCRS.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/crs/HardCodedCRS.java [UTF-8] Fri May 15 19:11:09 2015
@@ -18,6 +18,7 @@ package org.apache.sis.referencing.crs;
 
 import java.util.Map;
 import java.util.HashMap;
+import java.util.Collections;
 import org.opengis.referencing.datum.PixelInCell;
 import org.apache.sis.referencing.cs.HardCodedCS;
 import org.apache.sis.referencing.datum.HardCodedDatum;
@@ -84,11 +85,10 @@ public final strictfp class HardCodedCRS
      * this CRS is to test operations between CRS having different prime meridian.</p>
      *
      * @since 0.5
-     *
-     * @see DefaultProjectedCRSTest#NTF_ZONE_II
      */
     public static final DefaultGeographicCRS NTF = new DefaultGeographicCRS(
-            properties("NTF (Paris)"), HardCodedDatum.NTF, HardCodedCS.GEODETIC_2D);
+            Collections.singletonMap(DefaultGeographicCRS.NAME_KEY, "NTF (Paris)"),
+            HardCodedDatum.NTF, HardCodedCS.GEODETIC_2D);
 
     /**
      * A two-dimensional geographic coordinate reference system using a spherical datum.

Modified: sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/cs/AbstractCSTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/cs/AbstractCSTest.java?rev=1679630&r1=1679629&r2=1679630&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/cs/AbstractCSTest.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/cs/AbstractCSTest.java [UTF-8] Fri May 15 19:11:09 2015
@@ -27,7 +27,6 @@ import org.junit.Test;
 
 import static java.util.Collections.singletonMap;
 import static org.opengis.referencing.cs.CoordinateSystem.NAME_KEY;
-import static org.apache.sis.referencing.cs.CoordinateSystemsTest.STRICT;
 import static org.apache.sis.test.Assert.*;
 
 

Modified: sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/cs/CoordinateSystemsTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/cs/CoordinateSystemsTest.java?rev=1679630&r1=1679629&r2=1679630&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/cs/CoordinateSystemsTest.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/cs/CoordinateSystemsTest.java [UTF-8] Fri May 15 19:11:09 2015
@@ -51,11 +51,6 @@ import static org.apache.sis.test.Assert
 })
 public final strictfp class CoordinateSystemsTest extends TestCase {
     /**
-     * Tolerance threshold for strict floating point comparisons.
-     */
-    static final double STRICT = 0;
-
-    /**
      * Tests {@link CoordinateSystems#parseAxisDirection(String)}.
      */
     @Test

Modified: sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/cs/DefaultCoordinateSystemAxisTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/cs/DefaultCoordinateSystemAxisTest.java?rev=1679630&r1=1679629&r2=1679630&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/cs/DefaultCoordinateSystemAxisTest.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/cs/DefaultCoordinateSystemAxisTest.java [UTF-8] Fri May 15 19:11:09 2015
@@ -32,7 +32,6 @@ import static java.util.Collections.sing
 import static org.apache.sis.test.MetadataAssert.*;
 import static org.apache.sis.referencing.cs.HardCodedAxes.*;
 import static org.apache.sis.referencing.IdentifiedObjects.getProperties;
-import static org.apache.sis.referencing.cs.CoordinateSystemsTest.STRICT;
 
 
 /**

Modified: sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/cs/DefaultEllipsoidalCSTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/cs/DefaultEllipsoidalCSTest.java?rev=1679630&r1=1679629&r2=1679630&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/cs/DefaultEllipsoidalCSTest.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/cs/DefaultEllipsoidalCSTest.java [UTF-8] Fri May 15 19:11:09 2015
@@ -41,11 +41,6 @@ import static org.apache.sis.test.TestUt
 @DependsOn(AbstractCSTest.class)
 public final strictfp class DefaultEllipsoidalCSTest extends XMLTestCase {
     /**
-     * Tolerance threshold for strict floating point comparisons.
-     */
-    private static final double STRICT = 0;
-
-    /**
      * An XML file in this package containing an ellipsoidal coordinate system definition.
      */
     private static final String XML_FILE = "EllipsoidalCS.xml";

Modified: sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/cs/DirectionAlongMeridianTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/cs/DirectionAlongMeridianTest.java?rev=1679630&r1=1679629&r2=1679630&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/cs/DirectionAlongMeridianTest.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/cs/DirectionAlongMeridianTest.java [UTF-8] Fri May 15 19:11:09 2015
@@ -35,11 +35,6 @@ import static org.apache.sis.test.Metada
 @DependsOn(org.apache.sis.internal.referencing.AxisDirectionsTest.class)
 public final strictfp class DirectionAlongMeridianTest extends TestCase {
     /**
-     * Tolerance threshold for strict floating point comparisons.
-     */
-    private static final double STRICT = 0;
-
-    /**
      * Tests the {@link DirectionAlongMeridian#parse(AxisDirection)} method.
      */
     @Test

Modified: sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/datum/HardCodedDatum.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/datum/HardCodedDatum.java?rev=1679630&r1=1679629&r2=1679630&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/datum/HardCodedDatum.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/datum/HardCodedDatum.java [UTF-8] Fri May 15 19:11:09 2015
@@ -19,6 +19,7 @@ package org.apache.sis.referencing.datum
 import java.util.Date;
 import java.util.Map;
 import java.util.HashMap;
+import javax.measure.unit.SI;
 import javax.measure.unit.NonSI;
 import org.opengis.referencing.datum.PixelInCell;
 import org.opengis.referencing.datum.VerticalDatumType;
@@ -35,7 +36,7 @@ import static org.opengis.referencing.da
  *
  * @author  Martin Desruisseaux (Geomatys)
  * @since   0.4
- * @version 0.5
+ * @version 0.6
  * @module
  */
 public final strictfp class HardCodedDatum {
@@ -83,7 +84,7 @@ public final strictfp class HardCodedDat
      * Earth Gravitational Model}.
      */
     public static final DefaultGeodeticDatum WGS72 = new DefaultGeodeticDatum(
-            properties("World Geodetic System 1972", "6322", "Satellite navigation."),
+            properties("World Geodetic System 1972", "6322", WGS84.getScope()),
             new DefaultEllipsoid(GeodeticDatumMock.WGS84.getEllipsoid()), GREENWICH);
 
     /**
@@ -96,6 +97,28 @@ public final strictfp class HardCodedDat
             new DefaultEllipsoid(GeodeticDatumMock.NTF.getEllipsoid()), PARIS);
 
     /**
+     * Tokyo 1918 datum (EPSG:6301). Ellipsoid is Bessel 1841 and prime meridian is Greenwich.
+     * Bursa-Wolf parameters to {@link #JGD2000} are (-146.414, 507.337, 680.507).
+     *
+     * @since 0.6
+     */
+    public static final DefaultGeodeticDatum TOKYO = new DefaultGeodeticDatum(
+            properties("Tokyo 1918", "6301", "Geodetic survey."),
+            DefaultEllipsoid.createFlattenedSphere(properties("Bessel 1841", "7004", null),
+                    6377397.155, 299.1528128, SI.METRE), GREENWICH);
+
+    /**
+     * Japanese Geodetic Datum 2000 datum (EPSG:6612). Ellipsoid is GRS 1980 and prime meridian is Greenwich.
+     * This is useful for testing datum shift from {@link #TOKYO}.
+     *
+     * @since 0.6
+     */
+    public static final DefaultGeodeticDatum JGD2000 = new DefaultGeodeticDatum(
+            properties("Japanese Geodetic Datum 2000", "6612", TOKYO.getScope()),
+            DefaultEllipsoid.createFlattenedSphere(properties("GRS 1980", "7019", null),
+                    6378137, 298.257222101, SI.METRE), GREENWICH);
+
+    /**
      * Spherical datum based on GRS 1980 Authalic Sphere (EPSG:6047). Prime meridian is Greenwich.
      */
     public static final DefaultGeodeticDatum SPHERE = new DefaultGeodeticDatum(
@@ -103,21 +126,21 @@ public final strictfp class HardCodedDat
             new DefaultEllipsoid(GeodeticDatumMock.SPHERE.getEllipsoid()), GREENWICH);
 
     /**
-     * Mean sea level, which can be used as an approximation of geoid.
-     */
-    public static final DefaultVerticalDatum MEAN_SEA_LEVEL = new DefaultVerticalDatum(
-            properties("Mean Sea Level", "5100", "Hydrography."),
-            VerticalDatumType.GEOIDAL);
-
-    /**
      * Ellipsoid for measurements of height above the ellipsoid.
      * This is not a valid datum according ISO 19111, but is used by Apache SIS for internal calculation.
      */
     public static final DefaultVerticalDatum ELLIPSOID = new DefaultVerticalDatum(
-            properties("Ellipsoid", null, "Not a valid datum."),
+            properties("Ellipsoid", null, SPHERE.getScope()),
             VerticalDatumTypes.ELLIPSOIDAL);
 
     /**
+     * Mean sea level, which can be used as an approximation of geoid.
+     */
+    public static final DefaultVerticalDatum MEAN_SEA_LEVEL = new DefaultVerticalDatum(
+            properties("Mean Sea Level", "5100", "Hydrography."),
+            VerticalDatumType.GEOIDAL);
+
+    /**
      * Default datum for time measured since January 1st, 1970 at 00:00 UTC.
      */
     public static final DefaultTemporalDatum UNIX = new DefaultTemporalDatum(
@@ -147,7 +170,7 @@ public final strictfp class HardCodedDat
     /**
      * Creates a map of properties for the given name and EPSG code.
      */
-    private static Map<String,?> properties(final String name, final String code, final String scope) {
+    private static Map<String,?> properties(final String name, final String code, final CharSequence scope) {
         final Map<String,Object> properties = new HashMap<>(4);
         properties.put(NAME_KEY, name);
         if (code != null) {

Modified: sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/AbstractSingleOperationTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/AbstractSingleOperationTest.java?rev=1679630&r1=1679629&r2=1679630&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/AbstractSingleOperationTest.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/AbstractSingleOperationTest.java [UTF-8] Fri May 15 19:11:09 2015
@@ -41,7 +41,7 @@ import static org.opengis.test.Assert.*;
  */
 @DependsOn({
     DefaultOperationMethodTest.class,
-    org.apache.sis.referencing.operation.transform.MathTransformsTest.class
+    MathTransformsTest.class
 })
 public final strictfp class AbstractSingleOperationTest extends TestCase {
     /**
@@ -55,23 +55,24 @@ public final strictfp class AbstractSing
     }
 
     /**
-     * Tests {@link OperationMethods#checkDimensions(OperationMethod, MathTransform, Map)}.
+     * Tests {@link AbstractSingleOperation#checkDimensions(OperationMethod, MathTransform, Map)}
+     * without interpolation dimension.
      */
     @Test
     public void testCheckDimensions() {
         final Map<String,?> properties = Collections.singletonMap(DefaultOperationMethod.LOCALE_KEY, Locale.ENGLISH);
         final MathTransform tr = MathTransformsTest.createConcatenateAndPassThrough();
-        AbstractSingleOperation.checkDimensions(createOperationMethod(3, 3), tr, properties);
-        AbstractSingleOperation.checkDimensions(createOperationMethod(1, 1), tr, properties);
+        AbstractSingleOperation.checkDimensions(createOperationMethod(3, 3), 0, tr, properties);
+        AbstractSingleOperation.checkDimensions(createOperationMethod(1, 1), 0, tr, properties);
         try {
-            AbstractSingleOperation.checkDimensions(createOperationMethod(2, 2), tr, properties);
+            AbstractSingleOperation.checkDimensions(createOperationMethod(2, 2), 0, tr, properties);
             fail("MathTransform.sourceDimension == 3 shall be considered incompatible.");
         } catch (IllegalArgumentException e) {
             // This is the expected exception.
             assertEquals(e.getMessage(), "The transform has 1 source dimension, while 2 was expected.");
         }
         try {
-            AbstractSingleOperation.checkDimensions(createOperationMethod(3, 1), tr, properties);
+            AbstractSingleOperation.checkDimensions(createOperationMethod(3, 1), 0, tr, properties);
             fail("MathTransform.targetDimension == 3 shall be considered incompatible.");
         } catch (IllegalArgumentException e) {
             // This is the expected exception.

Modified: sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/DefaultOperationMethodTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/DefaultOperationMethodTest.java?rev=1679630&r1=1679629&r2=1679630&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/DefaultOperationMethodTest.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/DefaultOperationMethodTest.java [UTF-8] Fri May 15 19:11:09 2015
@@ -19,6 +19,7 @@ package org.apache.sis.referencing.opera
 import java.util.Map;
 import java.util.HashMap;
 import org.opengis.metadata.Identifier;
+import org.opengis.parameter.ParameterDescriptor;
 import org.opengis.parameter.ParameterDescriptorGroup;
 import org.opengis.referencing.operation.OperationMethod;
 import org.apache.sis.io.wkt.Convention;
@@ -45,7 +46,8 @@ import static org.apache.sis.test.Refere
  */
 @DependsOn({
     DefaultFormulaTest.class,
-    org.apache.sis.referencing.AbstractIdentifiedObjectTest.class
+    org.apache.sis.referencing.AbstractIdentifiedObjectTest.class,
+    org.apache.sis.parameter.DefaultParameterDescriptorGroupTest.class
 })
 public final strictfp class DefaultOperationMethodTest extends TestCase {
     /**
@@ -54,11 +56,12 @@ public final strictfp class DefaultOpera
      * @param  method     The operation name (example: "Mercator (variant A)").
      * @param  identifier The EPSG numeric identifier (example: "9804").
      * @param  formula    Formula citation (example: "EPSG guidance note #7-2").
-     * @param  dimension  The number of input and output dimension.
+     * @param  dimension  The number of input and output dimension, or {@code null}.
+     * @param  parameters The parameters (can be empty).
      * @return The operation method.
      */
-    private static DefaultOperationMethod create(final String method, final String identifier, final String formula,
-            final Integer dimension)
+    static DefaultOperationMethod create(final String method, final String identifier, final String formula,
+            final Integer dimension, final ParameterDescriptor<?>... parameters)
     {
         final Map<String,Object> properties = new HashMap<>(8);
         assertNull(properties.put(OperationMethod.NAME_KEY, method));
@@ -68,15 +71,15 @@ public final strictfp class DefaultOpera
          * The parameter group for a Mercator projection is actually not empty, but it is not the purpose of
          * this class to test DefaultParameterDescriptorGroup. So we use an empty group of parameters here.
          */
-        final ParameterDescriptorGroup parameters = new DefaultParameterDescriptorGroup(properties, 1, 1);
+        final ParameterDescriptorGroup pg = new DefaultParameterDescriptorGroup(properties, 1, 1, parameters);
         /*
          * NAME_KEY share the same Identifier instance for saving a little bit of memory.
          * Then define the other properties to be given to OperationMethod.
          */
-        assertNotNull(properties.put(OperationMethod.NAME_KEY, parameters.getName()));
+        assertNotNull(properties.put(OperationMethod.NAME_KEY, pg.getName()));
         assertNull(properties.put(OperationMethod.IDENTIFIERS_KEY, new ImmutableIdentifier(HardCodedCitations.IOGP, "EPSG", identifier)));
         assertNull(properties.put(OperationMethod.FORMULA_KEY, new DefaultCitation(formula)));
-        return new DefaultOperationMethod(properties, dimension, dimension, parameters);
+        return new DefaultOperationMethod(properties, dimension, dimension, pg);
     }
 
     /**
@@ -151,6 +154,8 @@ public final strictfp class DefaultOpera
 
     /**
      * Tests {@link DefaultOperationMethod#toWKT()}.
+     * Since the WKT format of {@code OperationMethod} does not include parameters,
+     * we do not bother specifying the parameters in the object created here.
      */
     @Test
     @DependsOnMethod("testConstruction")

Modified: sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/builder/LinearTransformBuilderTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/builder/LinearTransformBuilderTest.java?rev=1679630&r1=1679629&r2=1679630&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/builder/LinearTransformBuilderTest.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/builder/LinearTransformBuilderTest.java [UTF-8] Fri May 15 19:11:09 2015
@@ -39,13 +39,6 @@ import static org.junit.Assert.*;
  */
 public final strictfp class LinearTransformBuilderTest extends TestCase {
     /**
-     * Tolerance threshold for strict floating point comparisons. This is used when the math transform has
-     * been built from exactly 3 points, in which case we expect an exact solution without rounding errors
-     * at the scale of {@code double} type since the implementation use double-double arithmetic.
-     */
-    private static final double STRICT = 0;
-
-    /**
      * Tests a very simple case where an exact answer is expected.
      */
     @Test
@@ -65,6 +58,9 @@ public final strictfp class LinearTransf
 
     /**
      * Tests a very simple case where an exact answer is expected.
+     * Tolerance threshold is set to zero because the math transform has been built from exactly 3 points,
+     * in which case we expect an exact solution without rounding errors at the scale of the {@code double}
+     * type. This is possible because SIS implementation uses double-double arithmetic.
      */
     @Test
     public void testMinimalist2D() {



Mime
View raw message