sis-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From desruisse...@apache.org
Subject svn commit: r1675576 - in /sis/branches/JDK8/core/sis-referencing/src: main/java/org/apache/sis/internal/referencing/ main/java/org/apache/sis/referencing/operation/ test/java/org/apache/sis/internal/referencing/ test/java/org/apache/sis/referencing/op...
Date Thu, 23 Apr 2015 11:33:40 GMT
Author: desruisseaux
Date: Thu Apr 23 11:33:39 2015
New Revision: 1675576

URL: http://svn.apache.org/r1675576
Log:
Referencing: ported support for "defining conversions".

Added:
    sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/DefaultProjection.java
  (with props)
    sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/AbstractSingleOperationTest.java
      - copied, changed from r1675086, sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/internal/referencing/OperationMethodsTest.java
Modified:
    sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/OperationMethods.java
    sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/AbstractCoordinateOperation.java
    sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/AbstractSingleOperation.java
    sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/DefaultConversion.java
    sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/package-info.java
    sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/internal/referencing/OperationMethodsTest.java
    sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/test/suite/ReferencingTestSuite.java

Modified: sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/OperationMethods.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/OperationMethods.java?rev=1675576&r1=1675575&r2=1675576&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/OperationMethods.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/OperationMethods.java
[UTF-8] Thu Apr 23 11:33:39 2015
@@ -16,7 +16,6 @@
  */
 package org.apache.sis.internal.referencing;
 
-import java.util.Map;
 import java.util.Collection;
 import org.opengis.util.Record;
 import javax.measure.unit.SI;
@@ -29,10 +28,7 @@ import org.opengis.metadata.quality.Posi
 import org.opengis.metadata.quality.QuantitativeResult;
 import org.opengis.referencing.operation.*;
 import org.apache.sis.referencing.AbstractIdentifiedObject;
-import org.apache.sis.referencing.operation.transform.MathTransforms;
-import org.apache.sis.referencing.operation.transform.PassThroughTransform;
 import org.apache.sis.internal.util.Citations;
-import org.apache.sis.util.resources.Errors;
 import org.apache.sis.util.CharSequences;
 import org.apache.sis.util.Characters;
 import org.apache.sis.util.Static;
@@ -161,101 +157,6 @@ public final class OperationMethods exte
             }
         }
         return false;
-    }
-
-    /**
-     * Checks if an operation method and a math transform have a compatible number of source
and target dimensions.
-     * In the particular case of a {@linkplain PassThroughTransform pass through transform}
with more dimensions
-     * than what we would expect from the given method, the check will rather be performed
against the
-     * {@linkplain PassThroughTransform#getSubTransform() sub transform}.
-     *
-     * <p>The intend is to allow creation of a three-dimensional {@code ProjectedCRS}
with a two-dimensional
-     * {@code OperationMethod}, where the third-dimension just pass through. This is not
a recommended approach
-     * and we do not document that as a supported feature, but we do not prevent it neither.</p>
-     *
-     * <p>This method tries to locates what seems to be the "core" of the given math
transform. The definition
-     * of "core" is imprecise and may be adjusted in future SIS versions. The current algorithm
is as below:</p>
-     *
-     * <ul>
-     *   <li>If the given transform can be decomposed in {@linkplain MathTransforms#getSteps(MathTransform)
steps},
-     *       then the steps for {@linkplain org.apache.sis.referencing.cs.CoordinateSystems#swapAndScaleAxes
axis
-     *       swapping and scaling} are ignored.</li>
-     *   <li>If the given transform or its non-ignorable step is a {@link PassThroughTransform},
then its sub-transform
-     *       is taken. Only one non-ignorable step may exist, otherwise we do not try to
select any of them.</li>
-     * </ul>
-     *
-     * @param  method     The operation method to compare to the math transform.
-     * @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.
-     */
-    public static void checkDimensions(final OperationMethod method, MathTransform transform,
-            final Map<String,?> properties) throws IllegalArgumentException
-    {
-        int actual = transform.getSourceDimensions();
-        Integer expected = method.getSourceDimensions();
-        if (expected != null && actual > expected) {
-            /*
-             * The given MathTransform use more dimensions than the OperationMethod.
-             * Try to locate one and only one sub-transform, ignoring axis swapping and scaling.
-             */
-            MathTransform subTransform = null;
-            for (final MathTransform step : MathTransforms.getSteps(transform)) {
-                if (!isIgnorable(step)) {
-                    if (subTransform == null && step instanceof PassThroughTransform)
{
-                        subTransform = ((PassThroughTransform) step).getSubTransform();
-                    } else {
-                        subTransform = null;
-                        break;
-                    }
-                }
-            }
-            if (subTransform != null) {
-                transform = subTransform;
-                actual = transform.getSourceDimensions();
-            }
-        }
-        /*
-         * Now verify if the MathTransform dimensions are equal to the OperationMethod ones,
-         * ignoring null java.lang.Integer instances.
-         */
-        byte isTarget = 0; // false: wrong dimension is the source one.
-        if (expected == null || actual == expected) {
-            actual = transform.getTargetDimensions();
-            expected = method.getTargetDimensions();
-            if (expected == null || actual == expected) {
-                return;
-            }
-            isTarget = 1; // true: wrong dimension is the target one.
-        }
-        throw new IllegalArgumentException(Errors.getResources(properties).getString(
-                Errors.Keys.MismatchedTransformDimension_3, isTarget, expected, actual));
-    }
-
-    /**
-     * Returns {@code true} if the specified transform is likely to exists only for axis
swapping
-     * and/or unit conversions. The heuristic rule checks if the transform is backed by a
square
-     * matrix with exactly one non-null value in each row and each column.
-     */
-    private static boolean isIgnorable(final MathTransform transform) {
-        final Matrix matrix = MathTransforms.getMatrix(transform);
-        if (matrix != null) {
-            final int size = matrix.getNumRow();
-            if (matrix.getNumCol() == size) {
-                for (int j=0; j<size; j++) {
-                    int n1=0, n2=0;
-                    for (int i=0; i<size; i++) {
-                        if (matrix.getElement(j,i) != 0) n1++;
-                        if (matrix.getElement(i,j) != 0) n2++;
-                    }
-                    if (n1 != 1 || n2 != 1) {
-                        return false;
-                    }
-                }
-                return true;
-            }
-        }
-        return false;
     }
 
     /**

Modified: sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/AbstractCoordinateOperation.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/AbstractCoordinateOperation.java?rev=1675576&r1=1675575&r2=1675576&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/AbstractCoordinateOperation.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/AbstractCoordinateOperation.java
[UTF-8] Thu Apr 23 11:33:39 2015
@@ -23,7 +23,6 @@ import org.opengis.util.InternationalStr
 import org.opengis.metadata.extent.Extent;
 import org.opengis.metadata.quality.PositionalAccuracy;
 import org.opengis.referencing.crs.CoordinateReferenceSystem;
-import org.opengis.referencing.operation.Conversion;
 import org.opengis.referencing.operation.CoordinateOperation;
 import org.opengis.referencing.operation.OperationMethod;
 import org.opengis.referencing.operation.MathTransform;
@@ -141,14 +140,12 @@ public class AbstractCoordinateOperation
     private final MathTransform transform;
 
     /**
-     * Constructs a new coordinate operation with the same values than the specified
-     * defining conversion, together with the specified source and target CRS.
-     * This constructor is used by {@link DefaultConversion} only.
+     * Constructs a new coordinate operation with the same values than the specified defining
conversion,
+     * together with the specified source and target CRS. This constructor is used by {@link
DefaultConversion} only.
      */
-    AbstractCoordinateOperation(final Conversion               definition,
+    AbstractCoordinateOperation(final CoordinateOperation       definition,
                                 final CoordinateReferenceSystem sourceCRS,
-                                final CoordinateReferenceSystem targetCRS,
-                                final MathTransform             transform)
+                                final CoordinateReferenceSystem targetCRS)
     {
         super(definition);
         this.sourceCRS                   = sourceCRS;
@@ -158,7 +155,7 @@ public class AbstractCoordinateOperation
         this.coordinateOperationAccuracy = definition.getCoordinateOperationAccuracy();
         this.domainOfValidity            = definition.getDomainOfValidity();
         this.scope                       = definition.getScope();
-        this.transform                   = transform;
+        this.transform                   = definition.getMathTransform();
     }
 
     /**

Modified: sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/AbstractSingleOperation.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/AbstractSingleOperation.java?rev=1675576&r1=1675575&r2=1675576&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/AbstractSingleOperation.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/AbstractSingleOperation.java
[UTF-8] Thu Apr 23 11:33:39 2015
@@ -19,13 +19,17 @@ package org.apache.sis.referencing.opera
 import java.util.Map;
 import org.opengis.parameter.ParameterValueGroup;
 import org.opengis.parameter.ParameterDescriptorGroup;
+import org.opengis.referencing.operation.Matrix;
 import org.opengis.referencing.operation.SingleOperation;
 import org.opengis.referencing.operation.OperationMethod;
 import org.opengis.referencing.operation.MathTransform;
 import org.opengis.referencing.crs.CoordinateReferenceSystem;
-import org.apache.sis.internal.referencing.OperationMethods;
 import org.apache.sis.parameter.Parameterized;
+import org.apache.sis.referencing.operation.transform.MathTransforms;
+import org.apache.sis.referencing.operation.transform.PassThroughTransform;
+import org.apache.sis.internal.referencing.OperationMethods;
 import org.apache.sis.util.collection.Containers;
+import org.apache.sis.util.resources.Errors;
 import org.apache.sis.util.ArgumentChecks;
 import org.apache.sis.util.ComparisonMode;
 
@@ -75,18 +79,143 @@ class AbstractSingleOperation extends Ab
         ArgumentChecks.ensureNonNull("targetCRS", targetCRS);
         ArgumentChecks.ensureNonNull("method",    method);
         ArgumentChecks.ensureNonNull("transform", transform);
+        checkDimensions(method, transform, properties);
         this.method = method;
         /*
-         * Undocumented property. We do not document it because parameters are usually either
inferred from
-         * the MathTransform, or specified explicitely in a DefiningConversion. However there
is a few cases,
-         * for example the Molodenski transform, where none of the above can apply, because
the operation is
-         * implemented by a concatenation of math transforms, and concatenations do not have
ParameterValueGroup.
+         * Undocumented property, because SIS usually infers the parameters from the MathTransform.
+         * However there is a few cases, for example the Molodenski transform, where we can
not infer the
+         * parameters easily because the operation is implemented by a concatenation of math
transforms.
          */
         parameters = Containers.property(properties, OperationMethods.PARAMETERS_KEY, ParameterValueGroup.class);
         // No clone since this is a SIS internal property and SIS does not modify those values
after construction.
     }
 
     /**
+     * Creates a defining conversion. This is for {@link DefaultConversion} constructor only.
+     */
+    AbstractSingleOperation(final Map<String,?>   properties,
+                            final OperationMethod method,
+                            final MathTransform   transform)
+    {
+        super(properties, null, null, null, transform);
+        ArgumentChecks.ensureNonNull("method",    method);
+        ArgumentChecks.ensureNonNull("transform", transform);
+        checkDimensions(method, transform, properties);
+        this.method = method;
+        parameters = Containers.property(properties, OperationMethods.PARAMETERS_KEY, ParameterValueGroup.class);
+    }
+
+    /**
+     * Constructs a new operation with the same values than the specified one, together with
the
+     * specified source and target CRS. While the source operation can be an arbitrary one,
it is
+     * typically a defining conversion.
+     */
+    AbstractSingleOperation(final SingleOperation           definition,
+                            final CoordinateReferenceSystem sourceCRS,
+                            final CoordinateReferenceSystem targetCRS)
+    {
+        super(definition, sourceCRS, targetCRS);
+        method = definition.getMethod();
+        parameters = (definition instanceof AbstractSingleOperation) ?
+                ((AbstractSingleOperation) definition).parameters : definition.getParameterValues();
+    }
+
+    /**
+     * Checks if an operation method and a math transform have a compatible number of source
and target dimensions.
+     * In the particular case of a {@linkplain PassThroughTransform pass through transform}
with more dimensions
+     * than what we would expect from the given method, the check will rather be performed
against the
+     * {@linkplain PassThroughTransform#getSubTransform() sub transform}.
+     *
+     * <p>The intend is to allow creation of a three-dimensional {@code ProjectedCRS}
with a two-dimensional
+     * {@code OperationMethod}, where the third-dimension just pass through. This is not
a recommended approach
+     * and we do not document that as a supported feature, but we do not prevent it neither.</p>
+     *
+     * <p>This method tries to locates what seems to be the "core" of the given math
transform. The definition
+     * of "core" is imprecise and may be adjusted in future SIS versions. The current algorithm
is as below:</p>
+     *
+     * <ul>
+     *   <li>If the given transform can be decomposed in {@linkplain MathTransforms#getSteps(MathTransform)
steps},
+     *       then the steps for {@linkplain org.apache.sis.referencing.cs.CoordinateSystems#swapAndScaleAxes
axis
+     *       swapping and scaling} are ignored.</li>
+     *   <li>If the given transform or its non-ignorable step is a {@link PassThroughTransform},
then its sub-transform
+     *       is taken. Only one non-ignorable step may exist, otherwise we do not try to
select any of them.</li>
+     * </ul>
+     *
+     * @param  method     The operation method to compare to the math transform.
+     * @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,
+            final Map<String,?> properties) throws IllegalArgumentException
+    {
+        int actual = transform.getSourceDimensions();
+        Integer expected = method.getSourceDimensions();
+        if (expected != null && actual > expected) {
+            /*
+             * The given MathTransform use more dimensions than the OperationMethod.
+             * Try to locate one and only one sub-transform, ignoring axis swapping and scaling.
+             */
+            MathTransform subTransform = null;
+            for (final MathTransform step : MathTransforms.getSteps(transform)) {
+                if (!isIgnorable(step)) {
+                    if (subTransform == null && step instanceof PassThroughTransform)
{
+                        subTransform = ((PassThroughTransform) step).getSubTransform();
+                    } else {
+                        subTransform = null;
+                        break;
+                    }
+                }
+            }
+            if (subTransform != null) {
+                transform = subTransform;
+                actual = transform.getSourceDimensions();
+            }
+        }
+        /*
+         * Now verify if the MathTransform dimensions are equal to the OperationMethod ones,
+         * ignoring null java.lang.Integer instances.
+         */
+        byte isTarget = 0; // false: wrong dimension is the source one.
+        if (expected == null || actual == expected) {
+            actual = transform.getTargetDimensions();
+            expected = method.getTargetDimensions();
+            if (expected == null || actual == expected) {
+                return;
+            }
+            isTarget = 1; // true: wrong dimension is the target one.
+        }
+        throw new IllegalArgumentException(Errors.getResources(properties).getString(
+                Errors.Keys.MismatchedTransformDimension_3, isTarget, expected, actual));
+    }
+
+    /**
+     * Returns {@code true} if the specified transform is likely to exists only for axis
swapping
+     * and/or unit conversions. The heuristic rule checks if the transform is backed by a
square
+     * matrix with exactly one non-null value in each row and each column.
+     */
+    private static boolean isIgnorable(final MathTransform transform) {
+        final Matrix matrix = MathTransforms.getMatrix(transform);
+        if (matrix != null) {
+            final int size = matrix.getNumRow();
+            if (matrix.getNumCol() == size) {
+                for (int j=0; j<size; j++) {
+                    int n1=0, n2=0;
+                    for (int i=0; i<size; i++) {
+                        if (matrix.getElement(j,i) != 0) n1++;
+                        if (matrix.getElement(i,j) != 0) n2++;
+                    }
+                    if (n1 != 1 || n2 != 1) {
+                        return false;
+                    }
+                }
+                return true;
+            }
+        }
+        return false;
+    }
+
+    /**
      * Returns the operation method.
      *
      * @return The operation method.

Modified: sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/DefaultConversion.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/DefaultConversion.java?rev=1675576&r1=1675575&r2=1675576&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/DefaultConversion.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/DefaultConversion.java
[UTF-8] Thu Apr 23 11:33:39 2015
@@ -34,6 +34,15 @@ import org.opengis.referencing.crs.Coord
  * {@linkplain #getMathTransform() math transform}. Subclasses may have to override the {@link
#getParameterValues()}
  * method if they need to provide a different set of parameters.</p>
  *
+ * <div class="section">Defining conversions</div>
+ * {@code OperationMethod} instances are generally created for a pair of existing {@linkplain
#getSourceCRS() source}
+ * and {@linkplain #getTargetCRS() target CRS}. But {@code Conversion} instances without
those information may exist
+ * temporarily while creating a {@linkplain org.apache.sis.referencing.crs.DefaultDerivedCRS
derived} or
+ * {@linkplain org.apache.sis.referencing.crs.DefaultProjectedCRS projected CRS}.
+ * Those <cite>defining conversions</cite> have no source and target CRS since
those elements are created by the
+ * derived or projected CRS themselves. This class provides a {@linkplain #DefaultConversion(Map,
OperationMethod,
+ * MathTransform) constructor} for such defining conversions.
+ *
  * <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)
  * given to the constructor are also immutable. Most SIS subclasses and related classes are
immutable under similar
@@ -103,6 +112,43 @@ public class DefaultConversion extends A
     }
 
     /**
+     * Creates a defining conversion from the given transform.
+     * This conversion has no source and target CRS since those elements will be created
by the
+     * {@linkplain org.apache.sis.referencing.crs.DefaultDerivedCRS derived} or
+     * {@linkplain org.apache.sis.referencing.crs.DefaultProjectedCRS projected CRS}.
+     *
+     * <p>The properties given in argument follow the same rules than for the
+     * {@linkplain AbstractCoordinateOperation#AbstractCoordinateOperation(Map, CoordinateReferenceSystem,
+     * CoordinateReferenceSystem, CoordinateReferenceSystem, MathTransform) super-class constructor}.</p>
+     *
+     * @param properties The properties to be given to the identified object.
+     * @param method     The operation method.
+     * @param transform  Transform from positions in the source CRS to positions in the target
CRS.
+     */
+    public DefaultConversion(final Map<String,?>   properties,
+                             final OperationMethod method,
+                             final MathTransform   transform)
+    {
+        super(properties, method, transform);
+    }
+
+    /**
+     * Constructs a new conversion with the same values than the specified one, together
with the
+     * specified source and target CRS. While the source conversion can be an arbitrary one,
it is
+     * typically a defining conversion.
+     *
+     * @param definition The defining conversion.
+     * @param sourceCRS  The source CRS.
+     * @param targetCRS  The target CRS.
+     */
+    DefaultConversion(final Conversion                definition,
+                      final CoordinateReferenceSystem sourceCRS,
+                      final CoordinateReferenceSystem targetCRS)
+    {
+        super(definition, sourceCRS, targetCRS);
+    }
+
+    /**
      * Returns the GeoAPI interface implemented by this class.
      * The default implementation returns {@code Conversion.class}.
      * Subclasses implementing a more specific GeoAPI interface shall override this method.

Added: sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/DefaultProjection.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/DefaultProjection.java?rev=1675576&view=auto
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/DefaultProjection.java
(added)
+++ sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/DefaultProjection.java
[UTF-8] Thu Apr 23 11:33:39 2015
@@ -0,0 +1,80 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.sis.referencing.operation;
+
+import org.opengis.referencing.operation.Conversion;
+import org.opengis.referencing.operation.Projection;
+import org.opengis.referencing.crs.CoordinateReferenceSystem;
+
+
+/**
+ * A conversion from (<var>longitude</var>, <var>latitude</var>)
coordinates to Cartesian coordinates
+ * (<var>x</var>,<var>y</var>).
+ *
+ * <p>An unofficial list of projections and their parameters can be found
+ * <a href="http://www.remotesensing.org/geotiff/proj_list/">there</a>.
+ * Most projections expect the following parameters:</p>
+ *
+ * <ul>
+ *   <li>{@code "central_meridian"} (default to 0),
+ *   <li>{@code "latitude_of_origin"} (default to 0),
+ *   <li>{@code "scale_factor"} (default to 1),
+ *   <li>{@code "false_easting"} (default to 0) and
+ *   <li>{@code "false_northing"} (default to 0).
+ * </ul>
+ *
+ * @author  Martin Desruisseaux (IRD, Geomatys)
+ * @since   0.6
+ * @version 0.6
+ * @module
+ *
+ * @see org.apache.sis.referencing.crs.DefaultProjectedCRS
+ */
+class DefaultProjection extends DefaultConversion implements Projection {
+    /**
+     * Serial number for inter-operability with different versions.
+     */
+    private static final long serialVersionUID = -7176751851369816864L;
+
+    /**
+     * Creates a new projection with the same values than the specified one, together with
the
+     * specified source and target CRS. While the source conversion can be an arbitrary one,
it
+     * is typically a defining conversion.
+     *
+     * @param definition The defining conversion.
+     * @param sourceCRS  The source CRS.
+     * @param targetCRS  The target CRS.
+     */
+    public DefaultProjection(final Conversion                definition,
+                             final CoordinateReferenceSystem sourceCRS,
+                             final CoordinateReferenceSystem targetCRS)
+    {
+        super(definition, sourceCRS, targetCRS);
+    }
+
+    /**
+     * Returns the GeoAPI interface implemented by this class.
+     * The default implementation returns {@code Projection.class}.
+     * Subclasses implementing a more specific GeoAPI interface shall override this method.
+     *
+     * @return The conversion interface implemented by this class.
+     */
+    @Override
+    public Class<? extends Projection> getInterface() {
+        return Projection.class;
+    }
+}

Propchange: sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/DefaultProjection.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/DefaultProjection.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain;charset=UTF-8

Modified: sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/package-info.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/package-info.java?rev=1675576&r1=1675575&r2=1675576&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/package-info.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/package-info.java
[UTF-8] Thu Apr 23 11:33:39 2015
@@ -16,7 +16,7 @@
  */
 
 /**
- * Relationship between any two {@linkplain org.apache.sis.referencing.crs.AbstractCRS Coordinate
Reference Systems}.
+ * Relationship between any two {@linkplain org.apache.sis.referencing.crs.AbstractCRS Coordinate
Reference Systems} (CRS).
  * An explanation for this package is provided in the {@linkplain org.opengis.referencing.operation
OpenGIS® javadoc}.
  * The remaining discussion on this page is specific to the Apache SIS implementation.
  *

Modified: sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/internal/referencing/OperationMethodsTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/internal/referencing/OperationMethodsTest.java?rev=1675576&r1=1675575&r2=1675576&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/internal/referencing/OperationMethodsTest.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/internal/referencing/OperationMethodsTest.java
[UTF-8] Thu Apr 23 11:33:39 2015
@@ -16,20 +16,10 @@
  */
 package org.apache.sis.internal.referencing;
 
-import java.util.ArrayList;
-import java.util.Collections;
 import java.util.List;
-import java.util.Locale;
-import java.util.Map;
+import java.util.ArrayList;
 import org.opengis.metadata.Identifier;
-import org.opengis.parameter.ParameterDescriptorGroup;
-import org.opengis.referencing.operation.MathTransform;
-import org.opengis.referencing.operation.OperationMethod;
 import org.apache.sis.metadata.iso.ImmutableIdentifier;
-import org.apache.sis.parameter.DefaultParameterDescriptorGroup;
-import org.apache.sis.referencing.operation.DefaultOperationMethod;
-import org.apache.sis.referencing.operation.transform.MathTransformsTest;
-import org.apache.sis.test.DependsOn;
 import org.apache.sis.test.TestCase;
 import org.junit.Test;
 
@@ -41,13 +31,9 @@ import static org.opengis.test.Assert.*;
  *
  * @author  Martin Desruisseaux (Geomatys)
  * @since   0.5
- * @version 0.5
+ * @version 0.6
  * @module
  */
-@DependsOn({
-    MathTransformsTest.class,
-    org.apache.sis.referencing.operation.DefaultOperationMethodTest.class
-})
 public final strictfp class OperationMethodsTest extends TestCase {
     /**
      * Tests {@link OperationMethods#hasCommonIdentifier(Iterable, Iterable)}.
@@ -78,39 +64,4 @@ public final strictfp class OperationMet
         id2.add(new ImmutableIdentifier(null, "EPSG", "9804"));
         assertEquals(Boolean.TRUE, OperationMethods.hasCommonIdentifier(id1, id2));
     }
-
-    /**
-     * Creates a dummy operation method of the given dimensions.
-     */
-    private static OperationMethod createOperationMethod(final int sourceDimension, final
int targetDimension) {
-        final ParameterDescriptorGroup parameters = new DefaultParameterDescriptorGroup(
-                Collections.singletonMap(ParameterDescriptorGroup.NAME_KEY, "Dummy"), 1,
1);
-        return new DefaultOperationMethod(Collections.singletonMap(OperationMethod.NAME_KEY,
parameters.getName()),
-                sourceDimension, targetDimension, parameters);
-    }
-
-    /**
-     * Tests {@link OperationMethods#checkDimensions(OperationMethod, MathTransform, Map)}.
-     */
-    @Test
-    public void testCheckDimensions() {
-        final Map<String,?> properties = Collections.singletonMap(DefaultOperationMethod.LOCALE_KEY,
Locale.ENGLISH);
-        final MathTransform tr = MathTransformsTest.createConcatenateAndPassThrough();
-        OperationMethods.checkDimensions(createOperationMethod(3, 3), tr, properties);
-        OperationMethods.checkDimensions(createOperationMethod(1, 1), tr, properties);
-        try {
-            OperationMethods.checkDimensions(createOperationMethod(2, 2), 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 {
-            OperationMethods.checkDimensions(createOperationMethod(3, 1), tr, properties);
-            fail("MathTransform.targetDimension == 3 shall be considered incompatible.");
-        } catch (IllegalArgumentException e) {
-            // This is the expected exception.
-            assertEquals(e.getMessage(), "The transform has 3 target dimensions, while 1
was expected.");
-        }
-    }
 }

Copied: sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/AbstractSingleOperationTest.java
(from r1675086, sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/internal/referencing/OperationMethodsTest.java)
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/AbstractSingleOperationTest.java?p2=sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/AbstractSingleOperationTest.java&p1=sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/internal/referencing/OperationMethodsTest.java&r1=1675086&r2=1675576&rev=1675576&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/internal/referencing/OperationMethodsTest.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/AbstractSingleOperationTest.java
[UTF-8] Thu Apr 23 11:33:39 2015
@@ -14,20 +14,15 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.apache.sis.internal.referencing;
+package org.apache.sis.referencing.operation;
 
-import java.util.ArrayList;
 import java.util.Collections;
-import java.util.List;
 import java.util.Locale;
 import java.util.Map;
-import org.opengis.metadata.Identifier;
 import org.opengis.parameter.ParameterDescriptorGroup;
 import org.opengis.referencing.operation.MathTransform;
 import org.opengis.referencing.operation.OperationMethod;
-import org.apache.sis.metadata.iso.ImmutableIdentifier;
 import org.apache.sis.parameter.DefaultParameterDescriptorGroup;
-import org.apache.sis.referencing.operation.DefaultOperationMethod;
 import org.apache.sis.referencing.operation.transform.MathTransformsTest;
 import org.apache.sis.test.DependsOn;
 import org.apache.sis.test.TestCase;
@@ -37,48 +32,18 @@ import static org.opengis.test.Assert.*;
 
 
 /**
- * Tests {@link OperationMethods}.
+ * Tests {@link AbstractSingleOperation}.
  *
  * @author  Martin Desruisseaux (Geomatys)
- * @since   0.5
- * @version 0.5
+ * @since   0.6
+ * @version 0.6
  * @module
  */
 @DependsOn({
-    MathTransformsTest.class,
-    org.apache.sis.referencing.operation.DefaultOperationMethodTest.class
+    DefaultOperationMethodTest.class,
+    org.apache.sis.referencing.operation.transform.MathTransformsTest.class
 })
-public final strictfp class OperationMethodsTest extends TestCase {
-    /**
-     * Tests {@link OperationMethods#hasCommonIdentifier(Iterable, Iterable)}.
-     */
-    @Test
-    public void testHasCommonIdentifier() {
-        final List<Identifier> id1 = new ArrayList<>(3);
-        final List<Identifier> id2 = new ArrayList<>(2);
-        assertNull(OperationMethods.hasCommonIdentifier(id1, id2));
-        /*
-         * Add codes for two Operation Methods which are implemented in Apache SIS by the
same class:
-         *
-         *  - EPSG:9804  —  "Mercator (variant A)" (formerly known as "Mercator (1SP)").
-         *  - EPSG:1026  —  "Mercator (Spherical)"
-         *  - GeoTIFF:7  —  "CT_Mercator"
-         */
-        id1.add(new ImmutableIdentifier(null, "EPSG", "9804"));
-        id1.add(new ImmutableIdentifier(null, "EPSG", "1026"));
-        id1.add(new ImmutableIdentifier(null, "GeoTIFF", "7"));
-        assertNull(OperationMethods.hasCommonIdentifier(id1, id2));
-        /*
-         * EPSG:9841 is a legacy (now deprecated) code for "Mercator (1SP)".
-         * We could have declared it as a deprecated code in the above list,
-         * but for the sake of this test we do not.
-         */
-        id2.add(new ImmutableIdentifier(null, "EPSG", "9841"));
-        assertEquals(Boolean.FALSE, OperationMethods.hasCommonIdentifier(id1, id2));
-        id2.add(new ImmutableIdentifier(null, "EPSG", "9804"));
-        assertEquals(Boolean.TRUE, OperationMethods.hasCommonIdentifier(id1, id2));
-    }
-
+public final strictfp class AbstractSingleOperationTest extends TestCase {
     /**
      * Creates a dummy operation method of the given dimensions.
      */
@@ -96,17 +61,17 @@ public final strictfp class OperationMet
     public void testCheckDimensions() {
         final Map<String,?> properties = Collections.singletonMap(DefaultOperationMethod.LOCALE_KEY,
Locale.ENGLISH);
         final MathTransform tr = MathTransformsTest.createConcatenateAndPassThrough();
-        OperationMethods.checkDimensions(createOperationMethod(3, 3), tr, properties);
-        OperationMethods.checkDimensions(createOperationMethod(1, 1), tr, properties);
+        AbstractSingleOperation.checkDimensions(createOperationMethod(3, 3), tr, properties);
+        AbstractSingleOperation.checkDimensions(createOperationMethod(1, 1), tr, properties);
         try {
-            OperationMethods.checkDimensions(createOperationMethod(2, 2), tr, properties);
+            AbstractSingleOperation.checkDimensions(createOperationMethod(2, 2), 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 {
-            OperationMethods.checkDimensions(createOperationMethod(3, 1), tr, properties);
+            AbstractSingleOperation.checkDimensions(createOperationMethod(3, 1), tr, properties);
             fail("MathTransform.targetDimension == 3 shall be considered incompatible.");
         } catch (IllegalArgumentException e) {
             // This is the expected exception.

Modified: sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/test/suite/ReferencingTestSuite.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/test/suite/ReferencingTestSuite.java?rev=1675576&r1=1675575&r2=1675576&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/test/suite/ReferencingTestSuite.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/test/suite/ReferencingTestSuite.java
[UTF-8] Thu Apr 23 11:33:39 2015
@@ -90,6 +90,7 @@ import org.junit.BeforeClass;
     // Registration of map projections and other math transforms.
     org.apache.sis.referencing.operation.DefaultFormulaTest.class,
     org.apache.sis.referencing.operation.DefaultOperationMethodTest.class,
+    org.apache.sis.referencing.operation.AbstractSingleOperationTest.class,
     org.apache.sis.referencing.operation.transform.OperationMethodSetTest.class,
     org.apache.sis.internal.referencing.OperationMethodsTest.class,
     org.apache.sis.internal.referencing.provider.AffineTest.class,



Mime
View raw message