sis-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From desruisse...@apache.org
Subject svn commit: r1724528 [2/15] - in /sis/branches/JDK6: ./ application/sis-console/src/main/artifact/bin/ application/sis-console/src/main/artifact/log/ application/sis-console/src/main/java/org/apache/sis/console/ core/sis-build-helper/src/main/java/org/...
Date Wed, 13 Jan 2016 23:25:42 GMT
Modified: sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/AbstractProvider.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/AbstractProvider.java?rev=1724528&r1=1724527&r2=1724528&view=diff
==============================================================================
--- sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/AbstractProvider.java [UTF-8] (original)
+++ sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/AbstractProvider.java [UTF-8] Wed Jan 13 23:25:38 2016
@@ -46,11 +46,11 @@ import org.apache.sis.util.Workaround;
  *
  * @author  Martin Desruisseaux (Geomatys)
  * @since   0.6
- * @version 0.6
+ * @version 0.7
  * @module
  */
 @XmlTransient
-abstract class AbstractProvider extends DefaultOperationMethod implements MathTransformProvider {
+public abstract class AbstractProvider extends DefaultOperationMethod implements MathTransformProvider {
     /**
      * For cross-version compatibility.
      */
@@ -185,4 +185,33 @@ abstract class AbstractProvider extends
     static ParameterDescriptor<Double> createShift(final ParameterBuilder builder) {
         return builder.create(0.0, SI.METRE);
     }
+
+    /**
+     * Flags whether the source and/or target ellipsoid are concerned by this operation. This method is invoked by
+     * {@link org.apache.sis.referencing.operation.transform.DefaultMathTransformFactory} for determining if this
+     * operation has {@code "semi_major"}, {@code "semi_minor"}, {@code "src_semi_major"}, {@code "src_semi_minor"}
+     * parameters that may need to be filled with values inferred from the source or target
+     * {@link org.apache.sis.referencing.datum.DefaultGeodeticDatum}.
+     * Meaning of return values:
+     *
+     * <ul>
+     *   <li>0 if neither the source coordinate system or the destination coordinate system is ellipsoidal.
+     *       There is no parameter that need to be completed.</li>
+     *   <li>1 if this operation has {@code "semi_major"} and {@code "semi_minor"} parameters that need
+     *       to be set to the axis lengths of the source ellipsoid.</li>
+     *   <li>2 if this operation has {@code "semi_major"} and {@code "semi_minor"} parameters that need
+     *       to be set to the axis lengths of the target ellipsoid.</li>
+     *   <li>3 if this operation has {@code "src_semi_major"}, {@code "src_semi_minor"}, {@code "tgt_semi_major"}
+     *       and {@code "tgt_semi_minor"} parameters that need to be set to the axis lengths of the source and
+     *       target ellipsoids.</li>
+     * </ul>
+     *
+     * This method is just a hint. If the information is not provided, {@code DefaultMathTransformFactory}
+     * will try to infer it from the type of user-specified source and target CRS.
+     *
+     * @return 0, 1, 2 or 3.
+     */
+    public int getEllipsoidsMask() {
+        return 0;
+    }
 }

Copied: sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/DatumShiftGridCompressed.java (from r1724479, sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/DatumShiftGridCompressed.java)
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/DatumShiftGridCompressed.java?p2=sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/DatumShiftGridCompressed.java&p1=sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/DatumShiftGridCompressed.java&r1=1724479&r2=1724528&rev=1724528&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/DatumShiftGridCompressed.java [UTF-8] (original)
+++ sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/DatumShiftGridCompressed.java [UTF-8] Wed Jan 13 23:25:38 2016
@@ -116,7 +116,7 @@ final class DatumShiftGridCompressed<C e
             }
             data[dim] = compressed;
         }
-        return new DatumShiftGridCompressed<>(grid, averages, data, scale);
+        return new DatumShiftGridCompressed<C,T>(grid, averages, data, scale);
     }
 
     /**
@@ -124,7 +124,7 @@ final class DatumShiftGridCompressed<C e
      */
     @Override
     final DatumShiftGridFile<C,T> setData(final Object[] other) {
-        return new DatumShiftGridCompressed<>(this, averages, (short[][]) other, scale);
+        return new DatumShiftGridCompressed<C,T>(this, averages, (short[][]) other, scale);
     }
 
     /**

Copied: sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/DatumShiftGridFile.java (from r1724479, sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/DatumShiftGridFile.java)
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/DatumShiftGridFile.java?p2=sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/DatumShiftGridFile.java&p1=sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/DatumShiftGridFile.java&r1=1724479&r2=1724528&rev=1724528&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/DatumShiftGridFile.java [UTF-8] (original)
+++ sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/DatumShiftGridFile.java [UTF-8] Wed Jan 13 23:25:38 2016
@@ -32,7 +32,8 @@ import org.apache.sis.referencing.datum.
 import org.apache.sis.internal.referencing.j2d.AffineTransform2D;
 
 // Branch-specific imports
-import java.nio.file.Path;
+import java.io.File;
+import org.apache.sis.internal.jdk7.Path;
 import org.apache.sis.internal.jdk8.JDK8;
 
 
@@ -200,7 +201,7 @@ public abstract class DatumShiftGridFile
         for (final GeneralParameterDescriptor gd : descriptor.descriptors()) {
             if (gd instanceof ParameterDescriptor<?>) {
                 final ParameterDescriptor<?> d = (ParameterDescriptor<?>) gd;
-                if (Path.class.isAssignableFrom(d.getValueClass())) {
+                if (File.class.isAssignableFrom(d.getValueClass())) {
                     parameters.getOrCreate(d).setValue(files[i]);
                     if (++i == files.length) break;
                 }
@@ -317,7 +318,7 @@ public abstract class DatumShiftGridFile
          */
         @Override
         final DatumShiftGridFile<C,T> setData(final Object[] other) {
-            return new Float<>(this, (float[][]) other);
+            return new Float<C,T>(this, (float[][]) other);
         }
 
         /**

Copied: sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/DatumShiftGridLoader.java (from r1724479, sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/DatumShiftGridLoader.java)
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/DatumShiftGridLoader.java?p2=sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/DatumShiftGridLoader.java&p1=sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/DatumShiftGridLoader.java&r1=1724479&r2=1724528&rev=1724528&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/DatumShiftGridLoader.java [UTF-8] (original)
+++ sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/DatumShiftGridLoader.java [UTF-8] Wed Jan 13 23:25:38 2016
@@ -31,8 +31,8 @@ import org.apache.sis.referencing.factor
 import org.apache.sis.referencing.factory.MissingFactoryResourceException;
 
 // Branch-dependent imports
-import java.nio.file.Path;
-import java.nio.file.NoSuchFileException;
+import org.apache.sis.internal.jdk7.Path;
+import java.io.FileNotFoundException;
 
 
 /**
@@ -160,7 +160,7 @@ class DatumShiftGridLoader {
      */
     static FactoryException canNotLoad(final String format, final Path file, final Exception cause) {
         final String message = Errors.format(Errors.Keys.CanNotParseFile_2, format, file);
-        if (cause instanceof NoSuchFileException) {
+        if (cause instanceof FileNotFoundException) {
             return new MissingFactoryResourceException(message, cause);
         } else {
             return new FactoryDataException(message, cause);

Modified: sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/Equirectangular.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/Equirectangular.java?rev=1724528&r1=1724527&r2=1724528&view=diff
==============================================================================
--- sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/Equirectangular.java [UTF-8] (original)
+++ sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/Equirectangular.java [UTF-8] Wed Jan 13 23:25:38 2016
@@ -168,7 +168,7 @@ public final class Equirectangular exten
         LATITUDE_OF_ORIGIN = createZeroConstant(builder     // Was used by EPSG:9823 (also EPSG:9842).
                 .addIdentifier("8801")
                 .addName("Latitude of natural origin")
-                .addName(Citations.OGC,     "latitude_of_origin")
+                .addName(Citations.OGC,     Constants.LATITUDE_OF_ORIGIN)
                 .addName(Citations.ESRI,    "Latitude_Of_Origin")
                 .addName(Citations.NETCDF,  "latitude_of_projection_origin")
                 .addName(Citations.GEOTIFF, "ProjCenterLat")
@@ -212,6 +212,17 @@ public final class Equirectangular exten
     }
 
     /**
+     * Notifies {@code DefaultMathTransformFactory} that map projections require
+     * values for the {@code "semi_major"} and {@code "semi_minor"} parameters.
+     *
+     * @return 1, meaning that the operation requires a source ellipsoid.
+     */
+    @Override
+    public final int getEllipsoidsMask() {
+        return 1;
+    }
+
+    /**
      * Gets a parameter value identified by the given descriptor and stores it only if different than zero.
      *
      * @param  source     The parameters from which to read the value.

Copied: sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/FranceGeocentricInterpolation.java (from r1724479, sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/FranceGeocentricInterpolation.java)
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/FranceGeocentricInterpolation.java?p2=sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/FranceGeocentricInterpolation.java&p1=sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/FranceGeocentricInterpolation.java&r1=1724479&r2=1724528&rev=1724528&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/FranceGeocentricInterpolation.java [UTF-8] (original)
+++ sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/FranceGeocentricInterpolation.java [UTF-8] Wed Jan 13 23:25:38 2016
@@ -59,8 +59,9 @@ import org.apache.sis.referencing.operat
 import static java.lang.Float.parseFloat;
 
 // Branch-specific imports
-import java.nio.file.Path;
-import java.nio.file.Paths;
+import java.io.File;
+import org.apache.sis.internal.jdk7.Path;
+import org.apache.sis.internal.jdk7.Paths;
 import org.apache.sis.internal.jdk8.JDK8;
 
 
@@ -145,7 +146,7 @@ public class FranceGeocentricInterpolati
     /**
      * The operation parameter descriptor for the <cite>Geocentric translations file</cite> parameter value.
      */
-    public static final ParameterDescriptor<Path> FILE;
+    public static final ParameterDescriptor<File> FILE;
 
     /**
      * The group of all parameters expected by this coordinate operation. The only parameter formally defined by EPSG
@@ -158,7 +159,7 @@ public class FranceGeocentricInterpolati
         FILE = builder
                 .addIdentifier("8727")
                 .addName("Geocentric translations file")
-                .create(Path.class, Paths.get(DEFAULT));
+                .create(File.class, Paths.get(DEFAULT));
         PARAMETERS = builder
                 .addIdentifier("9655")
                 .addName("France geocentric interpolation")
@@ -314,7 +315,7 @@ public class FranceGeocentricInterpolati
             default: throw new InvalidParameterValueException(Errors.format(
                             Errors.Keys.IllegalArgumentValue_2, "dim", dim), "dim", dim);
         }
-        final Path file = pg.getMandatoryValue(FILE);
+        final Path file = Path.castOrCopy(pg.getMandatoryValue(FILE));
         final DatumShiftGridFile<Angle,Length> grid = getOrLoad(file,
                 isRecognized(file) ? new double[] {TX, TY, TZ} : null, PRECISION);
         MathTransform tr = createGeodeticTransformation(factory,
@@ -363,11 +364,16 @@ public class FranceGeocentricInterpolati
             try {
                 grid = handler.peek();
                 if (grid == null) {
-                    try (final BufferedReader in = JDK8.newBufferedReader(resolved)) {
-                        DatumShiftGridLoader.log(FranceGeocentricInterpolation.class, file);
-                        final DatumShiftGridFile.Float<Angle,Length> g = load(in, file);
-                        grid = DatumShiftGridCompressed.compress(g, averages, scale);
-                    } catch (IOException | NoninvertibleTransformException | RuntimeException e) {
+                    try {
+                        final BufferedReader in = JDK8.newBufferedReader(resolved);
+                        try {
+                            DatumShiftGridLoader.log(FranceGeocentricInterpolation.class, file);
+                            final DatumShiftGridFile.Float<Angle,Length> g = load(in, file);
+                            grid = DatumShiftGridCompressed.compress(g, averages, scale);
+                        } finally {
+                            in.close();
+                        }
+                    } catch (Exception e) {     // Multi-catch on the JDK7 branch.
                         // NumberFormatException, ArithmeticException, NoSuchElementException, possibly other.
                         throw DatumShiftGridLoader.canNotLoad(HEADER, file, e);
                     }
@@ -447,7 +453,7 @@ public class FranceGeocentricInterpolati
                             Δy = gridGeometry[5];
                             nx = JDK8.toIntExact(Math.round((xf - x0) / Δx + 1));
                             ny = JDK8.toIntExact(Math.round((yf - y0) / Δy + 1));
-                            grid = new DatumShiftGridFile.Float<>(3,
+                            grid = new DatumShiftGridFile.Float<Angle,Length>(3,
                                     NonSI.DEGREE_ANGLE, SI.METRE, false,
                                     x0, y0, Δx, Δy, nx, ny, PARAMETERS, file);
                         }

Modified: sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/GeocentricAffineBetweenGeographic.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/GeocentricAffineBetweenGeographic.java?rev=1724528&r1=1724527&r2=1724528&view=diff
==============================================================================
--- sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/GeocentricAffineBetweenGeographic.java [UTF-8] (original)
+++ sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/GeocentricAffineBetweenGeographic.java [UTF-8] Wed Jan 13 23:25:38 2016
@@ -109,6 +109,18 @@ public abstract class GeocentricAffineBe
     }
 
     /**
+     * Notifies {@code DefaultMathTransformFactory} that map projections require values for the
+     * {@code "src_semi_major"}, {@code "src_semi_minor"} , {@code "tgt_semi_major"} and
+     * {@code "tgt_semi_minor"} parameters.
+     *
+     * @return 3, meaning that the operation requires source and target ellipsoids.
+     */
+    @Override
+    public final int getEllipsoidsMask() {
+        return 3;
+    }
+
+    /**
      * Creates a math transform from the specified group of parameter values.
      * This method wraps the affine operation into Geographic/Geocentric conversions.
      *
@@ -144,7 +156,7 @@ public abstract class GeocentricAffineBe
         try {
             toGeographic = toGeographic.inverse();
         } catch (NoninvertibleTransformException e) {
-            throw new FactoryException(e);  // Should never happen with SIS implementation.
+            throw new FactoryException(e);                  // Should never happen with SIS implementation.
         }
         /*
          * The  Geocentric → Affine → Geographic  chain.

Modified: sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/GeocentricToGeographic.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/GeocentricToGeographic.java?rev=1724528&r1=1724527&r2=1724528&view=diff
==============================================================================
--- sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/GeocentricToGeographic.java [UTF-8] (original)
+++ sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/GeocentricToGeographic.java [UTF-8] Wed Jan 13 23:25:38 2016
@@ -77,6 +77,17 @@ public final class GeocentricToGeographi
     }
 
     /**
+     * Notifies {@code DefaultMathTransformFactory} that Geographic/geocentric conversions
+     * require values for the {@code "semi_major"} and {@code "semi_minor"} parameters.
+     *
+     * @return 2, meaning that the operation requires a target ellipsoid.
+     */
+    @Override
+    public int getEllipsoidsMask() {
+        return 2;
+    }
+
+    /**
      * Creates a transform from the specified group of parameter values.
      *
      * @param  factory The factory to use for creating the transform.
@@ -92,7 +103,7 @@ public final class GeocentricToGeographi
         try {
             tr = tr.inverse();
         } catch (NoninvertibleTransformException e) {
-            throw new FactoryException(e);
+            throw new FactoryException(e);                  // Should never happen with SIS implementation.
         }
         return tr;
     }

Modified: sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/Geographic3Dto2D.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/Geographic3Dto2D.java?rev=1724528&r1=1724527&r2=1724528&view=diff
==============================================================================
--- sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/Geographic3Dto2D.java [UTF-8] (original)
+++ sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/Geographic3Dto2D.java [UTF-8] Wed Jan 13 23:25:38 2016
@@ -103,11 +103,11 @@ public final class Geographic3Dto2D exte
     {
         if (transform == null) try {
             final MatrixSIS m = Matrices.createDiagonal(4, 3);
-            m.setElement(2, 2, 0);  // Here is the height value that we want.
+            m.setElement(2, 2, 0);                                  // Here is the height value that we want.
             m.setElement(3, 2, 1);
             transform = MathTransforms.linear(m).inverse();
         } catch (NoninvertibleTransformException e) {
-            throw new FactoryException(e);  // Should never happen.
+            throw new FactoryException(e);                          // Should never happen.
         }
         return transform;
     }

Modified: sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/GeographicOffsets.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/GeographicOffsets.java?rev=1724528&r1=1724527&r2=1724528&view=diff
==============================================================================
--- sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/GeographicOffsets.java [UTF-8] (original)
+++ sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/GeographicOffsets.java [UTF-8] Wed Jan 13 23:25:38 2016
@@ -16,24 +16,26 @@
  */
 package org.apache.sis.internal.referencing.provider;
 
-import javax.xml.bind.annotation.XmlTransient;
+import javax.measure.unit.SI;
 import javax.measure.unit.NonSI;
+import javax.xml.bind.annotation.XmlTransient;
+import org.opengis.parameter.ParameterValueGroup;
 import org.opengis.parameter.ParameterDescriptor;
 import org.opengis.parameter.ParameterDescriptorGroup;
 import org.opengis.parameter.ParameterNotFoundException;
-import org.opengis.parameter.ParameterValueGroup;
 import org.opengis.referencing.operation.MathTransform;
 import org.opengis.referencing.operation.MathTransformFactory;
 import org.opengis.referencing.operation.Transformation;
-import org.apache.sis.internal.referencing.j2d.AffineTransform2D;
 import org.apache.sis.parameter.ParameterBuilder;
 import org.apache.sis.parameter.Parameters;
+import org.apache.sis.referencing.operation.matrix.Matrix4;
+import org.apache.sis.referencing.operation.transform.MathTransforms;
 
 
 /**
- * The provider for <cite>"Geographic2D offsets"</cite> (EPSG:9619).
- * The default implementation handles the 2D case.
- * The {@link GeographicOffsets3D} subclass adds a third dimension.
+ * Base class for all transformations that perform a translation in the geographic domain.
+ * This base class defines a provider for <cite>"Geographic3D offsets"</cite> (EPSG:9660),
+ * but subclasses will provide different operations.
  *
  * @author  Martin Desruisseaux (Geomatys)
  * @since   0.7
@@ -58,28 +60,34 @@ public class GeographicOffsets extends A
     static final ParameterDescriptor<Double> TY;
 
     /**
+     * The operation parameter descriptor for the <cite>"Vertical Offset"</cite> parameter value.
+     */
+    static final ParameterDescriptor<Double> TZ;
+
+    /**
      * The group of all parameters expected by this coordinate operation.
      */
     private static final ParameterDescriptorGroup PARAMETERS;
     static {
         final ParameterBuilder builder = builder();
-        TY = builder.addIdentifier("8601").addName("Latitude offset").create(0, NonSI.DEGREE_ANGLE);
+        TY = builder.addIdentifier("8601").addName("Latitude offset") .create(0, NonSI.DEGREE_ANGLE);
         TX = builder.addIdentifier("8602").addName("Longitude offset").create(0, NonSI.DEGREE_ANGLE);
-        PARAMETERS = builder.addIdentifier("9619").addName("Geographic2D offsets").createGroup(TY, TX);
+        TZ = builder.addIdentifier("8603").addName("Vertical Offset") .create(0, SI.METRE);
+        PARAMETERS = builder.addIdentifier("9660").addName("Geographic3D offsets").createGroup(TY, TX, TZ);
     }
 
     /**
      * Constructs a provider with default parameters.
      */
     public GeographicOffsets() {
-        super(2, 2, PARAMETERS);
+        super(3, 3, PARAMETERS);
     }
 
     /**
-     * For subclass constructor only.
+     * For subclasses constructor only.
      */
-    GeographicOffsets(ParameterDescriptorGroup parameters) {
-        super(3, 3, parameters);
+    GeographicOffsets(int dim, ParameterDescriptorGroup parameters) {
+        super(dim, dim, parameters);
     }
 
     /**
@@ -94,7 +102,7 @@ public class GeographicOffsets extends A
 
     /**
      * Creates a transform from the specified group of parameter values.
-     * The parameter values are unconditionally converted to degrees.
+     * The parameter values are unconditionally converted to degrees and metres.
      *
      * @param  factory Ignored (can be null).
      * @param  values The group of parameter values.
@@ -106,6 +114,10 @@ public class GeographicOffsets extends A
             throws ParameterNotFoundException
     {
         final Parameters pv = Parameters.castOrWrap(values);
-        return new AffineTransform2D(1, 0, 0, 1, pv.doubleValue(TX), pv.doubleValue(TY));
+        final Matrix4 t = new Matrix4();
+        t.m03 = pv.doubleValue(TX);
+        t.m13 = pv.doubleValue(TY);
+        t.m23 = pv.doubleValue(TZ);
+        return MathTransforms.linear(t);
     }
 }

Modified: sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/GeographicToGeocentric.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/GeographicToGeocentric.java?rev=1724528&r1=1724527&r2=1724528&view=diff
==============================================================================
--- sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/GeographicToGeocentric.java [UTF-8] (original)
+++ sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/GeographicToGeocentric.java [UTF-8] Wed Jan 13 23:25:38 2016
@@ -84,6 +84,17 @@ public final class GeographicToGeocentri
     }
 
     /**
+     * Notifies {@code DefaultMathTransformFactory} that Geographic/geocentric conversions
+     * require values for the {@code "semi_major"} and {@code "semi_minor"} parameters.
+     *
+     * @return 1, meaning that the operation requires a source ellipsoid.
+     */
+    @Override
+    public int getEllipsoidsMask() {
+        return 1;
+    }
+
+    /**
      * Creates a transform from the specified group of parameter values.
      *
      * @param  factory The factory to use for creating the transform.

Modified: sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/LongitudeRotation.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/LongitudeRotation.java?rev=1724528&r1=1724527&r2=1724528&view=diff
==============================================================================
--- sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/LongitudeRotation.java [UTF-8] (original)
+++ sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/LongitudeRotation.java [UTF-8] Wed Jan 13 23:25:38 2016
@@ -20,7 +20,6 @@ import javax.xml.bind.annotation.XmlTran
 import org.opengis.parameter.ParameterValueGroup;
 import org.opengis.parameter.ParameterDescriptorGroup;
 import org.opengis.parameter.ParameterNotFoundException;
-import org.opengis.referencing.operation.Transformation;
 import org.opengis.referencing.operation.MathTransform;
 import org.opengis.referencing.operation.MathTransformFactory;
 import org.apache.sis.internal.referencing.j2d.AffineTransform2D;
@@ -45,11 +44,11 @@ import org.apache.sis.parameter.Paramete
  *
  * @author  Martin Desruisseaux (IRD, Geomatys)
  * @since   0.6
- * @version 0.6
+ * @version 0.7
  * @module
  */
 @XmlTransient
-public final class LongitudeRotation extends AbstractProvider {
+public final class LongitudeRotation extends GeographicOffsets {
     /**
      * Serial number for inter-operability with different versions.
      */
@@ -60,24 +59,14 @@ public final class LongitudeRotation ext
      */
     private static final ParameterDescriptorGroup PARAMETERS;
     static {
-        PARAMETERS = builder().addIdentifier("9601").addName("Longitude rotation").createGroup(GeographicOffsets.TX);
+        PARAMETERS = builder().addIdentifier("9601").addName("Longitude rotation").createGroup(TX);
     }
 
     /**
      * Constructs a provider with default parameters.
      */
     public LongitudeRotation() {
-        super(2, 2, PARAMETERS);
-    }
-
-    /**
-     * Returns the operation type.
-     *
-     * @return Interface implemented by all coordinate operations that use this method.
-     */
-    @Override
-    public Class<Transformation> getOperationType() {
-        return Transformation.class;
+        super(2, PARAMETERS);
     }
 
     /**
@@ -100,7 +89,7 @@ public final class LongitudeRotation ext
     public MathTransform createMathTransform(final MathTransformFactory factory, final ParameterValueGroup values)
             throws ParameterNotFoundException
     {
-        final double offset = Parameters.castOrWrap(values).doubleValue(GeographicOffsets.TX);
-        return new AffineTransform2D(1, 0, 0, 1, offset, 0);
+        final Parameters pv = Parameters.castOrWrap(values);
+        return new AffineTransform2D(1, 0, 0, 1, pv.doubleValue(TX), 0);
     }
 }

Modified: sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/MapProjection.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/MapProjection.java?rev=1724528&r1=1724527&r2=1724528&view=diff
==============================================================================
--- sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/MapProjection.java [UTF-8] (original)
+++ sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/MapProjection.java [UTF-8] Wed Jan 13 23:25:38 2016
@@ -203,6 +203,17 @@ public abstract class MapProjection exte
      */
     protected abstract NormalizedProjection createProjection(final Parameters parameters) throws ParameterNotFoundException;
 
+    /**
+     * Notifies {@code DefaultMathTransformFactory} that map projections require
+     * values for the {@code "semi_major"} and {@code "semi_minor"} parameters.
+     *
+     * @return 1, meaning that the operation requires a source ellipsoid.
+     */
+    @Override
+    public final int getEllipsoidsMask() {
+        return 1;
+    }
+
 
 
 

Modified: sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/Molodensky.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/Molodensky.java?rev=1724528&r1=1724527&r2=1724528&view=diff
==============================================================================
--- sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/Molodensky.java [UTF-8] (original)
+++ sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/Molodensky.java [UTF-8] Wed Jan 13 23:25:38 2016
@@ -96,27 +96,24 @@ public final class Molodensky extends Ge
         final ParameterBuilder builder = builder();
         AXIS_LENGTH_DIFFERENCE = builder.addName("Semi-major axis length difference").create(Double.NaN, SI.METRE);
         FLATTENING_DIFFERENCE  = builder.addName("Flattening difference").createBounded(-1, +1, Double.NaN, Unit.ONE);
-        builder.setRequired(false);
-        ParameterDescriptor<Double> a = builder.addName(TGT_SEMI_MAJOR.getName()).createStrictlyPositive(Double.NaN, SI.METRE);
-        ParameterDescriptor<Double> b = builder.addName(TGT_SEMI_MINOR.getName()).createStrictlyPositive(Double.NaN, SI.METRE);
         PARAMETERS = builder.setRequired(true)
                 .addIdentifier("9604")
                 .addName("Molodensky")
                 .addName(Citations.OGC, "Molodenski")
                 .createGroup(DIMENSION,                         // OGC only
+                             SRC_SEMI_MAJOR, SRC_SEMI_MINOR,    // OGC only
+                             TGT_SEMI_MAJOR, TGT_SEMI_MINOR,    // OGC only - redundant with differences
                              TX,                                // OGC and EPSG
                              TY,                                // OGC and EPSG
                              TZ,                                // OGC and EPSG
                              AXIS_LENGTH_DIFFERENCE,            // EPSG only
-                             FLATTENING_DIFFERENCE,             // EPSG only
-                             SRC_SEMI_MAJOR, SRC_SEMI_MINOR,    // OGC only
-                             a, b);                             // OGC only
+                             FLATTENING_DIFFERENCE);            // EPSG only
     }
 
     /**
      * Creates a descriptor for the internal parameters of {@link MolodenskyTransform}.
-     * This is identical to the standard parameters except that the last 3 OGC parameters
-     * are replaced by the eccentricity.
+     * This is similar to the standard parameters except that the redundant target axes
+     * lengths are omitted.
      *
      * @return Internal parameter descriptor.
      */
@@ -126,19 +123,19 @@ public final class Molodensky extends Ge
         ParameterDescriptor<Boolean> abridged = builder.addName("abridged").create(Boolean.class, null);
         return builder.addName("Molodensky")
                 .createGroup(DIMENSION,
+                             SRC_SEMI_MAJOR,
+                             SRC_SEMI_MINOR,
+                             AXIS_LENGTH_DIFFERENCE,
+                             FLATTENING_DIFFERENCE,
                              TX,
                              TY,
                              TZ,
-                             AXIS_LENGTH_DIFFERENCE,
-                             FLATTENING_DIFFERENCE,
-                             SRC_SEMI_MAJOR,
-                             MapProjection.ECCENTRICITY,
                              abridged);
     }
 
     /**
      * The providers for all combinations between 2D and 3D cases.
-     * Array length is 4. Index is build with following rule:
+     * Array length is 4. Index is built with following rule:
      * <ul>
      *   <li>Bit 1: dimension of source coordinates (0 for 2D, 1 for 3D).</li>
      *   <li>Bit 0: dimension of target coordinates (0 for 2D, 1 for 3D).</li>

Copied: sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/NADCON.java (from r1724479, sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/NADCON.java)
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/NADCON.java?p2=sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/NADCON.java&p1=sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/NADCON.java&r1=1724479&r2=1724528&rev=1724528&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/NADCON.java [UTF-8] (original)
+++ sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/NADCON.java [UTF-8] Wed Jan 13 23:25:38 2016
@@ -43,9 +43,10 @@ import org.apache.sis.util.resources.Err
 import org.apache.sis.internal.system.DataDirectory;
 
 // Branch-dependent imports
-import java.nio.file.Path;
-import java.nio.file.Paths;
-import java.nio.file.Files;
+import java.io.File;
+import org.apache.sis.internal.jdk7.Path;
+import org.apache.sis.internal.jdk7.Paths;
+import org.apache.sis.internal.jdk7.Files;
 
 
 /**
@@ -75,13 +76,13 @@ public final class NADCON extends Abstra
      * The operation parameter descriptor for the <cite>"Latitude difference file"</cite> parameter value.
      * The default value is {@code "conus.las"}.
      */
-    private static final ParameterDescriptor<Path> LATITUDE;
+    private static final ParameterDescriptor<File> LATITUDE;
 
     /**
      * The operation parameter descriptor for the <cite>"Longitude difference file"</cite> parameter value.
      * The default value is {@code "conus.los"}.
      */
-    private static final ParameterDescriptor<Path> LONGITUDE;
+    private static final ParameterDescriptor<File> LONGITUDE;
 
     /**
      * The group of all parameters expected by this coordinate operation.
@@ -92,11 +93,11 @@ public final class NADCON extends Abstra
         LATITUDE = builder
                 .addIdentifier("8657")
                 .addName("Latitude difference file")
-                .create(Path.class, Paths.get("conus.las"));
+                .create(File.class, Paths.get("conus.las"));
         LONGITUDE = builder
                 .addIdentifier("8658")
                 .addName("Longitude difference file")
-                .create(Path.class, Paths.get("conus.los"));
+                .create(File.class, Paths.get("conus.los"));
         PARAMETERS = builder
                 .addIdentifier("9613")
                 .addName("NADCON")
@@ -135,7 +136,8 @@ public final class NADCON extends Abstra
     {
         final Parameters pg  = Parameters.castOrWrap(values);
         return InterpolatedTransform.createGeodeticTransformation(factory,
-                getOrLoad(pg.getMandatoryValue(LATITUDE), pg.getMandatoryValue(LONGITUDE)));
+                getOrLoad(Path.castOrCopy(pg.getMandatoryValue(LATITUDE)),
+                          Path.castOrCopy(pg.getMandatoryValue(LONGITUDE))));
     }
 
     /**
@@ -151,7 +153,7 @@ public final class NADCON extends Abstra
     {
         final Path rlat = DataDirectory.DATUM_CHANGES.resolve(latitudeShifts).toAbsolutePath();
         final Path rlon = DataDirectory.DATUM_CHANGES.resolve(longitudeShifts).toAbsolutePath();
-        final Object key = new AbstractMap.SimpleImmutableEntry<>(rlat, rlon);
+        final Object key = new AbstractMap.SimpleImmutableEntry<Path,Path>(rlat, rlon);
         DatumShiftGridFile<?,?> grid = DatumShiftGridFile.CACHE.peek(key);
         if (grid == null) {
             final Cache.Handler<DatumShiftGridFile<?,?>> handler = DatumShiftGridFile.CACHE.lock(key);
@@ -164,18 +166,24 @@ public final class NADCON extends Abstra
                         // Note: buffer size must be divisible by the size of 'float' data type.
                         final ByteBuffer buffer = ByteBuffer.allocate(4096).order(ByteOrder.LITTLE_ENDIAN);
                         final FloatBuffer fb = buffer.asFloatBuffer();
-                        try (final ReadableByteChannel in = Files.newByteChannel(rlat)) {
+                        ReadableByteChannel in = Files.newByteChannel(rlat);
+                        try {
                             DatumShiftGridLoader.log(NADCON.class, CharSequences.commonPrefix(
                                     latitudeShifts.toString(), longitudeShifts.toString()).toString() + '…');
                             loader = new Loader(in, buffer, file);
                             loader.readGrid(fb, null, longitudeShifts);
+                        } finally {
+                            in.close();
                         }
                         buffer.clear();
                         file = longitudeShifts;
-                        try (final ReadableByteChannel in = Files.newByteChannel(rlon)) {
+                        in = Files.newByteChannel(rlon);
+                        try {
                             new Loader(in, buffer, file).readGrid(fb, loader, null);
+                        } finally {
+                            in.close();
                         }
-                    } catch (IOException | NoninvertibleTransformException | RuntimeException e) {
+                    } catch (Exception e) {     // Multi-catch on the JDK7 branch.
                         throw DatumShiftGridLoader.canNotLoad("NADCON", file, e);
                     }
                     grid = DatumShiftGridCompressed.compress(loader.grid, null, loader.grid.accuracy);
@@ -392,7 +400,7 @@ public final class NADCON extends Abstra
             if (latitudeShifts == null) {
                 dim   = 1;                          // Dimension of latitudes.
                 scale = DEGREES_TO_SECONDS * Δy;    // NADCON shifts are positive north.
-                grid  = new DatumShiftGridFile.Float<>(2, NonSI.DEGREE_ANGLE, NonSI.DEGREE_ANGLE,
+                grid  = new DatumShiftGridFile.Float<Angle,Angle>(2, NonSI.DEGREE_ANGLE, NonSI.DEGREE_ANGLE,
                         true, x0, y0, Δx, Δy, nx, ny, PARAMETERS, file, longitudeShifts);
                 grid.accuracy = SECOND_PRECISION / DEGREES_TO_SECONDS;
             } else {

Copied: sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/NTv2.java (from r1724479, sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/NTv2.java)
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/NTv2.java?p2=sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/NTv2.java&p1=sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/NTv2.java&r1=1724479&r2=1724528&rev=1724528&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/NTv2.java [UTF-8] (original)
+++ sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/NTv2.java [UTF-8] Wed Jan 13 23:25:38 2016
@@ -51,9 +51,10 @@ import org.apache.sis.util.resources.Err
 import org.apache.sis.util.resources.Messages;
 
 // Branch-dependent imports
-import java.nio.file.Files;
-import java.nio.file.Path;
-import java.nio.charset.StandardCharsets;
+import java.io.File;
+import org.apache.sis.internal.jdk7.Files;
+import org.apache.sis.internal.jdk7.Path;
+import org.apache.sis.internal.jdk7.StandardCharsets;
 import org.apache.sis.internal.jdk8.JDK8;
 
 
@@ -78,7 +79,7 @@ public final class NTv2 extends Abstract
      * The operation parameter descriptor for the <cite>"Latitude and longitude difference file"</cite> parameter value.
      * The file extension is typically {@code ".gsb"}. There is no default value.
      */
-    private static final ParameterDescriptor<Path> FILE;
+    private static final ParameterDescriptor<File> FILE;
 
     /**
      * The group of all parameters expected by this coordinate operation.
@@ -89,7 +90,7 @@ public final class NTv2 extends Abstract
         FILE = builder
                 .addIdentifier("8656")
                 .addName("Latitude and longitude difference file")
-                .create(Path.class, null);
+                .create(File.class, null);
         PARAMETERS = builder
                 .addIdentifier("9615")
                 .addName("NTv2")
@@ -127,7 +128,8 @@ public final class NTv2 extends Abstract
             throws ParameterNotFoundException, FactoryException
     {
         final Parameters pg = Parameters.castOrWrap(values);
-        return InterpolatedTransform.createGeodeticTransformation(factory, getOrLoad(pg.getMandatoryValue(FILE)));
+        return InterpolatedTransform.createGeodeticTransformation(factory,
+                getOrLoad(Path.castOrCopy(pg.getMandatoryValue(FILE))));
     }
 
     /**
@@ -145,12 +147,17 @@ public final class NTv2 extends Abstract
             try {
                 grid = handler.peek();
                 if (grid == null) {
-                    try (final ReadableByteChannel in = Files.newByteChannel(resolved)) {
-                        DatumShiftGridLoader.log(NTv2.class, file);
-                        final Loader loader = new Loader(in, file);
-                        grid = loader.readGrid();
-                        loader.reportWarnings();
-                    } catch (IOException | NoninvertibleTransformException | RuntimeException e) {
+                    try {
+                        final ReadableByteChannel in = Files.newByteChannel(resolved);
+                        try {
+                            DatumShiftGridLoader.log(NTv2.class, file);
+                            final Loader loader = new Loader(in, file);
+                            grid = loader.readGrid();
+                            loader.reportWarnings();
+                        } finally {
+                            in.close();
+                        }
+                    } catch (Exception e) {     // Multi-catch on the JDK7 branch.
                         throw DatumShiftGridLoader.canNotLoad("NTv2", file, e);
                     }
                     grid = grid.useSharedData();
@@ -196,7 +203,7 @@ public final class NTv2 extends Abstract
          */
         private static final Map<String,Integer> TYPES;
         static {
-            final Map<String,Integer> types = new HashMap<>(32);
+            final Map<String,Integer> types = new HashMap<String,Integer>(32);
             final Integer string  = STRING_TYPE;    // Autoboxing
             final Integer integer = INTEGER_TYPE;
             final Integer real    = DOUBLE_TYPE;
@@ -254,7 +261,7 @@ public final class NTv2 extends Abstract
          */
         Loader(final ReadableByteChannel channel, final Path file) throws IOException, FactoryException {
             super(channel, ByteBuffer.allocate(4096), file);
-            this.header = new LinkedHashMap<>();
+            this.header = new LinkedHashMap<String,Object>();
             ensureBufferContains(RECORD_LENGTH);
             if (isLittleEndian(buffer.getInt(KEY_LENGTH))) {
                 buffer.order(ByteOrder.LITTLE_ENDIAN);
@@ -331,7 +338,7 @@ public final class NTv2 extends Abstract
              * sign of longitude translations; instead, this reversal will be handled by grid.coordinateToGrid
              * MathTransform and its inverse.
              */
-            final DatumShiftGridFile.Float<Angle,Angle> grid = new DatumShiftGridFile.Float<>(2,
+            final DatumShiftGridFile.Float<Angle,Angle> grid = new DatumShiftGridFile.Float<Angle,Angle>(2,
                     unit, unit, true, -xmin, ymin, -dx, dy, width, height, PARAMETERS, file);
             @SuppressWarnings("MismatchedReadAndWriteOfArray") final float[] tx = grid.offsets[0];
             @SuppressWarnings("MismatchedReadAndWriteOfArray") final float[] ty = grid.offsets[1];

Modified: sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/TransverseMercator.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/TransverseMercator.java?rev=1724528&r1=1724527&r2=1724528&view=diff
==============================================================================
--- sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/TransverseMercator.java [UTF-8] (original)
+++ sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/TransverseMercator.java [UTF-8] Wed Jan 13 23:25:38 2016
@@ -16,13 +16,20 @@
  */
 package org.apache.sis.internal.referencing.provider;
 
+import javax.measure.unit.Unit;
+import javax.measure.unit.SI;
+import javax.measure.unit.NonSI;
 import javax.xml.bind.annotation.XmlTransient;
 import org.opengis.parameter.ParameterDescriptor;
 import org.opengis.parameter.ParameterDescriptorGroup;
+import org.opengis.parameter.ParameterValueGroup;
+import org.apache.sis.measure.Longitude;
+import org.apache.sis.parameter.Parameters;
 import org.apache.sis.parameter.ParameterBuilder;
 import org.apache.sis.metadata.iso.citation.Citations;
-import org.apache.sis.parameter.Parameters;
 import org.apache.sis.referencing.operation.projection.NormalizedProjection;
+import org.apache.sis.internal.util.Constants;
+import org.apache.sis.math.MathFunctions;
 
 
 /**
@@ -31,7 +38,7 @@ import org.apache.sis.referencing.operat
  * @author  Martin Desruisseaux (MPO, IRD, Geomatys)
  * @author  Rueben Schulz (UBC)
  * @since   0.6
- * @version 0.6
+ * @version 0.7
  * @module
  *
  * @see <a href="http://www.remotesensing.org/geotiff/proj_list/transverse_mercator.html">Transverse Mercator on RemoteSensing.org</a>
@@ -44,6 +51,19 @@ public final class TransverseMercator ex
     private static final long serialVersionUID = -3386587506686432398L;
 
     /**
+     * Width of a Universal Transverse Mercator (UTM) zone, in degrees.
+     *
+     * @see #zone(double)
+     * @see #centralMeridian(int)
+     */
+    private static final double ZONE_WIDTH = 6;
+
+    /**
+     * The {@value} string, which is also the EPSG name for this projection.
+     */
+    public static final String NAME = "Transverse Mercator";
+
+    /**
      * The operation parameter descriptor for the <cite>Latitude of natural origin</cite> (φ₀) parameter value.
      * Valid values range is [-90 … 90]° and default value is 0°.
      */
@@ -64,7 +84,7 @@ public final class TransverseMercator ex
     /**
      * The group of all parameters expected by this coordinate operation.
      */
-    private static final ParameterDescriptorGroup PARAMETERS;
+    static final ParameterDescriptorGroup PARAMETERS;
     static {
         final ParameterBuilder builder = builder();
         LATITUDE_OF_ORIGIN = createLatitude(builder
@@ -80,7 +100,7 @@ public final class TransverseMercator ex
 
         PARAMETERS = builder
                 .addIdentifier(              "9807")
-                .addName(                    "Transverse Mercator")
+                .addName(                    NAME)
                 .addName(                    "Gauss-Kruger")
                 .addName(                    "Gauss-Boaga")
                 .addName(                    "TM")
@@ -119,4 +139,81 @@ public final class TransverseMercator ex
     protected NormalizedProjection createProjection(final Parameters parameters) {
         return new org.apache.sis.referencing.operation.projection.TransverseMercator(this, parameters);
     }
+
+    /**
+     * Sets the parameter values for a Transverse Mercator projection and returns a suggested conversion name.
+     *
+     * <blockquote><table class="sis">
+     *   <caption>Transverse Mercator parameters</caption>
+     *   <tr><th>Parameter name</th>                 <th>Value</th></tr>
+     *   <tr><td>Latitude of natural origin</td>     <td>Given latitude, or 0° if UTM projection</td></tr>
+     *   <tr><td>Longitude of natural origin</td>    <td>Given longitude, optionally snapped to a UTM central meridian</td></tr>
+     *   <tr><td>Scale factor at natural origin</td> <td>0.9996</td></tr>
+     *   <tr><td>False easting</td>                  <td>500000 metres</td></tr>
+     *   <tr><td>False northing</td>                 <td>0 (North hemisphere) or 10000000 (South hemisphere) metres</td></tr>
+     * </table></blockquote>
+     *
+     * @param  group      The parameters for which to set the values.
+     * @param  isUTM      {@code true} for Universal Transverse Mercator (UTM) projection.
+     * @param  latitude   The latitude in the center of the desired projection.
+     * @param  longitude  The longitude in the center of the desired projection.
+     * @return A name like <cite>"Transverse Mercator"</cite> or <cite>"UTM zone 10N"</cite>,
+     *         depending on the arguments given to this method.
+     *
+     * @since 0.7
+     */
+    public static String setParameters(final ParameterValueGroup group,
+            final boolean isUTM, double latitude, double longitude)
+    {
+        final boolean isSouth = MathFunctions.isNegative(latitude);
+        int zone = zone(longitude);
+        if (isUTM) {
+            latitude = 0;
+            longitude = centralMeridian(zone);
+        } else if (longitude != centralMeridian(zone)) {
+            zone = 0;
+        }
+        String name = NAME;
+        if (zone != 0) {
+            name = "UTM zone " + zone + (isSouth ? 'S' : 'N');
+        }
+        group.parameter(Constants.LATITUDE_OF_ORIGIN).setValue(latitude,  NonSI.DEGREE_ANGLE);
+        group.parameter(Constants.CENTRAL_MERIDIAN)  .setValue(longitude, NonSI.DEGREE_ANGLE);
+        group.parameter(Constants.SCALE_FACTOR)      .setValue(0.9996, Unit.ONE);
+        group.parameter(Constants.FALSE_EASTING)     .setValue(500000, SI.METRE);
+        group.parameter(Constants.FALSE_NORTHING)    .setValue(isSouth ? 10000000 : 0, SI.METRE);
+        return name;
+    }
+
+    /**
+     * Computes the UTM zone from a meridian in the zone.
+     *
+     * @param  longitude A meridian inside the desired zone, in degrees relative to Greenwich.
+     *         Positive longitudes are toward east, and negative longitudes toward west.
+     * @return The UTM zone number numbered from 1 to 60 inclusive, or 0 if the given central meridian was NaN.
+     *
+     * @since 0.7
+     */
+    public static int zone(double longitude) {
+        /*
+         * Casts to int are equivalent to Math.floor(double) for positive values, which is guaranteed
+         * to be the case here since we normalize the central meridian to the [MIN_VALUE … MAX_VALUE] range.
+         */
+        double z = (longitude - Longitude.MIN_VALUE) / ZONE_WIDTH;                          // Zone number with fractional part.
+        z -= Math.floor(z / ((Longitude.MAX_VALUE - Longitude.MIN_VALUE) / ZONE_WIDTH))     // Roll in the [0 … 60) range.
+                          * ((Longitude.MAX_VALUE - Longitude.MIN_VALUE) / ZONE_WIDTH);
+        return (int) (z + 1);   // Cast only after addition in order to handle NaN as documented.
+    }
+
+    /**
+     * Computes the central meridian of a given UTM zone.
+     *
+     * @param zone The UTM zone as a number in the [1 … 60] range.
+     * @return The central meridian of the given UTM zone.
+     *
+     * @since 0.7
+     */
+    public static double centralMeridian(final int zone) {
+        return (zone - 0.5) * ZONE_WIDTH + Longitude.MIN_VALUE;
+    }
 }

Modified: sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/parameter/DefaultParameterValue.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/parameter/DefaultParameterValue.java?rev=1724528&r1=1724527&r2=1724528&view=diff
==============================================================================
--- sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/parameter/DefaultParameterValue.java [UTF-8] (original)
+++ sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/parameter/DefaultParameterValue.java [UTF-8] Wed Jan 13 23:25:38 2016
@@ -44,11 +44,14 @@ import org.apache.sis.internal.referenci
 import org.apache.sis.internal.metadata.WKTKeywords;
 import org.apache.sis.internal.util.PatchedUnitFormat;
 import org.apache.sis.internal.util.Numerics;
+import org.apache.sis.internal.system.Loggers;
 import org.apache.sis.util.Numbers;
 import org.apache.sis.util.ComparisonMode;
 import org.apache.sis.util.LenientComparable;
 import org.apache.sis.util.ObjectConverters;
 import org.apache.sis.util.resources.Errors;
+import org.apache.sis.util.logging.Logging;
+import org.apache.sis.util.UnconvertibleObjectException;
 
 import static org.apache.sis.util.ArgumentChecks.ensureNonNull;
 import static org.apache.sis.util.Utilities.deepEquals;
@@ -504,6 +507,19 @@ public class DefaultParameterValue<T> ex
     }
 
     /**
+     * Same as {@link #isFile(Object)}, but accepts also a {@link String} if the type specified
+     * in the parameter descriptor is one of the types documented in {@link #valueFile()}.
+     */
+    private boolean isOrNeedFile(final Object value) {
+        if (value instanceof String) {
+            final Class<?> type = descriptor.getValueClass();
+            return (type == URI.class) || (type == URL.class)
+                   || File.class.isAssignableFrom(type);
+        }
+        return isFile(value);
+    }
+
+    /**
      * Returns the exception to throw when an incompatible method is invoked for the value type.
      */
     private IllegalStateException missingOrIncompatibleValue(final Object value) {
@@ -539,9 +555,25 @@ public class DefaultParameterValue<T> ex
      * @see #getValue()
      */
     @Override
-    public void setValue(final Object value) throws InvalidParameterValueException {
-        // Use 'unit' instead than 'getUnit()' despite class Javadoc claims because units are not expected
-        // to be involved in this method. We just want the current unit setting to be unchanged.
+    public void setValue(Object value) throws InvalidParameterValueException {
+        /*
+         * Try to convert the value only for a limited amount of types. In particular we want to allow conversions
+         * between java.io.File and java.nio.file.Path for easier transition between JDK6 and JDK7. We do not want
+         * to allow too many conversions for reducing the risk of unexpected behavior.  If we fail to convert, try
+         * to set the value anyway since the user may have redefined the setValue(Object, Unit) method.
+         */
+        if (isOrNeedFile(value)) try {
+            value = ObjectConverters.convert(value, descriptor.getValueClass());
+        } catch (UnconvertibleObjectException e) {
+            // Level.FINE (not WARNING) because this log duplicates the exception
+            // that 'setValue(Object, Unit)' may throw (with a better message).
+            Logging.recoverableException(Logging.getLogger(Loggers.COORDINATE_OPERATION),
+                    DefaultParameterValue.class, "setValue", e);
+        }
+        /*
+         * Use 'unit' instead than 'getUnit()' despite class Javadoc claims because units are not expected
+         * to be involved in this method. We just want the current unit setting to be unchanged.
+         */
         setValue(value, unit);
     }
 
@@ -829,6 +861,8 @@ public class DefaultParameterValue<T> ex
      * @return An unmodifiable implementation of the given parameter, or {@code null} if the given parameter was null.
      *
      * @since 0.6
+     *
+     * @see DefaultParameterValueGroup#unmodifiable(ParameterValueGroup)
      */
     public static <T> DefaultParameterValue<T> unmodifiable(final ParameterValue<T> parameter) {
         return UnmodifiableParameterValue.create(parameter);
@@ -895,9 +929,9 @@ public class DefaultParameterValue<T> ex
         WKTUtilities.appendName(descriptor, formatter, ElementKind.PARAMETER);
         final Convention convention = formatter.getConvention();
         final boolean isWKT1 = convention.majorVersion() == 1;
-        Unit<?> unit = getUnit();   // Gives to users a chance to override this property.
+        Unit<?> unit = getUnit();                                   // Gives to users a chance to override this property.
         if (unit == null) {
-            final T value = getValue();   // Gives to users a chance to override this property.
+            final T value = getValue();                             // Gives to users a chance to override this property.
             if (!isWKT1 && isFile(value)) {
                 formatter.append(value.toString(), null);
                 return WKTKeywords.ParameterFile;

Modified: sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/parameter/DefaultParameterValueGroup.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/parameter/DefaultParameterValueGroup.java?rev=1724528&r1=1724527&r2=1724528&view=diff
==============================================================================
--- sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/parameter/DefaultParameterValueGroup.java [UTF-8] (original)
+++ sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/parameter/DefaultParameterValueGroup.java [UTF-8] Wed Jan 13 23:25:38 2016
@@ -18,8 +18,10 @@ package org.apache.sis.parameter;
 
 import java.util.List;
 import java.util.ArrayList;
+import java.util.LinkedList;
 import java.util.Map;
 import java.util.IdentityHashMap;
+import java.util.Iterator;
 import java.io.Serializable;
 import javax.xml.bind.annotation.XmlType;
 import javax.xml.bind.annotation.XmlElement;
@@ -38,9 +40,7 @@ import org.apache.sis.util.LenientCompar
 import org.apache.sis.util.ComparisonMode;
 import org.apache.sis.util.resources.Errors;
 import org.apache.sis.util.ArgumentChecks;
-
-import static org.apache.sis.util.Utilities.deepEquals;
-import static org.apache.sis.referencing.IdentifiedObjects.isHeuristicMatchForName;
+import org.apache.sis.util.Utilities;
 
 // Branch-dependent imports
 import org.apache.sis.internal.jdk7.Objects;
@@ -103,7 +103,7 @@ import org.apache.sis.internal.jdk7.Obje
  *
  * @author  Martin Desruisseaux (IRD, Geomatys)
  * @since   0.4
- * @version 0.6
+ * @version 0.7
  * @module
  *
  * @see DefaultParameterDescriptorGroup
@@ -206,7 +206,7 @@ public class DefaultParameterValueGroup
     @Override
     @SuppressWarnings("ReturnOfCollectionOrArrayField")
     public List<GeneralParameterValue> values() {
-        return values;  // Intentionally modifiable.
+        return values;                                          // Intentionally modifiable.
     }
 
     /**
@@ -305,7 +305,7 @@ public class DefaultParameterValueGroup
         for (int i=0; i<size; i++) {
             final GeneralParameterDescriptor descriptor = values.descriptor(i);
             if (descriptor instanceof ParameterDescriptor<?>) {
-                if (isHeuristicMatchForName(descriptor, name)) {
+                if (IdentifiedObjects.isHeuristicMatchForName(descriptor, name)) {
                     if (fallback < 0) {
                         fallback = i;
                     } else {
@@ -334,7 +334,7 @@ public class DefaultParameterValueGroup
      *
      * @param  name The name of the parameter to search for.
      * @return The set of all parameter group for the given name.
-     * @throws ParameterNotFoundException If no descriptor was found for the given name.
+     * @throws ParameterNotFoundException if no descriptor was found for the given name.
      */
     @Override
     public List<ParameterValueGroup> groups(final String name) throws ParameterNotFoundException {
@@ -345,7 +345,7 @@ public class DefaultParameterValueGroup
         for (int i=0; i<size; i++) {
             final GeneralParameterDescriptor descriptor = values.descriptor(i);
             if (descriptor instanceof ParameterDescriptorGroup) {
-                if (isHeuristicMatchForName(descriptor, name)) {
+                if (IdentifiedObjects.isHeuristicMatchForName(descriptor, name)) {
                     groups.add((ParameterValueGroup) values.get(i));
                 }
             }
@@ -358,8 +358,8 @@ public class DefaultParameterValueGroup
         if (groups.isEmpty()) {
             final ParameterDescriptorGroup descriptor = values.descriptor;
             if (!(descriptor.descriptor(name) instanceof ParameterDescriptorGroup)) {
-                throw new ParameterNotFoundException(Errors.format(
-                        Errors.Keys.ParameterNotFound_2, descriptor.getName(), name), name);
+                throw new ParameterNotFoundException(Errors.format(Errors.Keys.ParameterNotFound_2,
+                        Verifier.getDisplayName(descriptor), name), name);
             }
         }
         return groups;
@@ -377,8 +377,8 @@ public class DefaultParameterValueGroup
      *
      * @param  name The name of the parameter group to create.
      * @return A newly created parameter group for the given name.
-     * @throws ParameterNotFoundException If no descriptor was found for the given name.
-     * @throws InvalidParameterCardinalityException If this parameter group already contains the
+     * @throws ParameterNotFoundException if no descriptor was found for the given name.
+     * @throws InvalidParameterCardinalityException if this parameter group already contains the
      *         {@linkplain ParameterDescriptorGroup#getMaximumOccurs() maximum number of occurrences}
      *         of subgroups of the given name.
      */
@@ -400,7 +400,14 @@ public class DefaultParameterValueGroup
 
     /**
      * Compares the specified object with this parameter for equality.
-     * The strictness level is controlled by the second argument.
+     * The strictness level is controlled by the second argument:
+     *
+     * <ul>
+     *   <li>{@link ComparisonMode#STRICT} and {@link ComparisonMode#BY_CONTRACT BY_CONTRACT}
+     *       take in account the parameter order.</li>
+     *   <li>{@link ComparisonMode#IGNORE_METADATA} and {@link ComparisonMode#APPROXIMATIVE APPROXIMATIVE}
+     *       ignore the order of parameter values (but not necessarily the order of parameter descriptors).</li>
+     * </ul>
      *
      * @param  object The object to compare to {@code this}.
      * @param  mode The strictness level of the comparison.
@@ -420,15 +427,37 @@ public class DefaultParameterValueGroup
                            Objects.equals(values, that.values);
                 }
             } else if (object instanceof ParameterValueGroup) {
-                final ParameterValueGroup that = (ParameterValueGroup) object;
-                return deepEquals(getDescriptor(), that.getDescriptor(), mode) &&
-                       deepEquals(values(), that.values(), mode);
+                return equals(this, (ParameterValueGroup) object, mode);
             }
         }
         return false;
     }
 
     /**
+     * Compares the given objects for equality, ignoring parameter order in "ignore metadata" mode.
+     */
+    static boolean equals(final Parameters expected, final ParameterValueGroup actual, final ComparisonMode mode) {
+        if (!Utilities.deepEquals(expected.getDescriptor(), actual.getDescriptor(), mode)) {
+            return false;
+        }
+        if (!mode.isIgnoringMetadata()) {
+            return Utilities.deepEquals(expected.values(), actual.values(), mode);
+        }
+        final List<GeneralParameterValue> values = new LinkedList<GeneralParameterValue>(expected.values());
+scan:   for (final GeneralParameterValue param : actual.values()) {
+            final Iterator<GeneralParameterValue> it = values.iterator();
+            while (it.hasNext()) {
+                if (Utilities.deepEquals(it.next(), param, mode)) {
+                    it.remove();
+                    continue scan;
+                }
+            }
+            return false;   // A parameter from 'actual' has not been found in 'expected'.
+        }
+        return values.isEmpty();
+    }
+
+    /**
      * Compares the specified object with this parameter for equality.
      * This method is implemented as below:
      *
@@ -449,7 +478,7 @@ public class DefaultParameterValueGroup
     /**
      * Returns a hash value for this parameter.
      *
-     * @return The hash code value. This value doesn't need to be the same
+     * @return The hash code value. This value does not need to be the same
      *         in past or future versions of this class.
      */
     @Override

Modified: sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/parameter/ParameterBuilder.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/parameter/ParameterBuilder.java?rev=1724528&r1=1724527&r2=1724528&view=diff
==============================================================================
--- sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/parameter/ParameterBuilder.java [UTF-8] (original)
+++ sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/parameter/ParameterBuilder.java [UTF-8] Wed Jan 13 23:25:38 2016
@@ -20,9 +20,6 @@ import javax.measure.unit.Unit;
 import org.opengis.parameter.ParameterDescriptor;
 import org.opengis.parameter.ParameterDescriptorGroup;
 import org.opengis.parameter.GeneralParameterDescriptor;
-import org.opengis.parameter.ParameterValueGroup;
-import org.opengis.referencing.cs.CoordinateSystem;             // For javadoc
-import org.opengis.referencing.crs.CoordinateReferenceSystem;   // For javadoc
 import org.apache.sis.measure.MeasurementRange;
 import org.apache.sis.measure.NumberRange;
 import org.apache.sis.measure.Range;
@@ -428,8 +425,6 @@ public class ParameterBuilder extends Bu
      *         for the group to create.
      * @return The parameter descriptor group for a map projection.
      *
-     * @see org.apache.sis.referencing.operation.transform.DefaultMathTransformFactory#createBaseToDerived(CoordinateReferenceSystem, ParameterValueGroup, CoordinateSystem)
-     *
      * @since 0.6
      */
     public ParameterDescriptorGroup createGroupForMapProjection(final ParameterDescriptor<?>... parameters) {

Modified: sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/parameter/Parameters.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/parameter/Parameters.java?rev=1724528&r1=1724527&r2=1724528&view=diff
==============================================================================
--- sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/parameter/Parameters.java [UTF-8] (original)
+++ sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/parameter/Parameters.java [UTF-8] Wed Jan 13 23:25:38 2016
@@ -124,6 +124,24 @@ public abstract class Parameters impleme
     }
 
     /**
+     * Returns the given parameter value group as an unmodifiable {@code Parameters} instance.
+     * If the given parameters is already an unmodifiable instance of {@code Parameters},
+     * then it is returned as-is. Otherwise this method copies all parameter values in a new,
+     * unmodifiable, parameter group instance.
+     *
+     * @param  parameters The parameters to make unmodifiable, or {@code null}.
+     * @return An unmodifiable group with the same parameters than the given group,
+     *         or {@code null} if the given argument was null.
+     *
+     * @since 0.7
+     *
+     * @see DefaultParameterValue#unmodifiable(ParameterValue)
+     */
+    public static Parameters unmodifiable(final ParameterValueGroup parameters) {
+        return UnmodifiableParameterValueGroup.create(parameters);
+    }
+
+    /**
      * Returns the given parameter value group as a {@code Parameters} instance.
      * If the given parameters is already an instance of {@code Parameters}, then it is returned as-is.
      * Otherwise this method returns a wrapper which delegate all method invocations to the given instance.
@@ -352,15 +370,32 @@ public abstract class Parameters impleme
      * The {@link DefaultParameterValueGroup} subclass will override this method with a more efficient
      * implementation which avoid creating some deferred parameters.
      */
+    @SuppressWarnings("null")
     ParameterValue<?> parameterIfExist(final String name) throws ParameterNotFoundException {
+        ParameterValue<?> fallback  = null;
+        ParameterValue<?> ambiguity = null;
         for (final GeneralParameterValue value : values()) {
             if (value instanceof ParameterValue<?>) {
-                if (isHeuristicMatchForName(value.getDescriptor(), name)) {
-                    return (ParameterValue<?>) value;
+                final ParameterValue<?> param = (ParameterValue<?>) value;
+                final ParameterDescriptor<?> descriptor = param.getDescriptor();
+                if (name.equals(descriptor.getName().toString())) {
+                    return param;
+                }
+                if (isHeuristicMatchForName(descriptor, name)) {
+                    if (fallback == null) {
+                        fallback = param;
+                    } else {
+                        ambiguity = param;
+                    }
                 }
             }
         }
-        return null;
+        if (ambiguity != null) {
+            throw new ParameterNotFoundException(Errors.format(Errors.Keys.AmbiguousName_3,
+                    IdentifiedObjects.toString(fallback .getDescriptor().getName()),
+                    IdentifiedObjects.toString(ambiguity.getDescriptor().getName()), name), name);
+        }
+        return fallback;
     }
 
     /**
@@ -408,7 +443,7 @@ public abstract class Parameters impleme
     }
 
     /**
-     * Returns the value of the parameter identified by the given descriptor.
+     * Returns the value of the parameter identified by the given descriptor, or {@code null} if none.
      * This method uses the following information from the given {@code parameter} descriptor:
      *
      * <ul>
@@ -465,6 +500,30 @@ public abstract class Parameters impleme
     }
 
     /**
+     * Returns the value of the parameter identified by the given descriptor, or throws an exception if none.
+     * The default implementation invokes {@link #getValue(ParameterDescriptor)} and verifies that the returned
+     * value is non-null.
+     *
+     * @param  <T> The type of the parameter value.
+     * @param  parameter The name or alias of the parameter to look for, together with the desired type and unit of value.
+     * @return The requested parameter value if it exists, or the {@linkplain DefaultParameterDescriptor#getDefaultValue()
+     *         default value} otherwise provided that it is not {@code null}.
+     * @throws ParameterNotFoundException if the given {@code parameter} name or alias is not legal for this group.
+     * @throws IllegalStateException if the value is not defined and there is no default value.
+     *
+     * @since 0.7
+     */
+    public <T> T getMandatoryValue(final ParameterDescriptor<T> parameter) throws ParameterNotFoundException {
+        final T value = getValue(parameter);
+        if (value != null) {
+            return value;
+        } else {
+            throw new IllegalStateException(Errors.format(Errors.Keys.MissingValueForParameter_1,
+                    Verifier.getDisplayName(parameter)));
+        }
+    }
+
+    /**
      * Returns the default value of the given descriptor, or throws an exception if the
      * descriptor does not define a default value. This check should be kept consistent
      * with the {@link DefaultParameterValue#incompatibleValue(Object)} check.
@@ -721,7 +780,7 @@ public abstract class Parameters impleme
                     target.setValue(((Number) v).doubleValue(), unit);
                 } else if (v instanceof double[]) {
                     target.setValue((double[]) v, unit);
-                } else {
+                } else if (v != target.getValue()) {    // Accept null value if the target value is already null.
                     throw new InvalidParameterValueException(Errors.format(
                             Errors.Keys.IllegalArgumentValue_2, name, v), name, v);
                 }

Modified: sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/parameter/UnmodifiableParameterValue.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/parameter/UnmodifiableParameterValue.java?rev=1724528&r1=1724527&r2=1724528&view=diff
==============================================================================
--- sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/parameter/UnmodifiableParameterValue.java [UTF-8] (original)
+++ sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/parameter/UnmodifiableParameterValue.java [UTF-8] Wed Jan 13 23:25:38 2016
@@ -17,6 +17,7 @@
 package org.apache.sis.parameter;
 
 import javax.measure.unit.Unit;
+import javax.xml.bind.annotation.XmlTransient;
 import org.opengis.parameter.ParameterValue;
 import org.apache.sis.internal.util.Cloner;
 import org.apache.sis.util.collection.WeakHashSet;
@@ -54,6 +55,7 @@ import org.apache.sis.util.resources.Err
  * @version 0.6
  * @module
  */
+@XmlTransient
 final class UnmodifiableParameterValue<T> extends DefaultParameterValue<T> {
     /**
      * For cross-version compatibility.
@@ -117,6 +119,7 @@ final class UnmodifiableParameterValue<T
      * Returns a modifiable copy of this parameter.
      */
     @Override
+    @SuppressWarnings("CloneDoesntCallSuperClone")
     public DefaultParameterValue<T> clone() {
         return new DefaultParameterValue<T>(this);
     }

Copied: sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/parameter/UnmodifiableParameterValueGroup.java (from r1724479, sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/parameter/UnmodifiableParameterValueGroup.java)
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/parameter/UnmodifiableParameterValueGroup.java?p2=sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/parameter/UnmodifiableParameterValueGroup.java&p1=sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/parameter/UnmodifiableParameterValueGroup.java&r1=1724479&r2=1724528&rev=1724528&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/parameter/UnmodifiableParameterValueGroup.java [UTF-8] (original)
+++ sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/parameter/UnmodifiableParameterValueGroup.java [UTF-8] Wed Jan 13 23:25:38 2016
@@ -34,7 +34,7 @@ import org.apache.sis.util.resources.Err
 import org.apache.sis.internal.util.UnmodifiableArrayList;
 
 // Branch-dependent imports
-import java.util.Objects;
+import org.apache.sis.internal.jdk7.Objects;
 
 
 /**
@@ -156,7 +156,7 @@ final class UnmodifiableParameterValueGr
     @Override
     public List<ParameterValueGroup> groups(final String name) throws ParameterNotFoundException {
         ArgumentChecks.ensureNonNull("name", name);
-        final List<ParameterValueGroup> groups = new ArrayList<>(4);
+        final List<ParameterValueGroup> groups = new ArrayList<ParameterValueGroup>(4);
         for (final GeneralParameterValue value : values) {
             if (value instanceof ParameterValueGroup) {
                 if (IdentifiedObjects.isHeuristicMatchForName(value.getDescriptor(), name)) {

Modified: sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/AbstractIdentifiedObject.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/AbstractIdentifiedObject.java?rev=1724528&r1=1724527&r2=1724528&view=diff
==============================================================================
--- sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/AbstractIdentifiedObject.java [UTF-8] (original)
+++ sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/AbstractIdentifiedObject.java [UTF-8] Wed Jan 13 23:25:38 2016
@@ -171,7 +171,7 @@ public class AbstractIdentifiedObject ex
      * The name for this object or code. Shall never be {@code null}.
      *
      * <p><b>Consider this field as final!</b>
-     * This field is modified only at unmarshalling time by {@link #addName(Identifier)}.</p>
+     * This field is modified only at unmarshalling time by {@link Names#add(Identifier)}.</p>
      *
      * @see #getName()
      * @see #getNames()
@@ -184,7 +184,7 @@ public class AbstractIdentifiedObject ex
      * we may get both on unmarshalling.
      *
      * <p><b>Consider this field as final!</b>
-     * This field is modified only at unmarshalling time by {@link #addName(Identifier)}.</p>
+     * This field is modified only at unmarshalling time by {@link Names#add(Identifier)}.</p>
      */
     private Collection<GenericName> alias;
 
@@ -644,6 +644,8 @@ public class AbstractIdentifiedObject ex
      *           <cite>When object name matter</cite> below.</td></tr>
      *   <tr><td>{@link ComparisonMode#APPROXIMATIVE APPROXIMATIVE}:</td>
      *       <td>Same as {@code IGNORE_METADATA}, with some tolerance threshold on numerical values.</td></tr>
+     *   <tr><td>{@link ComparisonMode#ALLOW_VARIANT ALLOW_VARIANT}:</td>
+     *       <td>Same as {@code APPROXIMATIVE}, but ignores coordinate system axes.</td></tr>
      *   <tr><td>{@link ComparisonMode#DEBUG DEBUG}:</td>
      *        <td>Special mode for figuring out why two objects expected to be equal are not.</td></tr>
      * </table>
@@ -718,6 +720,7 @@ public class AbstractIdentifiedObject ex
             }
             case IGNORE_METADATA:
             case APPROXIMATIVE:
+            case ALLOW_VARIANT:
             case DEBUG: {
                 return implementsSameInterface(object);
             }

Modified: sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/Builder.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/Builder.java?rev=1724528&r1=1724527&r2=1724528&view=diff
==============================================================================
--- sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/Builder.java [UTF-8] (original)
+++ sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/Builder.java [UTF-8] Wed Jan 13 23:25:38 2016
@@ -33,6 +33,8 @@ import org.opengis.referencing.Identifie
 import org.apache.sis.metadata.iso.ImmutableIdentifier;
 import org.apache.sis.internal.system.DefaultFactories;
 import org.apache.sis.internal.util.Citations;
+import org.apache.sis.internal.referencing.DeprecatedCode;
+import org.apache.sis.internal.referencing.DeprecatedName;
 import org.apache.sis.util.iso.Types;
 import org.apache.sis.util.Deprecable;
 import org.apache.sis.util.resources.Errors;



Mime
View raw message