sis-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From desruisse...@apache.org
Subject svn commit: r1661575 [3/4] - in /sis/branches/JDK6: ./ core/sis-metadata/src/main/java/org/apache/sis/internal/metadata/ core/sis-metadata/src/main/java/org/apache/sis/io/wkt/ core/sis-metadata/src/main/java/org/apache/sis/metadata/ core/sis-metadata/s...
Date Sun, 22 Feb 2015 23:02:54 GMT
Modified: sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/AbstractMathTransform.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/AbstractMathTransform.java?rev=1661575&r1=1661574&r2=1661575&view=diff
==============================================================================
--- sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/AbstractMathTransform.java [UTF-8] (original)
+++ sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/AbstractMathTransform.java [UTF-8] Sun Feb 22 23:02:52 2015
@@ -81,6 +81,8 @@ import static org.apache.sis.util.Argume
  * @since   0.5
  * @version 0.5
  * @module
+ *
+ * @see DefaultMathTransformFactory
  */
 public abstract class AbstractMathTransform extends FormattableObject
         implements MathTransform, Parameterized, LenientComparable
@@ -130,6 +132,8 @@ public abstract class AbstractMathTransf
      * Gets the dimension of input points.
      *
      * @return The dimension of input points.
+     *
+     * @see org.apache.sis.referencing.operation.DefaultOperationMethod#getSourceDimensions()
      */
     @Override
     public abstract int getSourceDimensions();
@@ -138,6 +142,8 @@ public abstract class AbstractMathTransf
      * Gets the dimension of output points.
      *
      * @return The dimension of output points.
+     *
+     * @see org.apache.sis.referencing.operation.DefaultOperationMethod#getTargetDimensions()
      */
     @Override
     public abstract int getTargetDimensions();
@@ -145,11 +151,11 @@ public abstract class AbstractMathTransf
     /**
      * Returns the parameter descriptors for this math transform, or {@code null} if unknown.
      *
-     * <span class="note"><b>Relationship with ISO 19111:</b>
+     * <div class="note"><b>Relationship with ISO 19111:</b>
      * This method is similar to {@link OperationMethod#getParameters()}, except that typical
      * {@link MathTransform} implementations return parameters in standard units (usually
      * {@linkplain SI#METRE metres} or {@linkplain NonSI#DEGREE_ANGLE decimal degrees}).
-     * </span>
+     * </div>
      *
      * @return The parameter descriptors for this math transform, or {@code null}.
      *
@@ -165,11 +171,11 @@ public abstract class AbstractMathTransf
      * Since this method returns a copy of the parameter values, any change to a value will have no
      * effect on this math transform.
      *
-     * <span class="note"><b>Relationship with ISO 19111:</b>
+     * <div class="note"><b>Relationship with ISO 19111:</b>
      * This method is similar to {@link SingleOperation#getParameterValues()}, except that typical
      * {@link MathTransform} implementations return parameters in standard units (usually
      * {@linkplain SI#METRE metres} or {@linkplain NonSI#DEGREE_ANGLE decimal degrees}).
-     * </span>
+     * </div>
      *
      * @return A copy of the parameter values for this math transform, or {@code null}.
      *

Modified: sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/ConcatenatedTransform.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/ConcatenatedTransform.java?rev=1661575&r1=1661574&r2=1661575&view=diff
==============================================================================
--- sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/ConcatenatedTransform.java [UTF-8] (original)
+++ sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/ConcatenatedTransform.java [UTF-8] Sun Feb 22 23:02:52 2015
@@ -856,11 +856,11 @@ class ConcatenatedTransform extends Abst
      * Tests whether this transform does not move any points.
      * Implementation checks if the two transforms are identity.
      *
-     * <span class="note"><b>Note:</b> this method should always returns {@code false}, since
+     * <div class="note"><b>Note:</b> this method should always returns {@code false}, since
      * {@code create(…)} should have created specialized implementations for identity cases.
      * Nevertheless we perform the full check as a safety, in case someone instantiated this
      * class directly instead than using a factory method, or in case the given math transforms
-     * are mutable (they should not, be we can not control what the user gave to us).</span>
+     * are mutable (they should not, be we can not control what the user gave to us).</div>
      */
     @Override
     public boolean isIdentity() {

Modified: sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/CopyTransform.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/CopyTransform.java?rev=1661575&r1=1661574&r2=1661575&view=diff
==============================================================================
--- sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/CopyTransform.java [UTF-8] (original)
+++ sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/CopyTransform.java [UTF-8] Sun Feb 22 23:02:52 2015
@@ -24,7 +24,6 @@ import org.opengis.referencing.operation
 import org.opengis.referencing.operation.NoninvertibleTransformException;
 import org.opengis.parameter.ParameterValueGroup;
 import org.opengis.parameter.ParameterDescriptorGroup;
-import org.apache.sis.parameter.TensorParameters;
 import org.apache.sis.internal.referencing.provider.Affine;
 import org.apache.sis.referencing.operation.matrix.MatrixSIS;
 import org.apache.sis.referencing.operation.matrix.Matrices;
@@ -142,10 +141,10 @@ final class CopyTransform extends Abstra
     /**
      * Tests whether this transform does not move any points.
      *
-     * <span class="note"><b>Note:</b> this method should always returns {@code false}, since
+     * <div class="note"><b>Note:</b> this method should always returns {@code false}, since
      * {@code MathTransforms.linear(…)} should have created specialized implementations for identity cases.
      * Nevertheless we perform the full check as a safety, in case someone instantiated this class directly
-     * instead than using a factory method.</span>
+     * instead than using a factory method.</div>
      */
     @Override
     public boolean isIdentity() {
@@ -310,7 +309,7 @@ final class CopyTransform extends Abstra
      */
     @Override
     public ParameterDescriptorGroup getParameterDescriptors() {
-        return Affine.PARAMETERS;
+        return Affine.getProvider(srcDim, getTargetDimensions(), true).getParameters();
     }
 
     /**
@@ -318,7 +317,7 @@ final class CopyTransform extends Abstra
      */
     @Override
     public ParameterValueGroup getParameterValues() {
-        return TensorParameters.WKT1.createValueGroup(Affine.IDENTIFICATION, getMatrix());
+        return Affine.parameters(getMatrix());
     }
 
     /**

Copied: sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/DefaultMathTransformFactory.java (from r1661574, sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/DefaultMathTransformFactory.java)
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/DefaultMathTransformFactory.java?p2=sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/DefaultMathTransformFactory.java&p1=sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/DefaultMathTransformFactory.java&r1=1661574&r2=1661575&rev=1661575&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/DefaultMathTransformFactory.java [UTF-8] (original)
+++ sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/DefaultMathTransformFactory.java [UTF-8] Sun Feb 22 23:02:52 2015
@@ -262,10 +262,10 @@ public class DefaultMathTransformFactory
     public DefaultMathTransformFactory(final Iterable<? extends OperationMethod> methods) {
         ArgumentChecks.ensureNonNull("methods", methods);
         this.methods  = methods;
-        methodsByName = new ConcurrentHashMap<>();
-        methodsByType = new IdentityHashMap<>();
-        lastMethod    = new ThreadLocal<>();
-        pool          = new WeakHashSet<>(MathTransform.class);
+        methodsByName = new ConcurrentHashMap<String, OperationMethod>();
+        methodsByType = new IdentityHashMap<Class<?>, OperationMethodSet>();
+        lastMethod    = new ThreadLocal<OperationMethod>();
+        pool          = new WeakHashSet<MathTransform>(MathTransform.class);
     }
 
     /**
@@ -523,7 +523,7 @@ public class DefaultMathTransformFactory
                     mismatchedParam = semiMinor;
                     mismatchedValue = b;
                 }
-            } catch (IllegalArgumentException | IllegalStateException e) {
+            } catch (IllegalArgumentException e) {
                 /*
                  * Parameter not found, or is not numeric, or unit of measurement is not linear.
                  * Those exceptions should never occur with map projections, but may happen for
@@ -538,6 +538,8 @@ public class DefaultMathTransformFactory
                  *    "tgt_semi_major" and "tgt_semi_minor" parameters anyway.
                  */
                 failure = e;
+            } catch (IllegalStateException e) {
+                failure = e;
             }
             if (mismatchedParam != null) {
                 Logging.log(DefaultMathTransformFactory.class, "createBaseToDerived",
@@ -554,7 +556,7 @@ public class DefaultMathTransformFactory
             lastMethod.set(method);
         } catch (FactoryException e) {
             if (failure != null) {
-                e.addSuppressed(failure);
+                // e.addSuppressed(failure) on the JDK7 branch.
             }
             throw e;
         }
@@ -601,7 +603,9 @@ public class DefaultMathTransformFactory
         try {
             swap1 = CoordinateSystems.swapAndScaleAxes(baseCS, CoordinateSystems.normalize(baseCS));
             swap3 = CoordinateSystems.swapAndScaleAxes(CoordinateSystems.normalize(derivedCS), derivedCS);
-        } catch (IllegalArgumentException | ConversionException cause) {
+        } catch (IllegalArgumentException cause) {
+            throw new FactoryException(cause);
+        } catch (ConversionException cause) {
             throw new FactoryException(cause);
         }
         /*
@@ -706,13 +710,15 @@ public class DefaultMathTransformFactory
                     parameters = copy;
                 }
                 transform  = ((MathTransformProvider) method).createMathTransform(parameters);
-            } catch (IllegalArgumentException | IllegalStateException exception) {
+            } catch (IllegalArgumentException exception) {
                 /*
                  * Catch only exceptions which may be the result of improper parameter
                  * usage (e.g. a value out of range). Do not catch exception caused by
                  * programming errors (e.g. null pointer exception).
                  */
                 throw new FactoryException(exception);
+            } catch (IllegalStateException exception) {
+                throw new FactoryException(exception);
             }
             transform = pool.unique(transform);
             method = DefaultOperationMethod.redimension(method,

Modified: sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/IdentityTransform.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/IdentityTransform.java?rev=1661575&r1=1661574&r2=1661575&view=diff
==============================================================================
--- sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/IdentityTransform.java [UTF-8] (original)
+++ sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/IdentityTransform.java [UTF-8] Sun Feb 22 23:02:52 2015
@@ -25,7 +25,6 @@ import org.opengis.referencing.operation
 import org.apache.sis.util.ArgumentChecks;
 import org.apache.sis.util.ComparisonMode;
 import org.apache.sis.geometry.GeneralDirectPosition;
-import org.apache.sis.parameter.TensorParameters;
 import org.apache.sis.internal.referencing.provider.Affine;
 import org.apache.sis.referencing.operation.matrix.Matrices;
 import org.apache.sis.internal.referencing.j2d.AffineTransform2D;
@@ -134,7 +133,7 @@ final class IdentityTransform extends Ab
      */
     @Override
     public ParameterDescriptorGroup getParameterDescriptors() {
-        return Affine.PARAMETERS;
+        return Affine.getProvider(dimension, dimension, true).getParameters();
     }
 
     /**
@@ -144,7 +143,7 @@ final class IdentityTransform extends Ab
      */
     @Override
     public ParameterValueGroup getParameterValues() {
-        return TensorParameters.WKT1.createValueGroup(Affine.IDENTIFICATION, getMatrix());
+        return Affine.parameters(getMatrix());
     }
 
     /**

Modified: sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/LinearTransform1D.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/LinearTransform1D.java?rev=1661575&r1=1661574&r2=1661575&view=diff
==============================================================================
--- sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/LinearTransform1D.java [UTF-8] (original)
+++ sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/LinearTransform1D.java [UTF-8] Sun Feb 22 23:02:52 2015
@@ -28,7 +28,6 @@ import org.apache.sis.referencing.operat
 import org.apache.sis.referencing.operation.matrix.Matrix1;
 import org.apache.sis.referencing.operation.matrix.Matrix2;
 import org.apache.sis.internal.referencing.provider.Affine;
-import org.apache.sis.parameter.TensorParameters;
 import org.apache.sis.internal.util.Numerics;
 import org.apache.sis.util.ComparisonMode;
 
@@ -116,7 +115,7 @@ class LinearTransform1D extends Abstract
      */
     @Override
     public ParameterDescriptorGroup getParameterDescriptors() {
-        return Affine.PARAMETERS;
+        return Affine.getProvider(1, 1, true).getParameters();
     }
 
     /**
@@ -128,7 +127,7 @@ class LinearTransform1D extends Abstract
      */
     @Override
     public ParameterValueGroup getParameterValues() {
-        return TensorParameters.WKT1.createValueGroup(Affine.IDENTIFICATION, getMatrix());
+        return Affine.parameters(getMatrix());
     }
 
     /**
@@ -168,10 +167,10 @@ class LinearTransform1D extends Abstract
     /**
      * Tests whether this transform does not move any points.
      *
-     * <span class="note"><b>Note:</b> this method should always returns {@code false}, since
+     * <div class="note"><b>Note:</b> this method should always returns {@code false}, since
      * {@code MathTransforms.linear(…)} should have created specialized implementations for identity cases.
      * Nevertheless we perform the full check as a safety, in case someone instantiated this class directly
-     * instead than using a factory method.</span>
+     * instead than using a factory method.</div>
      */
     @Override
     public boolean isIdentity() {

Modified: sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/LogarithmicTransform1D.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/LogarithmicTransform1D.java?rev=1661575&r1=1661574&r2=1661575&view=diff
==============================================================================
--- sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/LogarithmicTransform1D.java [UTF-8] (original)
+++ sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/LogarithmicTransform1D.java [UTF-8] Sun Feb 22 23:02:52 2015
@@ -285,10 +285,10 @@ class LogarithmicTransform1D extends Abs
         /**
          * The offset to add to the logarithm.
          *
-         * <span class="note"><b>Note:</b> the offset could be handled by a concatenation with {@link LinearTransform1D}.
+         * <div class="note"><b>Note:</b> the offset could be handled by a concatenation with {@link LinearTransform1D}.
          * instead than an explicit field in this class. However the <var>offset</var> + log<sub>base</sub>(<var>x</var>)
          * formula is extensively used as a <cite>transfer function</cite> in grid coverages. Consequently we keep this
-         * explicit field for performance reasons.</span>
+         * explicit field for performance reasons.</div>
          */
         private final double offset;
 

Modified: sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/MathTransforms.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/MathTransforms.java?rev=1661575&r1=1661574&r2=1661575&view=diff
==============================================================================
--- sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/MathTransforms.java [UTF-8] (original)
+++ sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/MathTransforms.java [UTF-8] Sun Feb 22 23:02:52 2015
@@ -109,7 +109,7 @@ public final class MathTransforms extend
      * @return The linear (usually affine) transform.
      *
      * @see #getMatrix(MathTransform)
-     * @see org.opengis.referencing.operation.MathTransformFactory#createAffineTransform(Matrix)
+     * @see DefaultMathTransformFactory#createAffineTransform(Matrix)
      */
     public static LinearTransform linear(final Matrix matrix) {
         ensureNonNull("matrix", matrix);
@@ -157,7 +157,7 @@ public final class MathTransforms extend
      * @throws MismatchedDimensionException if the output dimension of the first transform
      *         does not match the input dimension of the second transform.
      *
-     * @see MathTransformFactory#createConcatenatedTransform(MathTransform, MathTransform)
+     * @see DefaultMathTransformFactory#createConcatenatedTransform(MathTransform, MathTransform)
      */
     public static MathTransform concatenate(final MathTransform tr1, final MathTransform tr2)
             throws MismatchedDimensionException

Copied: sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/OperationMethodSet.java (from r1661574, sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/OperationMethodSet.java)
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/OperationMethodSet.java?p2=sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/OperationMethodSet.java&p1=sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/OperationMethodSet.java&r1=1661574&r2=1661575&rev=1661575&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/OperationMethodSet.java [UTF-8] (original)
+++ sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/OperationMethodSet.java [UTF-8] Sun Feb 22 23:02:52 2015
@@ -81,7 +81,7 @@ final class OperationMethodSet extends A
     {
         this.type = type;
         this.methods = methods;
-        cachedMethods = new ArrayList<>();
+        cachedMethods = new ArrayList<OperationMethod>();
         reset();
     }
 

Modified: sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/ProjectiveTransform.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/ProjectiveTransform.java?rev=1661575&r1=1661574&r2=1661575&view=diff
==============================================================================
--- sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/ProjectiveTransform.java [UTF-8] (original)
+++ sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/ProjectiveTransform.java [UTF-8] Sun Feb 22 23:02:52 2015
@@ -25,7 +25,6 @@ import org.opengis.referencing.operation
 import org.opengis.referencing.operation.MathTransform;
 import org.opengis.referencing.operation.NoninvertibleTransformException;
 import org.apache.sis.util.ComparisonMode;
-import org.apache.sis.parameter.TensorParameters;
 import org.apache.sis.referencing.operation.matrix.Matrices;
 import org.apache.sis.referencing.operation.matrix.MatrixSIS;
 import org.apache.sis.internal.referencing.ExtendedPrecisionMatrix;
@@ -152,7 +151,7 @@ class ProjectiveTransform extends Abstra
      */
     @Override
     public ParameterDescriptorGroup getParameterDescriptors() {
-        return Affine.PARAMETERS;
+        return Affine.getProvider(getSourceDimensions(), getTargetDimensions(), Matrices.isAffine(this)).getParameters();
     }
 
     /**
@@ -163,7 +162,7 @@ class ProjectiveTransform extends Abstra
      */
     @Override
     public ParameterValueGroup getParameterValues() {
-        return TensorParameters.WKT1.createValueGroup(Affine.IDENTIFICATION, getMatrix());
+        return Affine.parameters(this);
     }
 
     /**
@@ -205,10 +204,10 @@ class ProjectiveTransform extends Abstra
     /**
      * Tests whether this transform does not move any points.
      *
-     * <span class="note"><b>Note:</b> this method should always returns {@code false}, since
+     * <div class="note"><b>Note:</b> this method should always returns {@code false}, since
      * {@code MathTransforms.linear(…)} should have created specialized implementations for identity cases.
      * Nevertheless we perform the full check as a safety, in case someone instantiated this class directly
-     * instead than using a factory method.</span>
+     * instead than using a factory method.</div>
      */
     @Override
     public boolean isIdentity() {

Modified: sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/package-info.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/package-info.java?rev=1661575&r1=1661574&r2=1661575&view=diff
==============================================================================
--- sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/package-info.java [UTF-8] (original)
+++ sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/package-info.java [UTF-8] Sun Feb 22 23:02:52 2015
@@ -37,6 +37,18 @@
  * <p>This package does not include map projections, which are a special kind of transforms defined
  * in their own {@linkplain org.apache.sis.referencing.operation.projection projection} package.</p>
  *
+ *
+ * {@section Creating math transforms}
+ * {@code MathTransform} instances can be created either directly or indirectly.
+ * The recommended way is the indirect one: first
+ * {@linkplain org.apache.sis.referencing.CRS#findOperation find the coordinate operation}
+ * (generally from a pair of <var>source</var> and <var>target</var> CRS), then invoke
+ * {@link org.opengis.referencing.operation.CoordinateOperation#getMathTransform()}.
+ * However sophisticated users can also create math transforms explicitely from a group of parameter values
+ * using the {@linkplain org.apache.sis.referencing.operation.transform.DefaultMathTransformFactory math
+ * transform factory}.
+ *
+ *
  * {@section Non-spatial coordinates}
  * {@code MathTransform} usually performs conversions or transformations from points given in a
  * {@linkplain org.apache.sis.referencing.operation.DefaultCoordinateOperation#getSourceCRS()
@@ -48,8 +60,9 @@
  * transfer functions}.
  *
  * @author  Martin Desruisseaux (IRD, Geomatys)
+ * @author  Adrian Custer (Geomatys)
  * @since   0.5
- * @version 0.5
+ * @version 0.6
  * @module
  */
 package org.apache.sis.referencing.operation.transform;

Modified: sis/branches/JDK6/core/sis-referencing/src/test/java/org/apache/sis/parameter/DefaultParameterDescriptorGroupTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/core/sis-referencing/src/test/java/org/apache/sis/parameter/DefaultParameterDescriptorGroupTest.java?rev=1661575&r1=1661574&r2=1661575&view=diff
==============================================================================
--- sis/branches/JDK6/core/sis-referencing/src/test/java/org/apache/sis/parameter/DefaultParameterDescriptorGroupTest.java [UTF-8] (original)
+++ sis/branches/JDK6/core/sis-referencing/src/test/java/org/apache/sis/parameter/DefaultParameterDescriptorGroupTest.java [UTF-8] Sun Feb 22 23:02:52 2015
@@ -19,10 +19,13 @@ package org.apache.sis.parameter;
 import java.util.Map;
 import java.util.List;
 import java.util.HashMap;
+import java.util.Collections;
 import org.opengis.parameter.ParameterDirection;
 import org.opengis.parameter.GeneralParameterDescriptor;
 import org.opengis.parameter.ParameterNotFoundException;
+import org.apache.sis.internal.util.Constants;
 import org.apache.sis.test.DependsOn;
+import org.apache.sis.test.DependsOnMethod;
 import org.apache.sis.test.TestCase;
 import org.junit.Test;
 
@@ -38,7 +41,7 @@ import static org.opengis.referencing.Id
  * @author  Martin Desruisseaux (IRD, Geomatys)
  * @author  Johann Sorel (Geomatys)
  * @since   0.4
- * @version 0.5
+ * @version 0.6
  * @module
  */
 @DependsOn(DefaultParameterDescriptorTest.class)
@@ -182,6 +185,33 @@ public final strictfp class DefaultParam
     }
 
     /**
+     * Tests WKT formatting of a group with a parameter having an identifier.
+     *
+     * @see DefaultParameterDescriptorTest#testIdentifiedParameterWKT()
+     *
+     * @since 0.6
+     */
+    @Test
+    @DependsOnMethod("testWKT")
+    public void testIdentifiedParameterWKT() {
+        /*
+         * Test below is identical to DefaultParameterDescriptorTest.testIdentifiedParameterWKT(),
+         * but is reproduced here for easier comparison with the test following it.
+         */
+        final DefaultParameterDescriptor<Double> descriptor = DefaultParameterDescriptorTest.createEPSG("A0", Constants.A0);
+        assertWktEquals("Parameter[“A0”, Id[“EPSG”, 8623, Citation[“OGP”], URI[“urn:ogc:def:parameter:EPSG::8623”]]]", descriptor);
+        /*
+         * When the parameter is part of a larger element, we expect a simplification.
+         * Here, the URI should be omitted because it is a long value which does not
+         * bring new information, since it is computed from other values.
+         */
+        final DefaultParameterDescriptorGroup group = new DefaultParameterDescriptorGroup(
+                Collections.singletonMap(NAME_KEY, "Affine"), 1, 1, descriptor);
+        assertWktEquals("ParameterGroup[“Affine”,\n" +
+                        "  Parameter[“A0”, Id[“EPSG”, 8623, Citation[“OGP”]]]]", group);
+    }
+
+    /**
      * Tests {@link DefaultParameterDescriptorGroup} serialization.
      */
     @Test

Modified: sis/branches/JDK6/core/sis-referencing/src/test/java/org/apache/sis/parameter/DefaultParameterDescriptorTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/core/sis-referencing/src/test/java/org/apache/sis/parameter/DefaultParameterDescriptorTest.java?rev=1661575&r1=1661574&r2=1661575&view=diff
==============================================================================
--- sis/branches/JDK6/core/sis-referencing/src/test/java/org/apache/sis/parameter/DefaultParameterDescriptorTest.java [UTF-8] (original)
+++ sis/branches/JDK6/core/sis-referencing/src/test/java/org/apache/sis/parameter/DefaultParameterDescriptorTest.java [UTF-8] Sun Feb 22 23:02:52 2015
@@ -25,6 +25,9 @@ import org.opengis.parameter.ParameterDe
 import org.apache.sis.measure.Range;
 import org.apache.sis.measure.NumberRange;
 import org.apache.sis.measure.MeasurementRange;
+import org.apache.sis.metadata.iso.ImmutableIdentifier;
+import org.apache.sis.metadata.iso.citation.HardCodedCitations;
+import org.apache.sis.internal.util.Constants;
 import org.apache.sis.test.DependsOnMethod;
 import org.apache.sis.test.DependsOn;
 import org.apache.sis.test.TestCase;
@@ -39,7 +42,7 @@ import static org.apache.sis.test.Metada
  *
  * @author  Martin Desruisseaux (IRD, Geomatys)
  * @since   0.4
- * @version 0.4
+ * @version 0.6
  * @module
  */
 @DependsOn(org.apache.sis.referencing.AbstractIdentifiedObjectTest.class)
@@ -135,6 +138,20 @@ public final strictfp class DefaultParam
     }
 
     /**
+     * Creates a descriptor with the given EPSG identifier.
+     *
+     * @param  name The parameter name.
+     * @param  code The parameter identifier.
+     * @return The descriptor with the given EPSG identifier.
+     */
+    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.OGP, Constants.EPSG, Short.toString(code))));
+        return new DefaultParameterDescriptor<Double>(properties, 0, 1, Double.class, null, null, null);
+    }
+
+    /**
      * Tests the creation of a simple descriptor for an optional parameter without minimum or maximum value.
      */
     @Test
@@ -294,4 +311,18 @@ public final strictfp class DefaultParam
         assertWktEquals("Parameter[“Real number”, 5.0, LengthUnit[“metre”, 1]]", descriptor);
         assertEquals("Parameter[\"Real number\", 5.0, Unit[\"metre\", 1]]", descriptor.toString());
     }
+
+    /**
+     * Tests WKT formatting of a parameter having an identifier.
+     *
+     * @see DefaultParameterDescriptorGroupTest#testIdentifiedParameterWKT()
+     *
+     * @since 0.6
+     */
+    @Test
+    @DependsOnMethod("testWKT")
+    public void testIdentifiedParameterWKT() {
+        final DefaultParameterDescriptor<Double> descriptor = createEPSG("A0", Constants.A0);
+        assertWktEquals("Parameter[“A0”, Id[“EPSG”, 8623, Citation[“OGP”], URI[“urn:ogc:def:parameter:EPSG::8623”]]]", descriptor);
+    }
 }

Modified: sis/branches/JDK6/core/sis-referencing/src/test/java/org/apache/sis/parameter/DefaultParameterValueTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/core/sis-referencing/src/test/java/org/apache/sis/parameter/DefaultParameterValueTest.java?rev=1661575&r1=1661574&r2=1661575&view=diff
==============================================================================
--- sis/branches/JDK6/core/sis-referencing/src/test/java/org/apache/sis/parameter/DefaultParameterValueTest.java [UTF-8] (original)
+++ sis/branches/JDK6/core/sis-referencing/src/test/java/org/apache/sis/parameter/DefaultParameterValueTest.java [UTF-8] Sun Feb 22 23:02:52 2015
@@ -24,6 +24,7 @@ import org.opengis.referencing.datum.Ver
 import org.opengis.parameter.ParameterDescriptor;
 import org.opengis.parameter.InvalidParameterTypeException;
 import org.opengis.parameter.InvalidParameterValueException;
+import org.apache.sis.internal.util.Constants;
 import org.apache.sis.io.wkt.Convention;
 import org.apache.sis.test.DependsOnMethod;
 import org.apache.sis.test.DependsOn;
@@ -40,7 +41,7 @@ import static org.apache.sis.test.Metada
  *
  * @author  Martin Desruisseaux (IRD, Geomatys)
  * @since   0.4
- * @version 0.4
+ * @version 0.6
  * @module
  */
 @DependsOn(DefaultParameterDescriptorTest.class)
@@ -600,4 +601,16 @@ public final strictfp class DefaultParam
         assertWktEquals(Convention.WKT2, "Parameter[“Count”, 4]", count);
         assertWktEquals(Convention.WKT2, "Parameter[“Length”, 30.0, LengthUnit[“cm”, 0.01]]", length);
     }
+
+    /**
+     * Tests WKT formatting of a parameter having an identifier.
+     *
+     * @since 0.6
+     */
+    @Test
+    @DependsOnMethod("testWKT")
+    public void testIdentifiedParameterWKT() {
+        final Watcher<Double> parameter = new Watcher<Double>(DefaultParameterDescriptorTest.createEPSG("A0", Constants.A0));
+        assertWktEquals("Parameter[“A0”, null, Id[“EPSG”, 8623, Citation[“OGP”]]]", parameter);
+    }
 }

Modified: sis/branches/JDK6/core/sis-referencing/src/test/java/org/apache/sis/parameter/ParametersTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/core/sis-referencing/src/test/java/org/apache/sis/parameter/ParametersTest.java?rev=1661575&r1=1661574&r2=1661575&view=diff
==============================================================================
--- sis/branches/JDK6/core/sis-referencing/src/test/java/org/apache/sis/parameter/ParametersTest.java [UTF-8] (original)
+++ sis/branches/JDK6/core/sis-referencing/src/test/java/org/apache/sis/parameter/ParametersTest.java [UTF-8] Sun Feb 22 23:02:52 2015
@@ -24,7 +24,6 @@ import org.opengis.parameter.ParameterDi
 import org.opengis.parameter.ParameterValue;
 import org.opengis.parameter.ParameterValueGroup;
 import org.opengis.metadata.Identifier;
-import org.opengis.parameter.GeneralParameterValue;
 import org.opengis.util.GenericName;
 import org.opengis.util.InternationalString;
 import javax.measure.unit.Unit;

Modified: sis/branches/JDK6/core/sis-referencing/src/test/java/org/apache/sis/parameter/TensorParametersTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/core/sis-referencing/src/test/java/org/apache/sis/parameter/TensorParametersTest.java?rev=1661575&r1=1661574&r2=1661575&view=diff
==============================================================================
--- sis/branches/JDK6/core/sis-referencing/src/test/java/org/apache/sis/parameter/TensorParametersTest.java [UTF-8] (original)
+++ sis/branches/JDK6/core/sis-referencing/src/test/java/org/apache/sis/parameter/TensorParametersTest.java [UTF-8] Sun Feb 22 23:02:52 2015
@@ -17,24 +17,23 @@
 package org.apache.sis.parameter;
 
 import java.util.Map;
-import java.util.List;
 import java.util.Random;
 import org.opengis.parameter.ParameterValueGroup;
 import org.opengis.parameter.ParameterDescriptor;
-import org.opengis.parameter.GeneralParameterDescriptor;
 import org.opengis.referencing.operation.Matrix;
 import org.apache.sis.referencing.operation.matrix.Matrices;
 import org.apache.sis.test.TestUtilities;
 import org.apache.sis.test.DependsOnMethod;
 import org.apache.sis.test.DependsOn;
 import org.apache.sis.test.TestCase;
+import org.junit.AfterClass;
 import org.junit.Test;
 
 import static java.util.Collections.singletonMap;
 import static org.opengis.test.Validators.validate;
-import static org.opengis.referencing.IdentifiedObject.NAME_KEY;
-import static org.apache.sis.parameter.TensorParameters.WKT1;
-import static org.apache.sis.test.Assert.*;
+import static org.apache.sis.test.ReferencingAssert.*;
+import static org.apache.sis.internal.util.Constants.NUM_ROW;
+import static org.apache.sis.internal.util.Constants.NUM_COL;
 
 
 /**
@@ -42,19 +41,128 @@ import static org.apache.sis.test.Assert
  *
  * @author  Martin Desruisseaux (Geomatys)
  * @since   0.4
- * @version 0.4
+ * @version 0.6
  * @module
  */
-@DependsOn(ParametersTest.class)
-public final strictfp class TensorParametersTest extends TestCase {
+@DependsOn({
+    DefaultParameterDescriptorTest.class,
+    DefaultParameterValueTest.class,
+    ParametersTest.class
+})
+public strictfp class TensorParametersTest extends TestCase {
     /**
-     * Asserts that the given descriptor has the given name and default value.
+     * The parameters to use for testing purpose. Mostly identical to {@link TensorParameters#WKT1},
+     * except that it is not an instance of the {@link MatrixParameters} subclass. Those parameters
+     * do not contain EPSG aliases and identifiers.
      */
-    static void assertDescriptorEquals(final String name, final Number defaultValue,
-            final GeneralParameterDescriptor actual)
+    private static TensorParameters<Double> WKT1;
+
+    /**
+     * The expected parameter names according the WKT 1 convention for the matrix elements.
+     *
+     * @see MatrixParametersTest#NAMES
+     */
+    static final String[][] ELEMENT_NAMES = {
+        {"elt_0_0", "elt_0_1", "elt_0_2", "elt_0_3"},
+        {"elt_1_0", "elt_1_1", "elt_1_2", "elt_1_3"},
+        {"elt_2_0", "elt_2_1", "elt_2_2", "elt_2_3"},
+        {"elt_3_0", "elt_3_1", "elt_3_2", "elt_3_3"}
+    };
+
+    /**
+     * The instance tested by this class.
+     */
+    final TensorParameters<Double> param;
+
+    /**
+     * The expected parameter names for all matrix elements.
+     * Example: {@link #ELEMENT_NAMES}.
+     */
+    private final String[][] names;
+
+    /**
+     * The expected parameter aliases for all matrix elements, or {@code null} for no alias.
+     * Example: {@link MatrixParametersTest#ALPHANUM_NAMES}.
+     */
+    private final String[][] aliases;
+
+    /**
+     * The expected parameter identifiers for all matrix elements, or {@code null} for no identifier.
+     * Example: {@link MatrixParametersAlphaNum#IDENTIFIERS}.
+     */
+    private final short[][] identifiers;
+
+    /**
+     * Creates a new test case for {@link TensorParameters}.
+     */
+    @SuppressWarnings("unchecked")
+    public TensorParametersTest() {
+        if (WKT1 == null) {
+            WKT1 = new TensorParameters<Double>(Double.class, "elt_", "_",
+                    TensorParameters.WKT1.getDimensionDescriptor(0),
+                    TensorParameters.WKT1.getDimensionDescriptor(1));
+        }
+        param       = WKT1;
+        names       = ELEMENT_NAMES;
+        aliases     = null;
+        identifiers = null;
+    }
+
+    /**
+     * Creates a new test case for a {@link MatrixParameters} defined by the subclass.
+     *
+     * @param param       The instance tested by this class.
+     * @param names       The expected parameter names for all matrix elements.
+     * @param aliases     The expected parameter aliases for all matrix elements, or {@code null} for no alias.
+     * @param identifiers The expected parameter identifiers for all matrix elements, or {@code null} for no identifier.
+     */
+    TensorParametersTest(final TensorParameters<Double> param, final String[][] names, final String[][] aliases,
+            final short[][] identifiers)
+    {
+        this.param       = param;
+        this.names       = names;
+        this.aliases     = aliases;
+        this.identifiers = identifiers;
+    }
+
+    /**
+     * Discards the parameters used by the tests in this class.
+     * This method is invoked by JUnit only after all tests completed.
+     */
+    @AfterClass
+    public static void clearTensorParameters() {
+        WKT1 = null;
+    }
+
+    /**
+     * Asserts that the given descriptor has the given name.
+     *
+     * @param names        The expected parameter name.
+     * @param defaultValue The expected parameter default value.
+     * @param actual       The actual parameter to verify.
+     */
+    private static void verifyDescriptor(final String name, final Number defaultValue,
+            final ParameterDescriptor<?> actual)
     {
-        assertEquals(name, actual.getName().getCode());
-        assertEquals(name, defaultValue, ((ParameterDescriptor<?>) actual).getDefaultValue());
+        assertEquals("name", name, actual.getName().getCode());
+        assertEquals("defaultValue", defaultValue, actual.getDefaultValue());
+    }
+
+    /**
+     * Asserts that the given descriptor has the given name, alias, identifier and default value.
+     *
+     * @param defaultValue The expected parameter default value.
+     * @param actual       The actual parameter to verify.
+     * @param row          Row index of the matrix element to test.
+     * @param column       Column index of the matrix element to test.
+     */
+    private void verifyDescriptor(final Number defaultValue, final ParameterDescriptor<?> actual,
+            final int row, final int column)
+    {
+        assertEquals("name", names[row][column], actual.getName().getCode());
+        assertAliasTipEquals((aliases != null) ? aliases[row][column] : null, actual);
+        assertIdentifierEqualsEPSG((identifiers != null) ? identifiers[row][column] : 0, actual);
+        assertEquals("defaultValue", defaultValue, actual.getDefaultValue());
     }
 
     /**
@@ -62,9 +170,9 @@ public final strictfp class TensorParame
      */
     @Test
     public void testGetDimensionDescriptor() {
-        final Integer THREE = 3;
-        assertDescriptorEquals("num_row", THREE, WKT1.getDimensionDescriptor(0));
-        assertDescriptorEquals("num_col", THREE, WKT1.getDimensionDescriptor(1));
+        final Integer N3 = 3;
+        verifyDescriptor(NUM_ROW, N3, param.getDimensionDescriptor(0));
+        verifyDescriptor(NUM_COL, N3, param.getDimensionDescriptor(1));
     }
 
     /**
@@ -73,26 +181,30 @@ public final strictfp class TensorParame
     @Test
     @DependsOnMethod("testIndicesToName")
     public void testGetElementDescriptor() {
-        final Double  ZERO  = 0.0;
-        final Double  ONE   = 1.0;
-        final ParameterDescriptor<Double> e00 = WKT1.getElementDescriptor(0, 0);
-        final ParameterDescriptor<Double> e01 = WKT1.getElementDescriptor(0, 1);
-        final ParameterDescriptor<Double> e10 = WKT1.getElementDescriptor(1, 0);
-        final ParameterDescriptor<Double> e11 = WKT1.getElementDescriptor(1, 1);
-        assertDescriptorEquals("elt_0_0", ONE,  e00);
-        assertDescriptorEquals("elt_0_1", ZERO, e01);
-        assertDescriptorEquals("elt_1_0", ZERO, e10);
-        assertDescriptorEquals("elt_1_1", ONE,  e11);
-        assertSame(e00, WKT1.getElementDescriptor(0, 0)); // Test caching.
-        assertSame(e01, WKT1.getElementDescriptor(0, 1));
-        assertSame(e10, WKT1.getElementDescriptor(1, 0));
-        assertSame(e11, WKT1.getElementDescriptor(1, 1));
-        /*
-         * Tests a value outside the cache capacity.
-         */
+        final Double N0 = 0.0;
+        final Double N1 = 1.0;
+        final ParameterDescriptor<Double> e00 = param.getElementDescriptor(0, 0);
+        final ParameterDescriptor<Double> e01 = param.getElementDescriptor(0, 1);
+        final ParameterDescriptor<Double> e10 = param.getElementDescriptor(1, 0);
+        final ParameterDescriptor<Double> e11 = param.getElementDescriptor(1, 1);
+        verifyDescriptor(N1, e00, 0, 0);
+        verifyDescriptor(N0, e01, 0, 1);
+        verifyDescriptor(N0, e10, 1, 0);
+        verifyDescriptor(N1, e11, 1, 1);
+        assertSame(e00, param.getElementDescriptor(0, 0)); // Test caching.
+        assertSame(e01, param.getElementDescriptor(0, 1));
+        assertSame(e10, param.getElementDescriptor(1, 0));
+        assertSame(e11, param.getElementDescriptor(1, 1));
+    }
+
+    /**
+     * Tests {@link TensorParameters#getElementDescriptor(int[])} with a value outside the cache capacity.
+     */
+    @DependsOnMethod("testGetElementDescriptor")
+    public void testGetElementDescriptorOutsideCache() {
         final int row = TensorParameters.CACHE_SIZE + 1;
         final int col = TensorParameters.CACHE_SIZE + 2;
-        assertDescriptorEquals("elt_" + row + "_" + col, ZERO, WKT1.getElementDescriptor(row, col));
+        verifyDescriptor("elt_" + row + "_" + col, 0.0, param.getElementDescriptor(row, col));
     }
 
     /**
@@ -100,8 +212,8 @@ public final strictfp class TensorParame
      */
     @Test
     public void testIndicesToName() {
-        assertEquals("elt_4_8", WKT1.indicesToName(new int[] {4, 8}));
-        assertEquals("elt_7_2", WKT1.indicesToName(new int[] {7, 2}));
+        assertEquals("elt_4_8", param.indicesToName(new int[] {4, 8}));
+        assertEquals("elt_7_2", param.indicesToName(new int[] {7, 2}));
     }
 
     /**
@@ -109,12 +221,12 @@ public final strictfp class TensorParame
      */
     @Test
     public void testNameToIndices() {
-        assertArrayEquals(new int[] {4, 8}, WKT1.nameToIndices("elt_4_8"));
-        assertArrayEquals(new int[] {7, 2}, WKT1.nameToIndices("elt_7_2"));
-        assertNull(WKT1.nameToIndices("other_7_2"));
-        assertNull(WKT1.nameToIndices("elt_7"));
+        assertArrayEquals(new int[] {4, 8}, param.nameToIndices("elt_4_8"));
+        assertArrayEquals(new int[] {7, 2}, param.nameToIndices("elt_7_2"));
+        assertNull(param.nameToIndices("other_7_2"));
+        assertNull(param.nameToIndices("elt_7"));
         try {
-            WKT1.nameToIndices("elt_7_2_3");
+            param.nameToIndices("elt_7_2_3");
             fail("Should not have parsed a name with too many indices.");
         } catch (IllegalArgumentException e) {
             // This is the expected exception.
@@ -122,44 +234,65 @@ public final strictfp class TensorParame
     }
 
     /**
-     * Tests {@link TensorParameters#descriptors(int[])} for a 1×1, 2×3 and 3×3 matrices.
+     * Tests {@link TensorParameters#getAllDescriptors(int[])} for a 1×1, 2×3 and 3×3 matrices.
      */
     @Test
     @DependsOnMethod("testGetElementDescriptor")
-    public void testDescriptors() {
-        final Double  ZERO  = 0.0;
-        final Double  ONE   = 1.0;
-        final Integer THREE = 3;
-        List<GeneralParameterDescriptor> descriptors = WKT1.descriptors(new int[] {1, 1});
-        assertDescriptorEquals("num_row", THREE, descriptors.get(0));
-        assertDescriptorEquals("num_col", THREE, descriptors.get(1));
-        assertDescriptorEquals("elt_0_0", ONE,   descriptors.get(2));
-        assertEquals("size", 3, descriptors.size());
-
-        descriptors = WKT1.descriptors(new int[] {2, 3});
-        assertDescriptorEquals("num_row", THREE, descriptors.get(0));
-        assertDescriptorEquals("num_col", THREE, descriptors.get(1));
-        assertDescriptorEquals("elt_0_0", ONE,   descriptors.get(2));
-        assertDescriptorEquals("elt_0_1", ZERO,  descriptors.get(3));
-        assertDescriptorEquals("elt_0_2", ZERO,  descriptors.get(4));
-        assertDescriptorEquals("elt_1_0", ZERO,  descriptors.get(5));
-        assertDescriptorEquals("elt_1_1", ONE,   descriptors.get(6));
-        assertDescriptorEquals("elt_1_2", ZERO,  descriptors.get(7));
-        assertEquals("size", 8, descriptors.size());
-
-        descriptors = WKT1.descriptors(new int[] {3, 3});
-        assertDescriptorEquals("num_row", THREE, descriptors.get( 0));
-        assertDescriptorEquals("num_col", THREE, descriptors.get( 1));
-        assertDescriptorEquals("elt_0_0", ONE,   descriptors.get( 2));
-        assertDescriptorEquals("elt_0_1", ZERO,  descriptors.get( 3));
-        assertDescriptorEquals("elt_0_2", ZERO,  descriptors.get( 4));
-        assertDescriptorEquals("elt_1_0", ZERO,  descriptors.get( 5));
-        assertDescriptorEquals("elt_1_1", ONE,   descriptors.get( 6));
-        assertDescriptorEquals("elt_1_2", ZERO,  descriptors.get( 7));
-        assertDescriptorEquals("elt_2_0", ZERO,  descriptors.get( 8));
-        assertDescriptorEquals("elt_2_1", ZERO,  descriptors.get( 9));
-        assertDescriptorEquals("elt_2_2", ONE,   descriptors.get(10));
-        assertEquals("size", 11, descriptors.size());
+    public void testGetAllDescriptors() {
+        final Double  N0 = 0.0;
+        final Double  N1 = 1.0;
+        final Integer N3 = 3;
+        ParameterDescriptor<?>[] descriptors = param.getAllDescriptors(1, 1);
+        verifyDescriptor(NUM_ROW, N3, descriptors[0]);
+        verifyDescriptor(NUM_COL, N3, descriptors[1]);
+        verifyDescriptor(N1, descriptors[2], 0, 0);
+        assertEquals("size", 3, descriptors.length);
+
+        descriptors = param.getAllDescriptors(2, 3);
+        verifyDescriptor(NUM_ROW, N3, descriptors[0]);
+        verifyDescriptor(NUM_COL, N3, descriptors[1]);
+        verifyDescriptor(N1, descriptors[2], 0, 0);
+        verifyDescriptor(N0, descriptors[3], 0, 1);
+        verifyDescriptor(N0, descriptors[4], 0, 2);
+        verifyDescriptor(N0, descriptors[5], 1, 0);
+        verifyDescriptor(N1, descriptors[6], 1, 1);
+        verifyDescriptor(N0, descriptors[7], 1, 2);
+        assertEquals("size", 8, descriptors.length);
+
+        descriptors = param.getAllDescriptors(3, 3);
+        verifyDescriptor(NUM_ROW, N3, descriptors[0]);
+        verifyDescriptor(NUM_COL, N3, descriptors[1]);
+        verifyDescriptor(N1, descriptors[ 2], 0, 0);
+        verifyDescriptor(N0, descriptors[ 3], 0, 1);
+        verifyDescriptor(N0, descriptors[ 4], 0, 2);
+        verifyDescriptor(N0, descriptors[ 5], 1, 0);
+        verifyDescriptor(N1, descriptors[ 6], 1, 1);
+        verifyDescriptor(N0, descriptors[ 7], 1, 2);
+        verifyDescriptor(N0, descriptors[ 8], 2, 0);
+        verifyDescriptor(N0, descriptors[ 9], 2, 1);
+        verifyDescriptor(N1, descriptors[10], 2, 2);
+        assertEquals("size", 11, descriptors.length);
+
+        descriptors = param.getAllDescriptors(4, 4);
+        verifyDescriptor(NUM_ROW, N3, descriptors[0]);
+        verifyDescriptor(NUM_COL, N3, descriptors[1]);
+        verifyDescriptor(N1, descriptors[ 2], 0, 0);
+        verifyDescriptor(N0, descriptors[ 3], 0, 1);
+        verifyDescriptor(N0, descriptors[ 4], 0, 2);
+        verifyDescriptor(N0, descriptors[ 5], 0, 3);
+        verifyDescriptor(N0, descriptors[ 6], 1, 0);
+        verifyDescriptor(N1, descriptors[ 7], 1, 1);
+        verifyDescriptor(N0, descriptors[ 8], 1, 2);
+        verifyDescriptor(N0, descriptors[ 9], 1, 3);
+        verifyDescriptor(N0, descriptors[10], 2, 0);
+        verifyDescriptor(N0, descriptors[11], 2, 1);
+        verifyDescriptor(N1, descriptors[12], 2, 2);
+        verifyDescriptor(N0, descriptors[13], 2, 3);
+        verifyDescriptor(N0, descriptors[14], 3, 0);
+        verifyDescriptor(N0, descriptors[15], 3, 1);
+        verifyDescriptor(N0, descriptors[16], 3, 2);
+        verifyDescriptor(N1, descriptors[17], 3, 3);
+        assertEquals("size", 18, descriptors.length);
     }
 
     /**
@@ -167,9 +300,9 @@ public final strictfp class TensorParame
      * {@link TensorParameters#toMatrix(ParameterValueGroup)}.
      */
     @Test
-    @DependsOnMethod("testDescriptors")
+    @DependsOnMethod("testGetAllDescriptors")
     public void testMatrixConversion() {
-        final int size = 8;
+        final int size = Math.min(6, TensorParameters.CACHE_SIZE);
         final Random random = TestUtilities.createRandomNumberGenerator();
         for (int numRow = 2; numRow <= size; numRow++) {
             for (int numCol = 2; numCol <= size; numCol++) {
@@ -179,12 +312,13 @@ public final strictfp class TensorParame
                         matrix.setElement(j, i, 200*random.nextDouble() - 100);
                     }
                 }
-                final ParameterValueGroup group = WKT1.createValueGroup(singletonMap(NAME_KEY, "Test"), matrix);
+                final ParameterValueGroup group = param.createValueGroup(
+                        singletonMap(ParameterDescriptor.NAME_KEY, "Test"), matrix);
                 validate(group);
-                assertEquals("num_row",  numRow, group.parameter("num_row").intValue());
-                assertEquals("num_col",  numCol, group.parameter("num_col").intValue());
-                assertEquals("elements", matrix, WKT1.toMatrix(group));
-                assertEquals("elements", matrix, WKT1.toMatrix(new ParameterValueGroupWrapper(group)));
+                assertEquals(NUM_ROW,    numRow, group.parameter(NUM_ROW).intValue());
+                assertEquals(NUM_COL,    numCol, group.parameter(NUM_COL).intValue());
+                assertEquals("elements", matrix, param.toMatrix(group));
+                assertEquals("elements", matrix, param.toMatrix(new ParameterValueGroupWrapper(group)));
             }
         }
     }
@@ -194,6 +328,6 @@ public final strictfp class TensorParame
      */
     @Test
     public void testSerialization() {
-        assertSerializedEquals(TensorParameters.WKT1);
+        assertSerializedEquals(param);
     }
 }

Modified: sis/branches/JDK6/core/sis-referencing/src/test/java/org/apache/sis/parameter/TensorValuesTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/core/sis-referencing/src/test/java/org/apache/sis/parameter/TensorValuesTest.java?rev=1661575&r1=1661574&r2=1661575&view=diff
==============================================================================
--- sis/branches/JDK6/core/sis-referencing/src/test/java/org/apache/sis/parameter/TensorValuesTest.java [UTF-8] (original)
+++ sis/branches/JDK6/core/sis-referencing/src/test/java/org/apache/sis/parameter/TensorValuesTest.java [UTF-8] Sun Feb 22 23:02:52 2015
@@ -20,11 +20,14 @@ import java.util.List;
 import org.opengis.parameter.ParameterValue;
 import org.opengis.parameter.ParameterValueGroup;
 import org.opengis.parameter.GeneralParameterValue;
+import org.opengis.parameter.ParameterDescriptor;
 import org.opengis.parameter.ParameterDescriptorGroup;
 import org.opengis.parameter.GeneralParameterDescriptor;
 import org.opengis.parameter.ParameterNotFoundException;
 import org.opengis.referencing.operation.Matrix;
 import org.apache.sis.referencing.operation.matrix.Matrices;
+import org.apache.sis.internal.referencing.provider.Affine;
+import org.apache.sis.internal.util.Constants;
 import org.apache.sis.test.DependsOnMethod;
 import org.apache.sis.test.DependsOn;
 import org.apache.sis.test.TestCase;
@@ -32,9 +35,9 @@ import org.junit.Test;
 
 import static java.util.Collections.singletonMap;
 import static org.opengis.test.Validators.validate;
-import static org.apache.sis.parameter.TensorParameters.WKT1;
-import static org.apache.sis.parameter.TensorParametersTest.assertDescriptorEquals;
 import static org.apache.sis.test.MetadataAssert.*;
+import static org.apache.sis.internal.util.Constants.NUM_ROW;
+import static org.apache.sis.internal.util.Constants.NUM_COL;
 
 
 /**
@@ -42,10 +45,10 @@ import static org.apache.sis.test.Metada
  *
  * @author  Martin Desruisseaux (Geomatys)
  * @since   0.4
- * @version 0.4
+ * @version 0.6
  * @module
  */
-@DependsOn(TensorParametersTest.class)
+@DependsOn(MatrixParametersTest.class)
 public final strictfp class TensorValuesTest extends TestCase {
     /**
      * The name of the parameter group created in this test class.
@@ -53,14 +56,40 @@ public final strictfp class TensorValues
     private static final String GROUP_NAME = "Group test";
 
     /**
-     * Creates an instance for a matrix.
+     * Creates an instance for a matrix using the WKT 1 conventions.
      */
-    private static ParameterValueGroup create() {
-        return WKT1.createValueGroup(singletonMap(TensorValues.NAME_KEY, GROUP_NAME));
+    private static ParameterValueGroup createWKT1() {
+        return TensorParameters.WKT1.createValueGroup(singletonMap(TensorValues.NAME_KEY, GROUP_NAME));
+    }
+
+    /**
+     * Creates an instance for a matrix using the alphanumeric (EPSG) conventions.
+     */
+    private static ParameterValueGroup createAlphaNumeric() {
+        return TensorParameters.ALPHANUM.createValueGroup(singletonMap(TensorValues.NAME_KEY, GROUP_NAME));
+    }
+
+    /**
+     * Asserts that the given descriptor has the given name and default value.
+     * Aliases and identifiers are ignored - testing them is the purpose of {@link MatrixParametersTest}.
+     *
+     * @param name         The expected parameter name.
+     * @param defaultValue The expected parameter default value.
+     * @param actual       The actual parameter to verify.
+     */
+    private static void assertDescriptorEquals(final String name, final Number defaultValue,
+            final GeneralParameterDescriptor actual)
+    {
+        assertEquals(name, actual.getName().getCode());
+        assertEquals(name, defaultValue, ((ParameterDescriptor<?>) actual).getDefaultValue());
     }
 
     /**
      * Asserts that the given parameter has the given name and value.
+     *
+     * @param name   The expected parameter name.
+     * @param value  The expected parameter value.
+     * @param actual The actual parameter to verify.
      */
     private static void assertValueEquals(final String name, final Number value, final GeneralParameterValue actual) {
         assertEquals(name, actual.getDescriptor().getName().getCode());
@@ -68,57 +97,86 @@ public final strictfp class TensorValues
     }
 
     /**
-     * Tests {@link TensorValues#descriptors()}.
+     * Tests {@link TensorValues#descriptors()} using WKT1 contentions.
      */
     @Test
     public void testDescriptors() {
-        final Double  ZERO  = 0.0;
-        final Double  ONE   = 1.0;
-        final Integer THREE = 3;
-        final ParameterValueGroup group = create();
+        final Double  N0 = 0.0;
+        final Double  N1 = 1.0;
+        final Integer N3 = 3;
+        final ParameterValueGroup group = createWKT1();
 
-        group.parameter("num_row").setValue(1);
-        group.parameter("num_col").setValue(1);
+        group.parameter(NUM_ROW).setValue(1);
+        group.parameter(NUM_COL).setValue(1);
         List<GeneralParameterDescriptor> descriptors = group.getDescriptor().descriptors();
-        assertDescriptorEquals("num_row", THREE, descriptors.get(0));
-        assertDescriptorEquals("num_col", THREE, descriptors.get(1));
-        assertDescriptorEquals("elt_0_0", ONE,   descriptors.get(2));
+        assertDescriptorEquals( NUM_ROW,  N3, descriptors.get(0));
+        assertDescriptorEquals( NUM_COL,  N3, descriptors.get(1));
+        assertDescriptorEquals("elt_0_0", N1, descriptors.get(2));
         assertEquals("size", 3, descriptors.size());
 
-        group.parameter("num_row").setValue(2);
-        group.parameter("num_col").setValue(3);
+        group.parameter(NUM_ROW).setValue(2);
+        group.parameter(NUM_COL).setValue(3);
         descriptors = group.getDescriptor().descriptors();
-        assertDescriptorEquals("num_row", THREE, descriptors.get(0));
-        assertDescriptorEquals("num_col", THREE, descriptors.get(1));
-        assertDescriptorEquals("elt_0_0", ONE,   descriptors.get(2));
-        assertDescriptorEquals("elt_0_1", ZERO,  descriptors.get(3));
-        assertDescriptorEquals("elt_0_2", ZERO,  descriptors.get(4));
-        assertDescriptorEquals("elt_1_0", ZERO,  descriptors.get(5));
-        assertDescriptorEquals("elt_1_1", ONE,   descriptors.get(6));
-        assertDescriptorEquals("elt_1_2", ZERO,  descriptors.get(7));
+        assertDescriptorEquals( NUM_ROW,  N3, descriptors.get(0));
+        assertDescriptorEquals( NUM_COL,  N3, descriptors.get(1));
+        assertDescriptorEquals("elt_0_0", N1, descriptors.get(2));
+        assertDescriptorEquals("elt_0_1", N0, descriptors.get(3));
+        assertDescriptorEquals("elt_0_2", N0, descriptors.get(4));
+        assertDescriptorEquals("elt_1_0", N0, descriptors.get(5));
+        assertDescriptorEquals("elt_1_1", N1, descriptors.get(6));
+        assertDescriptorEquals("elt_1_2", N0, descriptors.get(7));
         assertEquals("size", 8, descriptors.size());
     }
 
     /**
+     * Tests {@link TensorValues#descriptors()} using alphanumeric (EPSG) contentions.
+     */
+    @Test
+    @DependsOnMethod("testDescriptors")
+    public void testAlphaNumericDescriptors() {
+        final Double  N0 = 0.0;
+        final Double  N1 = 1.0;
+        final Integer N3 = 3;
+        final ParameterValueGroup group = createAlphaNumeric();
+        final List<GeneralParameterDescriptor> descriptors = group.getDescriptor().descriptors();
+        assertDescriptorEquals(NUM_ROW, N3, descriptors.get(0));
+        assertDescriptorEquals(NUM_COL, N3, descriptors.get(1));
+        assertDescriptorEquals("A0",    N1, descriptors.get( 2));
+        assertDescriptorEquals("A1",    N0, descriptors.get( 3));
+        assertDescriptorEquals("A2",    N0, descriptors.get( 4));
+        assertDescriptorEquals("B0",    N0, descriptors.get( 5));
+        assertDescriptorEquals("B1",    N1, descriptors.get( 6));
+        assertDescriptorEquals("B2",    N0, descriptors.get( 7));
+        assertDescriptorEquals("C0",    N0, descriptors.get( 8));
+        assertDescriptorEquals("C1",    N0, descriptors.get( 9));
+        assertDescriptorEquals("C2",    N1, descriptors.get(10));
+        assertEquals("size", 11, descriptors.size());
+    }
+
+    /**
      * Tests {@link TensorValues#values()}.
      */
     @Test
     @DependsOnMethod("testParameter")
     public void testValues() {
-        final ParameterValueGroup group = create();
-        group.parameter("num_row").setValue(2);
-        group.parameter("num_col").setValue(3);
+        final ParameterValueGroup group = createWKT1();
+        group.parameter(NUM_ROW).setValue(2);
+        group.parameter(NUM_COL).setValue(3);
         List<GeneralParameterValue> values = group.values();
-        assertValueEquals("num_row", 2, values.get(0));
-        assertValueEquals("num_col", 3, values.get(1));
+        assertValueEquals(NUM_ROW, 2, values.get(0));
+        assertValueEquals(NUM_COL, 3, values.get(1));
         assertEquals("size", 2, values.size());
-
+        /*
+         * Above list had no explicit parameters, since all of them had their default values.
+         * Now set some parameters to different values. Those parameters should now appear in
+         * the list.
+         */
         group.parameter("elt_0_1").setValue(8);
         group.parameter("elt_1_1").setValue(7);
         group.parameter("elt_1_2").setValue(6);
         values = group.values();
-        assertValueEquals("num_row", 2,   values.get(0));
-        assertValueEquals("num_col", 3,   values.get(1));
+        assertValueEquals( NUM_ROW,  2,   values.get(0));
+        assertValueEquals( NUM_COL,  3,   values.get(1));
         assertValueEquals("elt_0_1", 8.0, values.get(2));
         assertValueEquals("elt_1_1", 7.0, values.get(3));
         assertValueEquals("elt_1_2", 6.0, values.get(4));
@@ -130,17 +188,39 @@ public final strictfp class TensorValues
      */
     @Test
     public void testDescriptor() {
-        final ParameterValueGroup group = create();
+        final Double  N0 = 0.0;
+        final Double  N1 = 1.0;
+        final Integer N3 = 3;
+        final ParameterValueGroup group = createWKT1();
         final ParameterDescriptorGroup d = group.getDescriptor();
-        assertDescriptorEquals("num_row", 3,   d.descriptor("num_row"));
-        assertDescriptorEquals("num_col", 3,   d.descriptor("num_col"));
-        assertDescriptorEquals("elt_0_0", 1.0, d.descriptor("elt_0_0"));
-        assertDescriptorEquals("elt_2_2", 1.0, d.descriptor("elt_2_2"));
+        assertDescriptorEquals( NUM_ROW,  N3, d.descriptor( NUM_ROW ));
+        assertDescriptorEquals( NUM_COL,  N3, d.descriptor( NUM_COL ));
+        assertDescriptorEquals("elt_0_0", N1, d.descriptor("elt_0_0"));
+        assertDescriptorEquals("elt_0_1", N0, d.descriptor("elt_0_1"));
+        assertDescriptorEquals("elt_0_2", N0, d.descriptor("elt_0_2"));
+        assertDescriptorEquals("elt_1_0", N0, d.descriptor("elt_1_0"));
+        assertDescriptorEquals("elt_1_1", N1, d.descriptor("elt_1_1"));
+        assertDescriptorEquals("elt_1_2", N0, d.descriptor("elt_1_2"));
+        assertDescriptorEquals("elt_2_0", N0, d.descriptor("elt_2_0"));
+        assertDescriptorEquals("elt_2_1", N0, d.descriptor("elt_2_1"));
+        assertDescriptorEquals("elt_2_2", N1, d.descriptor("elt_2_2"));
+        /*
+         * Same test than above, but using the EPSG or pseudo-EPSG names.
+         */
+        assertDescriptorEquals("elt_0_0", N1, d.descriptor("A0"));
+        assertDescriptorEquals("elt_0_1", N0, d.descriptor("A1"));
+        assertDescriptorEquals("elt_0_2", N0, d.descriptor("A2"));
+        assertDescriptorEquals("elt_1_0", N0, d.descriptor("B0"));
+        assertDescriptorEquals("elt_1_1", N1, d.descriptor("B1"));
+        assertDescriptorEquals("elt_1_2", N0, d.descriptor("B2"));
+        assertDescriptorEquals("elt_2_0", N0, d.descriptor("C0"));
+        assertDescriptorEquals("elt_2_1", N0, d.descriptor("C1"));
+        assertDescriptorEquals("elt_2_2", N1, d.descriptor("C2"));
         /*
          * If we reduce the matrix size, than it shall not be possible
          * anymore to get the descriptor in the row that we removed.
          */
-        group.parameter("num_col").setValue(2);
+        group.parameter(NUM_COL).setValue(2);
         try {
             d.descriptor("elt_2_2");
             fail("elt_2_2 should not exist.");
@@ -156,21 +236,34 @@ public final strictfp class TensorValues
      */
     @Test
     public void testParameter() {
-        final ParameterValueGroup group = create();
-        assertValueEquals("num_row", 3,   group.parameter("num_row"));
-        assertValueEquals("num_col", 3,   group.parameter("num_col"));
-        assertValueEquals("elt_0_0", 1.0, group.parameter("elt_0_0"));
-        assertValueEquals("elt_2_2", 1.0, group.parameter("elt_2_2"));
-
+        final Double  N0 = 0.0;
+        final Double  N1 = 1.0;
+        final Integer N3 = 3;
+        final ParameterValueGroup group = createWKT1();
+        assertValueEquals( NUM_ROW,  N3, group.parameter( NUM_ROW ));
+        assertValueEquals( NUM_COL,  N3, group.parameter( NUM_COL ));
+        assertValueEquals("elt_0_0", N1, group.parameter("elt_0_0"));
+        assertValueEquals("elt_0_1", N0, group.parameter("elt_0_1"));
+        assertValueEquals("elt_2_2", N1, group.parameter("elt_2_2"));
+        assertValueEquals("elt_0_0", N1, group.parameter("A0"));
+        assertValueEquals("elt_0_1", N0, group.parameter("A1"));
+        assertValueEquals("elt_2_2", N1, group.parameter("C2"));
+        /*
+         * Change some values and test again.
+         */
         group.parameter("elt_2_2").setValue(8);
         group.parameter("elt_0_1").setValue(6);
         assertValueEquals("elt_2_2", 8.0, group.parameter("elt_2_2"));
         assertValueEquals("elt_0_1", 6.0, group.parameter("elt_0_1"));
+        assertValueEquals("elt_0_0", N1,  group.parameter("elt_0_0"));
+        assertValueEquals("elt_2_2", 8.0, group.parameter("C2"));
+        assertValueEquals("elt_0_1", 6.0, group.parameter("A1"));
+        assertValueEquals("elt_0_0", N1,  group.parameter("A0"));
         /*
          * If we reduce the matrix size, than it shall not be possible
          * anymore to get the descriptor in the row that we removed.
          */
-        group.parameter("num_col").setValue(2);
+        group.parameter(NUM_COL).setValue(2);
         try {
             group.parameter("elt_2_2");
             fail("elt_2_2 should not exist.");
@@ -187,22 +280,22 @@ public final strictfp class TensorValues
     @Test
     @DependsOnMethod("testParameter")
     public void testClone() {
-        final ParameterValueGroup group = create();
-        group.parameter("num_row").setValue(2);
+        final ParameterValueGroup group = createWKT1();
+        group.parameter( NUM_ROW ).setValue(2);
         group.parameter("elt_0_1").setValue(4);
         group.parameter("elt_1_0").setValue(2);
         /*
          * Creates a clone, modify some values, keep other values.
          */
         final ParameterValueGroup clone = group.clone();
-        clone.parameter("num_row").setValue(4);
+        clone.parameter( NUM_ROW ).setValue(4);
         clone.parameter("elt_0_1").setValue(3);
         /*
          * Verify that changes in cloned values did not affected
          * values in the original object.
          */
-        assertEquals(2, group.parameter("num_row").intValue());
-        assertEquals(4, clone.parameter("num_row").intValue());
+        assertEquals(2, group.parameter( NUM_ROW ).intValue());
+        assertEquals(4, clone.parameter( NUM_ROW ).intValue());
         assertEquals(4, group.parameter("elt_0_1").intValue());
         assertEquals(3, clone.parameter("elt_0_1").intValue());
         assertEquals(2, group.parameter("elt_1_0").intValue());
@@ -210,23 +303,55 @@ public final strictfp class TensorValues
     }
 
     /**
-     * Tests WKT formatting.
+     * Tests {@link TensorParameters#WKT1} formatting.
+     * <ul>
+     *   <li>Group name shall be {@code "Affine"}.</li>
+     *   <li>Parameters {@code "num_row"} and {@code "num_col"} are mandatory.</li>
+     *   <li>Parameter names shall be of the form {@code "elt_0_0"}.</li>
+     *   <li>No identifier.</li>
+     * </ul>
      */
     @Test
-    public void testWKT() {
-        final Matrix matrix = Matrices.createIdentity(4);
+    public void testWKT1() {
+        final Matrix matrix = Matrices.createIdentity(3);
         matrix.setElement(0,2,  4);
         matrix.setElement(1,0, -2);
-        matrix.setElement(2,3,  7);
-        final ParameterValueGroup group = WKT1.createValueGroup(singletonMap(TensorValues.NAME_KEY, "Affine"), matrix);
+        matrix.setElement(2,2,  7);
+        final ParameterValueGroup group = TensorParameters.WKT1.createValueGroup(
+                singletonMap(TensorValues.NAME_KEY, Constants.AFFINE), matrix);
         validate(group);
         assertWktEquals(
                 "ParameterGroup[“Affine”,\n"      +
-                "  Parameter[“num_row”, 4],\n"    +
-                "  Parameter[“num_col”, 4],\n"    +
+                "  Parameter[“num_row”, 3],\n"    +   // Shall be shown even if equals to the defautl value.
+                "  Parameter[“num_col”, 3],\n"    +
                 "  Parameter[“elt_0_2”, 4.0],\n"  +
                 "  Parameter[“elt_1_0”, -2.0],\n" +
-                "  Parameter[“elt_2_3”, 7.0]]", group);
+                "  Parameter[“elt_2_2”, 7.0]]", group);
+    }
+
+    /**
+     * Tests {@link TensorParameters#ALPHANUM} formatting.
+     * <ul>
+     *   <li>Group name shall be {@code "Affine general parametric transformation"}.</li>
+     *   <li>No {@code "num_row"} or {@code "num_col"} parameters if their value is equals to 3.</li>
+     *   <li>Parameter names shall be of the form {@code "A0"}.</li>
+     *   <li>Identifiers present, but only for A0-A2 and B0-B2.</li>
+     * </ul>
+     */
+    @Test
+    public void testWKT2() {
+        final Matrix matrix = Matrices.createIdentity(3);
+        matrix.setElement(0,2,  4);
+        matrix.setElement(1,0, -2);
+        matrix.setElement(2,2,  7);
+        final ParameterValueGroup group = TensorParameters.ALPHANUM.createValueGroup(
+                singletonMap(TensorValues.NAME_KEY, Affine.NAME), matrix);
+        validate(group);
+        assertWktEquals(
+                "ParameterGroup[“Affine general parametric transformation”,\n" +
+                "  Parameter[“A2”, 4.0, Id[“EPSG”, 8625]],\n"  +
+                "  Parameter[“B0”, -2.0, Id[“EPSG”, 8639]],\n" +
+                "  Parameter[“C2”, 7.0]]", group);
     }
 
     /**
@@ -234,6 +359,6 @@ public final strictfp class TensorValues
      */
     @Test
     public void testSerialization() {
-        assertSerializedEquals(create());
+        assertSerializedEquals(createWKT1());
     }
 }

Modified: sis/branches/JDK6/core/sis-referencing/src/test/java/org/apache/sis/referencing/CommonCRSTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/core/sis-referencing/src/test/java/org/apache/sis/referencing/CommonCRSTest.java?rev=1661575&r1=1661574&r2=1661575&view=diff
==============================================================================
--- sis/branches/JDK6/core/sis-referencing/src/test/java/org/apache/sis/referencing/CommonCRSTest.java [UTF-8] (original)
+++ sis/branches/JDK6/core/sis-referencing/src/test/java/org/apache/sis/referencing/CommonCRSTest.java [UTF-8] Sun Feb 22 23:02:52 2015
@@ -31,6 +31,7 @@ import org.opengis.referencing.datum.Tem
 import org.opengis.referencing.datum.VerticalDatum;
 import org.opengis.referencing.datum.VerticalDatumType;
 import org.apache.sis.internal.referencing.VerticalDatumTypes;
+import org.apache.sis.internal.util.Constants;
 import org.apache.sis.test.DependsOnMethod;
 import org.apache.sis.test.DependsOn;
 import org.apache.sis.test.TestCase;
@@ -211,24 +212,24 @@ public final strictfp class CommonCRSTes
      */
     @Test
     public void testForCode() throws FactoryException {
-        verifyForCode(CommonCRS.WGS84 .geographic(),            "EPSG", "4326");
-        verifyForCode(CommonCRS.WGS72 .geographic(),            "EPSG", "4322");
-        verifyForCode(CommonCRS.SPHERE.geographic(),            "EPSG", "4047");
-        verifyForCode(CommonCRS.NAD83 .geographic(),            "EPSG", "4269");
-        verifyForCode(CommonCRS.NAD27 .geographic(),            "EPSG", "4267");
-        verifyForCode(CommonCRS.ETRS89.geographic(),            "EPSG", "4258");
-        verifyForCode(CommonCRS.ED50  .geographic(),            "EPSG", "4230");
-        verifyForCode(CommonCRS.WGS84 .geocentric(),            "EPSG", "4978");
-        verifyForCode(CommonCRS.WGS72 .geocentric(),            "EPSG", "4984");
-        verifyForCode(CommonCRS.ETRS89.geocentric(),            "EPSG", "4936");
-        verifyForCode(CommonCRS.WGS84 .geographic3D(),          "EPSG", "4979");
-        verifyForCode(CommonCRS.WGS72 .geographic3D(),          "EPSG", "4985");
-        verifyForCode(CommonCRS.ETRS89.geographic3D(),          "EPSG", "4937");
-        verifyForCode(CommonCRS.Vertical.MEAN_SEA_LEVEL.crs(),  "EPSG", "5714");
-        verifyForCode(CommonCRS.Vertical.DEPTH.crs(),           "EPSG", "5715");
-        verifyForCode(CommonCRS.WGS84.normalizedGeographic(),   "CRS",  "84");
-        verifyForCode(CommonCRS.NAD83.normalizedGeographic(),   "CRS",  "83");
-        verifyForCode(CommonCRS.NAD27.normalizedGeographic(),   "CRS",  "27");
+        verifyForCode(CommonCRS.WGS84 .geographic(),            Constants.EPSG, "4326");
+        verifyForCode(CommonCRS.WGS72 .geographic(),            Constants.EPSG, "4322");
+        verifyForCode(CommonCRS.SPHERE.geographic(),            Constants.EPSG, "4047");
+        verifyForCode(CommonCRS.NAD83 .geographic(),            Constants.EPSG, "4269");
+        verifyForCode(CommonCRS.NAD27 .geographic(),            Constants.EPSG, "4267");
+        verifyForCode(CommonCRS.ETRS89.geographic(),            Constants.EPSG, "4258");
+        verifyForCode(CommonCRS.ED50  .geographic(),            Constants.EPSG, "4230");
+        verifyForCode(CommonCRS.WGS84 .geocentric(),            Constants.EPSG, "4978");
+        verifyForCode(CommonCRS.WGS72 .geocentric(),            Constants.EPSG, "4984");
+        verifyForCode(CommonCRS.ETRS89.geocentric(),            Constants.EPSG, "4936");
+        verifyForCode(CommonCRS.WGS84 .geographic3D(),          Constants.EPSG, "4979");
+        verifyForCode(CommonCRS.WGS72 .geographic3D(),          Constants.EPSG, "4985");
+        verifyForCode(CommonCRS.ETRS89.geographic3D(),          Constants.EPSG, "4937");
+        verifyForCode(CommonCRS.Vertical.MEAN_SEA_LEVEL.crs(),  Constants.EPSG, "5714");
+        verifyForCode(CommonCRS.Vertical.DEPTH.crs(),           Constants.EPSG, "5715");
+        verifyForCode(CommonCRS.WGS84.normalizedGeographic(),   Constants.CRS,  "84");
+        verifyForCode(CommonCRS.NAD83.normalizedGeographic(),   Constants.CRS,  "83");
+        verifyForCode(CommonCRS.NAD27.normalizedGeographic(),   Constants.CRS,  "27");
     }
 
     /**

Modified: sis/branches/JDK6/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/DefaultOperationMethodTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/DefaultOperationMethodTest.java?rev=1661575&r1=1661574&r2=1661575&view=diff
==============================================================================
--- sis/branches/JDK6/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/DefaultOperationMethodTest.java [UTF-8] (original)
+++ sis/branches/JDK6/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/DefaultOperationMethodTest.java [UTF-8] Sun Feb 22 23:02:52 2015
@@ -41,7 +41,7 @@ import static org.apache.sis.test.TestUt
  *
  * @author  Martin Desruisseaux (Geomatys)
  * @version 0.5
- * @since   0.5
+ * @since   0.6
  * @module
  */
 @DependsOn({
@@ -55,9 +55,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.
      * @return The operation method.
      */
-    private static DefaultOperationMethod create(final String method, final String identifier, final String formula) {
+    private static DefaultOperationMethod create(final String method, final String identifier, final String formula,
+            final Integer dimension)
+    {
         final Map<String,Object> properties = new HashMap<String,Object>(8);
         assertNull(properties.put(OperationMethod.NAME_KEY, method));
         assertNull(properties.put(Identifier.CODESPACE_KEY, "EPSG"));
@@ -74,7 +77,7 @@ public final strictfp class DefaultOpera
         assertNotNull(properties.put(OperationMethod.NAME_KEY, parameters.getName()));
         assertNull(properties.put(OperationMethod.IDENTIFIERS_KEY, new ImmutableIdentifier(HardCodedCitations.OGP, "EPSG", identifier)));
         assertNull(properties.put(OperationMethod.FORMULA_KEY, new DefaultCitation(formula)));
-        return new DefaultOperationMethod(properties, 2, 2, parameters);
+        return new DefaultOperationMethod(properties, dimension, dimension, parameters);
     }
 
     /**
@@ -82,7 +85,7 @@ public final strictfp class DefaultOpera
      */
     @Test
     public void testConstruction() {
-        final OperationMethod method = create("Mercator (variant A)", "9804", "EPSG guidance note #7-2");
+        final OperationMethod method = create("Mercator (variant A)", "9804", "EPSG guidance note #7-2", 2);
         assertEpsgIdentifierEquals("Mercator (variant A)", method.getName());
         assertEpsgIdentifierEquals("9804", getSingleton(method.getIdentifiers()));
         assertEquals("formula", "EPSG guidance note #7-2", method.getFormula().getCitation().getTitle().toString());
@@ -95,15 +98,16 @@ public final strictfp class DefaultOpera
      */
     @Test
     public void testEquals() {
-        final DefaultOperationMethod m1 = create("Mercator (variant A)", "9804", "EPSG guidance note #7-2");
-        final DefaultOperationMethod m2 = create("Mercator (variant A)", "9804", "E = FE + a*ko(lon - lonO)");
+        final Integer dim = 2;
+        final DefaultOperationMethod m1 = create("Mercator (variant A)", "9804", "EPSG guidance note #7-2",   dim);
+        final DefaultOperationMethod m2 = create("Mercator (variant A)", "9804", "E = FE + a*ko(lon - lonO)", dim);
         assertFalse ("STRICT",          m1.equals(m2, ComparisonMode.STRICT));
         assertFalse ("BY_CONTRACT",     m1.equals(m2, ComparisonMode.BY_CONTRACT));
         assertTrue  ("IGNORE_METADATA", m1.equals(m2, ComparisonMode.IGNORE_METADATA));
         assertEquals("Hash code should ignore metadata.", m1.hashCode(), m2.hashCode());
 
-        final DefaultOperationMethod m3 = create("Mercator (variant B)", "9805", "EPSG guidance note #7-2");
-        final DefaultOperationMethod m4 = create("mercator (variant b)", "9805", "EPSG guidance note #7-2");
+        final DefaultOperationMethod m3 = create("Mercator (variant B)", "9805", "EPSG guidance note #7-2", dim);
+        final DefaultOperationMethod m4 = create("mercator (variant b)", "9805", "EPSG guidance note #7-2", dim);
         assertFalse("IGNORE_METADATA", m1.equals(m3, ComparisonMode.IGNORE_METADATA));
         assertTrue ("IGNORE_METADATA", m3.equals(m4, ComparisonMode.IGNORE_METADATA));
         assertFalse("BY_CONTRACT",     m3.equals(m4, ComparisonMode.BY_CONTRACT));
@@ -114,25 +118,36 @@ public final strictfp class DefaultOpera
      */
     @Test
     @DependsOnMethod({"testConstruction", "testEquals"})
-    public void testResize() {
-        final OperationMethod method = create("Affine geometric transformation", "9623", "EPSG guidance note #7-2");
+    public void testRedimension() {
+        final OperationMethod method = create("Affine geometric transformation", "9623", "EPSG guidance note #7-2", null);
         OperationMethod other = DefaultOperationMethod.redimension(method, 2, 2);
-        assertSame(method, other);
-        assertTrue(method.equals(other));
+        assertSame(other, DefaultOperationMethod.redimension(other, 2, 2));
+        assertNotSame(method, other);
+        assertFalse(method.equals(other));
         assertEquals("sourceDimensions", Integer.valueOf(2), other.getSourceDimensions());
         assertEquals("targetDimensions", Integer.valueOf(2), other.getTargetDimensions());
 
         other = DefaultOperationMethod.redimension(method, 2, 3);
+        assertSame(other, DefaultOperationMethod.redimension(other, 2, 3));
         assertNotSame(method, other);
         assertFalse(method.equals(other));
         assertEquals("sourceDimensions", Integer.valueOf(2), other.getSourceDimensions());
         assertEquals("targetDimensions", Integer.valueOf(3), other.getTargetDimensions());
 
         other = DefaultOperationMethod.redimension(method, 3, 2);
+        assertSame(other, DefaultOperationMethod.redimension(other, 3, 2));
         assertNotSame(method, other);
         assertFalse(method.equals(other));
         assertEquals("sourceDimensions", Integer.valueOf(3), other.getSourceDimensions());
         assertEquals("targetDimensions", Integer.valueOf(2), other.getTargetDimensions());
+
+        try {
+            DefaultOperationMethod.redimension(other, 3, 3);
+            fail("Should not have accepted to change non-null dimensions.");
+        } catch (IllegalArgumentException e) {
+            final String message = e.getLocalizedMessage();
+            assertTrue(message, message.contains("Affine geometric transformation"));
+        }
     }
 
     /**
@@ -141,7 +156,7 @@ public final strictfp class DefaultOpera
     @Test
     @DependsOnMethod("testConstruction")
     public void testWKT() {
-        final OperationMethod method = create("Mercator (variant A)", "9804", "EPSG guidance note #7-2");
+        final OperationMethod method = create("Mercator (variant A)", "9804", "EPSG guidance note #7-2", 2);
         assertWktEquals("Method[“Mercator (variant A)”, Id[“EPSG”, 9804, Citation[“OGP”], URI[“urn:ogc:def:method:EPSG::9804”]]]", method);
         assertWktEquals(Convention.WKT1, "PROJECTION[“Mercator (variant A)”, AUTHORITY[“EPSG”, “9804”]]", method);
     }

Modified: sis/branches/JDK6/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/transform/CopyTransformTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/transform/CopyTransformTest.java?rev=1661575&r1=1661574&r2=1661575&view=diff
==============================================================================
--- sis/branches/JDK6/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/transform/CopyTransformTest.java [UTF-8] (original)
+++ sis/branches/JDK6/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/transform/CopyTransformTest.java [UTF-8] Sun Feb 22 23:02:52 2015
@@ -60,7 +60,7 @@ public final strictfp class CopyTransfor
     public void testIdentity() throws TransformException {
         transform = new CopyTransform(3, 0, 1, 2);
         validate();
-        verifyParameters(Affine.PARAMETERS, null);
+        verifyParameters(Affine.getProvider(3, 3, true).getParameters(), null);
         verifyIsIdentity(true);
 
         final double[] source = generateRandomCoordinates();

Modified: sis/branches/JDK6/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/transform/ProjectiveTransformTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/transform/ProjectiveTransformTest.java?rev=1661575&r1=1661574&r2=1661575&view=diff
==============================================================================
--- sis/branches/JDK6/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/transform/ProjectiveTransformTest.java [UTF-8] (original)
+++ sis/branches/JDK6/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/transform/ProjectiveTransformTest.java [UTF-8] Sun Feb 22 23:02:52 2015
@@ -129,6 +129,8 @@ public strictfp class ProjectiveTransfor
         assertTrue("The matrix declared by the MathTransform is not equal to the one given at creation time.",
                 Matrices.equals(matrix, tm, tolerance, false));
 
-        assertSame("ParameterDescriptor", Affine.PARAMETERS, ((Parameterized) transform).getParameterDescriptors());
+        assertSame("ParameterDescriptor",
+                Affine.getProvider(transform.getSourceDimensions(), transform.getTargetDimensions(), true).getParameters(),
+                ((Parameterized) transform).getParameterDescriptors());
     }
 }



Mime
View raw message