sis-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From desruisse...@apache.org
Subject svn commit: r1740146 [6/7] - in /sis/branches/JDK7: ./ core/sis-feature/ core/sis-feature/src/main/java/org/apache/sis/feature/ core/sis-feature/src/main/java/org/apache/sis/internal/ core/sis-feature/src/main/java/org/apache/sis/internal/feature/ core...
Date Wed, 20 Apr 2016 13:49:35 GMT
Modified: sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/crs/DefaultProjectedCRSTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/crs/DefaultProjectedCRSTest.java?rev=1740146&r1=1740145&r2=1740146&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/crs/DefaultProjectedCRSTest.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/crs/DefaultProjectedCRSTest.java [UTF-8] Wed Apr 20 13:49:33 2016
@@ -29,6 +29,7 @@ import org.opengis.parameter.ParameterVa
 import org.apache.sis.metadata.iso.citation.Citations;
 import org.apache.sis.referencing.CommonCRS;
 import org.apache.sis.referencing.cs.HardCodedCS;
+import org.apache.sis.referencing.factory.InvalidGeodeticParameterException;
 import org.apache.sis.internal.referencing.GeodeticObjectBuilder;
 import org.apache.sis.internal.util.Constants;
 import org.apache.sis.internal.system.Loggers;
@@ -88,6 +89,25 @@ public final strictfp class DefaultProje
     private static final String XML_FILE = "ProjectedCRS.xml";
 
     /**
+     * Creates a projected CRS and verifies its parameters.
+     * Verifies also that the constructor does not accept invalid base CRS.
+     *
+     * @throws FactoryException if the CRS creation failed.
+     */
+    @Test
+    public void testConstructor() throws FactoryException {
+        final ProjectedCRS crs = create(HardCodedCRS.NTF);
+        verifyParameters(crs.getConversionFromBase().getParameterValues());
+        try {
+            create(HardCodedCRS.WGS84_3D);
+            fail("Should not accept a three-dimensional base geodetic CRS.");
+        } catch (InvalidGeodeticParameterException e) {
+            final String message = e.getMessage();
+            assertTrue(message, message.contains("Lambert Conic Conformal (1SP)"));
+        }
+    }
+
+    /**
      * Creates the "NTF (Paris) / Lambert zone II" CRS. The prime meridian is always in grades,
      * but the axes can be in degrees or in grades depending if the {@code baseCRS} argument is
      * {@link HardCodedCRS.NTF_NORMALIZED_AXES} or {@link HardCodedCRS.NTF} respectively.
@@ -109,11 +129,24 @@ public final strictfp class DefaultProje
     }
 
     /**
+     * Verifies the parameters of a {@code ProjectedCRS} created by the {@link #create(GeographicCRS)} method
+     * or something equivalent.
+     */
+    private static void verifyParameters(final ParameterValueGroup pg) {
+        assertEquals("Latitude of natural origin",    52,          pg.parameter("Latitude of natural origin")    .doubleValue(NonSI.GRADE), STRICT);
+        assertEquals("Longitude of natural origin",    0,          pg.parameter("Longitude of natural origin")   .doubleValue(NonSI.GRADE), STRICT);
+        assertEquals("Scale factor at natural origin", 0.99987742, pg.parameter("Scale factor at natural origin").doubleValue(),            STRICT);
+        assertEquals("False easting",             600000,          pg.parameter("False easting")                 .doubleValue(SI.METRE),    STRICT);
+        assertEquals("False northing",           2200000,          pg.parameter("False northing")                .doubleValue(SI.METRE),    STRICT);
+    }
+
+    /**
      * Tests WKT 1 formatting.
      *
      * @throws FactoryException if the CRS creation failed.
      */
     @Test
+    @DependsOnMethod("testConstructor")
     public void testWKT1() throws FactoryException {
         final ProjectedCRS crs = create(HardCodedCRS.NTF);
         assertWktEquals(Convention.WKT1,
@@ -447,16 +480,10 @@ public final strictfp class DefaultProje
         assertAxisDirectionsEqual("coordinateSystem", crs.getCoordinateSystem(), AxisDirection.EAST, AxisDirection.NORTH);
 
         final Projection conversion = crs.getConversionFromBase();
-        final ParameterValueGroup pg = conversion.getParameterValues();
         assertEpsgNameAndIdentifierEqual("Lambert zone II", 18082, conversion);
         assertEpsgNameAndIdentifierEqual("Lambert Conic Conformal (1SP)", 9801, conversion.getMethod());
-        assertEquals("Latitude of natural origin",    52,          pg.parameter("Latitude of natural origin")    .doubleValue(NonSI.GRADE), STRICT);
-        assertEquals("Longitude of natural origin",    0,          pg.parameter("Longitude of natural origin")   .doubleValue(NonSI.GRADE), STRICT);
-        assertEquals("Scale factor at natural origin", 0.99987742, pg.parameter("Scale factor at natural origin").doubleValue(),            STRICT);
-        assertEquals("False easting",             600000,          pg.parameter("False easting")                 .doubleValue(SI.METRE),    STRICT);
-        assertEquals("False northing",           2200000,          pg.parameter("False northing")                .doubleValue(SI.METRE),    STRICT);
-
         assertNotNull("conversion.mathTransform", conversion.getMathTransform());
+        verifyParameters(conversion.getParameterValues());
         /*
          * Test marshalling and compare with the original file. The comparison ignores the <gml:name> nodes because the
          * marshalled CRS contains many operation method and parameter aliases which were not in the original XML file.

Modified: sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/crs/HardCodedCRS.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/crs/HardCodedCRS.java?rev=1740146&r1=1740145&r2=1740146&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/crs/HardCodedCRS.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/crs/HardCodedCRS.java [UTF-8] Wed Apr 20 13:49:33 2016
@@ -36,7 +36,7 @@ import static org.apache.sis.referencing
  *
  * @author  Martin Desruisseaux (Geomatys)
  * @since   0.4
- * @version 0.5
+ * @version 0.7
  * @module
  */
 public final strictfp class HardCodedCRS {
@@ -109,6 +109,38 @@ public final strictfp class HardCodedCRS
             HardCodedDatum.NTF, HardCodedCS.GEODETIC_2D);
 
     /**
+     * A three-dimensional geographic coordinate reference system using the Tokyo datum.
+     * This CRS uses (<var>longitude</var>, <var>latitude</var>, <var>height</var>) ordinates
+     * with longitude values increasing towards the East, latitude values increasing towards
+     * the North and ellipsoidal eight increasing toward up.
+     * The angular units are decimal degrees and the linear units are metres.
+     *
+     * <p>This CRS is equivalent to {@code EPSG:4301} except for axis order and the addition
+     * of ellipsoidal height.</p>
+     *
+     * @since 0.7
+     */
+    public static final DefaultGeographicCRS TOKYO = new DefaultGeographicCRS(
+            Collections.singletonMap(DefaultGeographicCRS.NAME_KEY, "Tokyo"),
+            HardCodedDatum.TOKYO, HardCodedCS.GEODETIC_3D);
+
+    /**
+     * A two-dimensional geographic coordinate reference system using the JGD2000 datum.
+     * This CRS uses (<var>longitude</var>, <var>latitude</var>, <var>height</var>) ordinates
+     * with longitude values increasing towards the East, latitude values increasing towards
+     * the North and ellipsoidal eight increasing toward up.
+     * The angular units are decimal degrees and the linear units are metres.
+     *
+     * <p>This CRS is equivalent to {@code EPSG:4612} except for axis order and the addition
+     * of ellipsoidal height.</p>
+     *
+     * @since 0.7
+     */
+    public static final DefaultGeographicCRS JGD2000 = new DefaultGeographicCRS(
+            Collections.singletonMap(DefaultGeographicCRS.NAME_KEY, "JGD2000"),
+            HardCodedDatum.JGD2000, HardCodedCS.GEODETIC_3D);
+
+    /**
      * A two-dimensional geographic coordinate reference system using a spherical datum.
      * This CRS uses (<var>longitude</var>, <var>latitude</var>) ordinates with longitude values
      * increasing towards the East and latitude values increasing towards the North.
@@ -161,6 +193,18 @@ public final strictfp class HardCodedCRS
             getProperties(HardCodedCS.ELLIPSOIDAL_HEIGHT), HardCodedDatum.ELLIPSOID, HardCodedCS.ELLIPSOIDAL_HEIGHT);
 
     /**
+     * A vertical coordinate reference system using ellipsoidal datum.
+     * Ellipsoidal heights are measured along the normal to the ellipsoid used in the definition of horizontal datum.
+     *
+     * <p>This is not a valid vertical CRS according ISO 19111.
+     * This CRS is used by Apache SIS for internal calculation.</p>
+     *
+     * @since 0.7
+     */
+    public static final DefaultVerticalCRS ELLIPSOIDAL_HEIGHT_cm = new DefaultVerticalCRS(
+            getProperties(HardCodedCS.ELLIPSOIDAL_HEIGHT_cm), HardCodedDatum.ELLIPSOID, HardCodedCS.ELLIPSOIDAL_HEIGHT_cm);
+
+    /**
      * A vertical coordinate reference system using Mean Sea Level datum.
      */
     public static final DefaultVerticalCRS GRAVITY_RELATED_HEIGHT = new DefaultVerticalCRS(

Modified: sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/cs/HardCodedAxes.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/cs/HardCodedAxes.java?rev=1740146&r1=1740145&r2=1740146&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/cs/HardCodedAxes.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/cs/HardCodedAxes.java [UTF-8] Wed Apr 20 13:49:33 2016
@@ -114,6 +114,16 @@ public final strictfp class HardCodedAxe
             AxisDirection.UP, SI.METRE, Double.NEGATIVE_INFINITY, Double.POSITIVE_INFINITY, null);
 
     /**
+     * Axis for height values above the ellipsoid in a
+     * {@linkplain org.apache.sis.referencing.crs.DefaultGeographicCRS geographic CRS}.
+     * Increasing ordinates values go {@linkplain AxisDirection#UP up} and units are {@linkplain SI#CENTIMETRE centimetres}.
+     *
+     * @since 0.7
+     */
+    public static final DefaultCoordinateSystemAxis ELLIPSOIDAL_HEIGHT_cm = create(AxisNames.ELLIPSOIDAL_HEIGHT, "h",
+            AxisDirection.UP, SI.CENTIMETRE, Double.NEGATIVE_INFINITY, Double.POSITIVE_INFINITY, null);
+
+    /**
      * Axis for height values measured from gravity.
      * Increasing ordinates values go {@linkplain AxisDirection#UP up} and units are {@linkplain SI#METRE metres}.
      * The ISO 19111 name is <cite>"gravity-related height"</cite> and the abbreviation is upper case <cite>"H"</cite>.

Modified: sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/cs/HardCodedCS.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/cs/HardCodedCS.java?rev=1740146&r1=1740145&r2=1740146&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/cs/HardCodedCS.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/cs/HardCodedCS.java [UTF-8] Wed Apr 20 13:49:33 2016
@@ -211,16 +211,26 @@ public final strictfp class HardCodedCS
 
     /**
      * A one-dimensional vertical CS with
-     * <var>{@linkplain HardCodedAxes#ELLIPSOIDAL_HEIGHT
-     * ellipsoidal height}</var> axis in metres.
+     * <var>{@linkplain HardCodedAxes#ELLIPSOIDAL_HEIGHT ellipsoidal height}</var>
+     * axis in metres.
      */
     public static final DefaultVerticalCS ELLIPSOIDAL_HEIGHT = new DefaultVerticalCS(
             getProperties(HardCodedAxes.ELLIPSOIDAL_HEIGHT), HardCodedAxes.ELLIPSOIDAL_HEIGHT);
 
     /**
      * A one-dimensional vertical CS with
-     * <var>{@linkplain HardCodedAxes#GRAVITY_RELATED_HEIGHT
-     * gravity-related height}</var> axis in metres.
+     * <var>{@linkplain HardCodedAxes#ELLIPSOIDAL_HEIGHT ellipsoidal height}</var>
+     * axis in centimetres.
+     *
+     * @since 0.7
+     */
+    public static final DefaultVerticalCS ELLIPSOIDAL_HEIGHT_cm = new DefaultVerticalCS(
+            getProperties(HardCodedAxes.ELLIPSOIDAL_HEIGHT_cm), HardCodedAxes.ELLIPSOIDAL_HEIGHT_cm);
+
+    /**
+     * A one-dimensional vertical CS with
+     * <var>{@linkplain HardCodedAxes#GRAVITY_RELATED_HEIGHT gravity-related height}</var>
+     * axis in metres.
      */
     public static final DefaultVerticalCS GRAVITY_RELATED_HEIGHT = new DefaultVerticalCS(
             getProperties(HardCodedAxes.GRAVITY_RELATED_HEIGHT), HardCodedAxes.GRAVITY_RELATED_HEIGHT);

Modified: sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/factory/sql/EPSGDataFormatter.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/factory/sql/EPSGDataFormatter.java?rev=1740146&r1=1740145&r2=1740146&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/factory/sql/EPSGDataFormatter.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/factory/sql/EPSGDataFormatter.java [UTF-8] Wed Apr 20 13:49:33 2016
@@ -85,8 +85,9 @@ import java.nio.charset.StandardCharsets
  *           and add a {@code CONSTRAINT pk_change PRIMARY KEY (change_id)} line instead.</li>
  *       <li>In the statement creating the {@code epsg_datum} table,
  *           change the type of the {@code realization_epoch} column to {@code SMALLINT}.</li>
- *       <li>Change the type of {@code show_crs}, {@code show_operation} and all {@code deprecated} fields
- *           from {@code SMALLINT} to {@code BOOLEAN}.</li>
+ *       <li>Change the type of {@code ellipsoid_shape}, {@code reverse_op}, {@code param_sign_reversal}
+ *           {@code show_crs}, {@code show_operation} and all {@code deprecated} fields from {@code SMALLINT}
+ *           (or sometime {@code VARCHAR(3)}) to {@code BOOLEAN}.</li>
  *       <li>Change the type of every {@code table_name} columns from {@code VARCHAR(80)} to {@code epsg_table_name}.</li>
  *       <li>Change the type of {@code coord_ref_sys_kind} column from {@code VARCHAR(24)} to {@code epsg_crs_kind}.</li>
  *       <li>Change the type of {@code coord_sys_type} column from {@code VARCHAR(24)} to {@code epsg_cs_kind}.</li>
@@ -175,15 +176,16 @@ public final class EPSGDataFormatter ext
     private boolean insertDatum;
 
     /**
-     * Number of columns to change from type SMALLINT to type BOOLEAN.
-     * All those columns must be last.
+     * Index (in reversal order) of columns to change from type SMALLINT to type BOOLEAN.
+     * Index 0 is the last columns, index 1 is the column before the last, <i>etc</i>.
+     * We use the reverse order because most boolean columns in the EPSG dataset are last.
      */
-    private int numBooleanColumns;
+    private int[] booleanColumnIndices;
 
     /**
-     * The {@link #numBooleanColumns} value for each table.
+     * The {@link #booleanColumnIndices} value for each table.
      */
-    private final Map<String,Integer> numBooleanColumnsForTables;
+    private final Map<String,int[]> booleanColumnIndicesForTables;
 
     /**
      * Creates a new instance.
@@ -193,28 +195,29 @@ public final class EPSGDataFormatter ext
      */
     private EPSGDataFormatter(final Connection c) throws SQLException {
         super(c, Integer.MAX_VALUE);
-        numBooleanColumnsForTables = new HashMap<>();
-        numBooleanColumnsForTables.put("epsg_alias",                     0);
-        numBooleanColumnsForTables.put("epsg_area",                      1);
-        numBooleanColumnsForTables.put("epsg_change",                    0);
-        numBooleanColumnsForTables.put("epsg_coordinateaxis",            0);
-        numBooleanColumnsForTables.put("epsg_coordinateaxisname",        1);
-        numBooleanColumnsForTables.put("epsg_coordinatereferencesystem", 2);
-        numBooleanColumnsForTables.put("epsg_coordinatesystem",          1);
-        numBooleanColumnsForTables.put("epsg_coordoperation",            2);
-        numBooleanColumnsForTables.put("epsg_coordoperationmethod",      1);
-        numBooleanColumnsForTables.put("epsg_coordoperationparam",       1);
-        numBooleanColumnsForTables.put("epsg_coordoperationparamusage",  0);
-        numBooleanColumnsForTables.put("epsg_coordoperationparamvalue",  0);
-        numBooleanColumnsForTables.put("epsg_coordoperationpath",        0);
-        numBooleanColumnsForTables.put("epsg_datum",                     1);
-        numBooleanColumnsForTables.put("epsg_deprecation",               0);
-        numBooleanColumnsForTables.put("epsg_ellipsoid",                 1);
-        numBooleanColumnsForTables.put("epsg_namingsystem",              1);
-        numBooleanColumnsForTables.put("epsg_primemeridian",             1);
-        numBooleanColumnsForTables.put("epsg_supersession",              0);
-        numBooleanColumnsForTables.put("epsg_unitofmeasure",             1);
-        numBooleanColumnsForTables.put("epsg_versionhistory",            0);
+        final Map<String,int[]> m = new HashMap<>();
+        m.put("epsg_alias",                     new int[] {   });
+        m.put("epsg_area",                      new int[] {0  });
+        m.put("epsg_change",                    new int[] {   });
+        m.put("epsg_coordinateaxis",            new int[] {   });
+        m.put("epsg_coordinateaxisname",        new int[] {0  });
+        m.put("epsg_coordinatereferencesystem", new int[] {0,1});
+        m.put("epsg_coordinatesystem",          new int[] {0  });
+        m.put("epsg_coordoperation",            new int[] {0,1});
+        m.put("epsg_coordoperationmethod",      new int[] {0,8});
+        m.put("epsg_coordoperationparam",       new int[] {0  });
+        m.put("epsg_coordoperationparamusage",  new int[] {0  });
+        m.put("epsg_coordoperationparamvalue",  new int[] {   });
+        m.put("epsg_coordoperationpath",        new int[] {   });
+        m.put("epsg_datum",                     new int[] {0  });
+        m.put("epsg_deprecation",               new int[] {   });
+        m.put("epsg_ellipsoid",                 new int[] {0,6});
+        m.put("epsg_namingsystem",              new int[] {0  });
+        m.put("epsg_primemeridian",             new int[] {0  });
+        m.put("epsg_supersession",              new int[] {   });
+        m.put("epsg_unitofmeasure",             new int[] {0  });
+        m.put("epsg_versionhistory",            new int[] {   });
+        booleanColumnIndicesForTables = m;
     }
 
     /**
@@ -302,14 +305,17 @@ public final class EPSGDataFormatter ext
                 return 0;
             }
             /*
-             * Following statements do not make sense anymore on enumerated values:
+             * Following statements do not make sense anymore on enumerated or boolean values:
              *
              *    UPDATE epsg_coordinatereferencesystem SET coord_ref_sys_kind = replace(coord_ref_sys_kind, CHR(182), CHR(10));
              *    UPDATE epsg_coordinatesystem SET coord_sys_type = replace(coord_sys_type, CHR(182), CHR(10));
              *    UPDATE epsg_datum SET datum_type = replace(datum_type, CHR(182), CHR(10));
+             *    UPDATE epsg_coordoperationparamusage SET param_sign_reversal = replace(param_sign_reversal, CHR(182), CHR(10))
              */
             if (line.contains("replace")) {
-                if (line.contains("coord_ref_sys_kind") || line.contains("coord_sys_type") || line.contains("datum_type")) {
+                if (line.contains("param_sign_reversal") || line.contains("coord_ref_sys_kind")
+                        || line.contains("coord_sys_type") || line.contains("datum_type"))
+                {
                     return 0;
                 }
             }
@@ -337,7 +343,7 @@ public final class EPSGDataFormatter ext
                 throw new SQLException("This simple program wants VALUES on the same line than INSERT INTO.");
             }
             final String table = CharSequences.trimWhitespaces(line, INSERT_INTO.length(), valuesStart).toString();
-            numBooleanColumns = numBooleanColumnsForTables.get(table);
+            booleanColumnIndices = booleanColumnIndicesForTables.get(table);
             insertDatum = table.equals("epsg_datum");
             /*
              * We are beginning insertions in a new table.
@@ -383,20 +389,40 @@ public final class EPSGDataFormatter ext
      */
     private String replaceIntegerByBoolean(final String line) throws SQLException {
         final StringBuilder buffer = new StringBuilder(line);
-        int end = line.length();
-        for (int n = 0; n < numBooleanColumns; n++) {
-            end = line.lastIndexOf(',', end - 1);
-            final int p = CharSequences.skipLeadingWhitespaces(line, end+1, line.length());
-            final boolean value;
-            switch (line.charAt(p)) {
-                case '0': value = false; break;
-                case '1': value = true;  break;
-                default: throw new SQLException("Unexpected boolean value at position " + p + " in:\n" + line);
+        int end = CharSequences.skipTrailingWhitespaces(buffer, 0, buffer.length());
+        if (buffer.codePointBefore(end) == ')') end--;
+        for (int n=0, columnIndex=0; n < booleanColumnIndices.length; columnIndex++) {
+            int start = end;
+            for (int c; (c = buffer.codePointBefore(start)) != ',';) {
+                start -= Character.charCount(c);
+                if (c == '\'') {
+                    while (true) {
+                        c = buffer.codePointBefore(start);
+                        start -= Character.charCount(c);
+                        if (c == '\'') {
+                            if (buffer.codePointBefore(start) != '\'') {
+                                break;
+                            }
+                            start--;
+                        }
+                    }
+                }
             }
-            if (line.charAt(p+1) != (n == 0 ? ' ' : ',')) {
-                throw new SQLException("Unexpected character at position " + (p+1) + " in:\n" + line);
+            if (columnIndex == booleanColumnIndices[n]) {
+                String value = CharSequences.trimWhitespaces(buffer, start, end).toString();
+                if (value.equals("0") || value.equalsIgnoreCase("'No'")) {
+                    value = "false";
+                } else if (value.equals("1") || value.equalsIgnoreCase("'Yes'")) {
+                    value = "true";
+                } else if (value.equalsIgnoreCase("Null") || value.equals("''")) {
+                    value = "Null";
+                } else {
+                    throw new SQLException("Unexpected boolean value \"" + value + "\" at position " + start + " in:\n" + line);
+                }
+                buffer.replace(start, end, value);
+                n++;
             }
-            buffer.replace(p, p+1, String.valueOf(value));
+            end = CharSequences.skipTrailingWhitespaces(buffer, 0, start - 1);
         }
         return buffer.toString();
     }
@@ -410,6 +436,7 @@ public final class EPSGDataFormatter ext
     /**
      * Removes the useless "E0" exponents after floating point numbers.
      */
+    @SuppressWarnings("null")
     private static String removeUselessExponents(String line) {
         StringBuilder cleaned = null;
         final Matcher matcher = uselessExponentPattern.matcher(line);

Modified: sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/DefaultConcatenatedOperationTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/DefaultConcatenatedOperationTest.java?rev=1740146&r1=1740145&r2=1740146&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/DefaultConcatenatedOperationTest.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/DefaultConcatenatedOperationTest.java [UTF-8] Wed Apr 20 13:49:33 2016
@@ -16,16 +16,26 @@
  */
 package org.apache.sis.referencing.operation;
 
+import java.util.Collections;
 import javax.xml.bind.JAXBException;
+import org.opengis.util.FactoryException;
 import org.opengis.referencing.crs.GeodeticCRS;
 import org.opengis.referencing.crs.CoordinateReferenceSystem;
 import org.opengis.referencing.operation.CoordinateOperation;
+import org.opengis.referencing.operation.MathTransformFactory;
+import org.opengis.referencing.operation.NoninvertibleTransformException;
+import org.apache.sis.referencing.operation.transform.EllipsoidToCentricTransform;
+import org.apache.sis.referencing.datum.HardCodedDatum;
+import org.apache.sis.referencing.crs.HardCodedCRS;
+import org.apache.sis.internal.system.DefaultFactories;
+import org.apache.sis.io.wkt.Convention;
+
 import org.opengis.test.Validators;
 import org.apache.sis.test.DependsOn;
 import org.apache.sis.test.XMLTestCase;
 import org.junit.Test;
 
-import static org.opengis.test.Assert.*;
+import static org.apache.sis.test.MetadataAssert.*;
 import static org.apache.sis.test.TestUtilities.getSingleton;
 
 
@@ -48,9 +58,80 @@ public final strictfp class DefaultConca
     private static final String XML_FILE = "ConcatenatedOperation.xml";
 
     /**
+     * Creates a “Tokyo to JGD2000” transformation.
+     *
+     * @see DefaultTransformationTest#createGeocentricTranslation()
+     */
+    private static DefaultConcatenatedOperation createGeocentricTranslation() throws FactoryException, NoninvertibleTransformException {
+        final MathTransformFactory mtFactory = DefaultFactories.forBuildin(MathTransformFactory.class);
+        final DefaultTransformation op = DefaultTransformationTest.createGeocentricTranslation();
+
+        final DefaultConversion before = new DefaultConversion(
+                Collections.singletonMap(DefaultConversion.NAME_KEY, "Geographic to geocentric"),
+                HardCodedCRS.TOKYO,             // SourceCRS
+                op.getSourceCRS(),              // TargetCRS
+                null,                           // InterpolationCRS
+                DefaultOperationMethodTest.create("Geographic/geocentric conversions", "9602", "EPSG guidance note #7-2", 3),
+                EllipsoidToCentricTransform.createGeodeticConversion(mtFactory, HardCodedDatum.TOKYO.getEllipsoid(), true));
+
+        final DefaultConversion after = new DefaultConversion(
+                Collections.singletonMap(DefaultConversion.NAME_KEY, "Geocentric to geographic"),
+                op.getTargetCRS(),              // SourceCRS
+                HardCodedCRS.JGD2000,           // TargetCRS
+                null,                           // InterpolationCRS
+                DefaultOperationMethodTest.create("Geographic/geocentric conversions", "9602", "EPSG guidance note #7-2", 3),
+                EllipsoidToCentricTransform.createGeodeticConversion(mtFactory, HardCodedDatum.JGD2000.getEllipsoid(), true).inverse());
+
+        return new DefaultConcatenatedOperation(
+                Collections.singletonMap(DefaultConversion.NAME_KEY, "Tokyo to JGD2000"),
+                new AbstractSingleOperation[] {before, op, after}, mtFactory);
+    }
+
+    /**
+     * Tests WKT formatting. The WKT format used here is not defined in OGC/ISO standards;
+     * this is a SIS-specific extension.
+     *
+     * @throws FactoryException if an error occurred while creating the test operation.
+     * @throws NoninvertibleTransformException if an error occurred while creating the test operation.
+     */
+    @Test
+    public void testWKT() throws FactoryException, NoninvertibleTransformException {
+        final DefaultConcatenatedOperation op = createGeocentricTranslation();
+        assertWktEquals(Convention.WKT2_SIMPLIFIED,                             // Pseudo-WKT actually.
+                "ConcatenatedOperation[“Tokyo to JGD2000”,\n" +
+                "  SourceCRS[GeodeticCRS[“Tokyo”,\n" +
+                "    Datum[“Tokyo 1918”,\n" +
+                "      Ellipsoid[“Bessel 1841”, 6377397.155, 299.1528128]],\n" +
+                "    CS[ellipsoidal, 3],\n" +
+                "      Axis[“Longitude (L)”, east, Unit[“degree”, 0.017453292519943295]],\n" +
+                "      Axis[“Latitude (B)”, north, Unit[“degree”, 0.017453292519943295]],\n" +
+                "      Axis[“Ellipsoidal height (h)”, up, Unit[“metre”, 1]]]],\n" +
+                "  TargetCRS[GeodeticCRS[“JGD2000”,\n" +
+                "    Datum[“Japanese Geodetic Datum 2000”,\n" +
+                "      Ellipsoid[“GRS 1980”, 6378137.0, 298.257222101]],\n" +
+                "    CS[ellipsoidal, 3],\n" +
+                "      Axis[“Longitude (L)”, east, Unit[“degree”, 0.017453292519943295]],\n" +
+                "      Axis[“Latitude (B)”, north, Unit[“degree”, 0.017453292519943295]],\n" +
+                "      Axis[“Ellipsoidal height (h)”, up, Unit[“metre”, 1]]]],\n" +
+                "  CoordinateOperationStep[“Geographic to geocentric”,\n" +
+                "    Method[“Geographic/geocentric conversions”],\n" +
+                "      Parameter[“semi_major”, 6377397.155, Unit[“metre”, 1]],\n" +
+                "      Parameter[“semi_minor”, 6356078.962818189, Unit[“metre”, 1]]],\n" +
+                "  CoordinateOperationStep[“Tokyo to JGD2000 (GSI)”,\n" +
+                "    Method[“Geocentric translations”],\n" +
+                "      Parameter[“X-axis translation”, -146.414],\n" +
+                "      Parameter[“Y-axis translation”, 507.337],\n" +
+                "      Parameter[“Z-axis translation”, 680.507]],\n" +
+                "  CoordinateOperationStep[“Geocentric to geographic”,\n" +
+                "    Method[“Geographic/geocentric conversions”],\n" +
+                "      Parameter[“semi_major”, 6378137.0, Unit[“metre”, 1]],\n" +
+                "      Parameter[“semi_minor”, 6356752.314140356, Unit[“metre”, 1]]]]", op);
+    }
+
+    /**
      * Tests (un)marshalling of a concatenated operation.
      *
-     * @throws JAXBException If an error occurred during (un)marshalling.
+     * @throws JAXBException if an error occurred during (un)marshalling.
      */
     @Test
     public void testXML() throws JAXBException {

Modified: sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/DefaultConversionTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/DefaultConversionTest.java?rev=1740146&r1=1740145&r2=1740146&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/DefaultConversionTest.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/DefaultConversionTest.java [UTF-8] Wed Apr 20 13:49:33 2016
@@ -23,6 +23,7 @@ import org.opengis.util.FactoryException
 import org.opengis.parameter.ParameterValue;
 import org.opengis.parameter.ParameterValueGroup;
 import org.opengis.referencing.crs.CoordinateReferenceSystem;
+import org.opengis.referencing.crs.GeodeticCRS;
 import org.opengis.referencing.crs.GeographicCRS;
 import org.opengis.referencing.crs.TemporalCRS;
 import org.opengis.referencing.cs.EllipsoidalCS;
@@ -96,7 +97,7 @@ public final strictfp class DefaultConve
      */
     private static GeographicCRS changeCS(final CoordinateReferenceSystem crs, final EllipsoidalCS cs) {
         return new DefaultGeographicCRS(Collections.singletonMap(DefaultGeographicCRS.NAME_KEY,
-                crs.getName()), ((GeographicCRS) crs).getDatum(), cs);
+                crs.getName()), ((GeodeticCRS) crs).getDatum(), cs);
     }
 
     /**
@@ -167,6 +168,7 @@ public final strictfp class DefaultConve
      * Asserts that at least some of the properties of the given {@code op} instance have the expected values
      * for an instance created by {@link #createLongitudeRotation(GeographicCRS, GeographicCRS)}.
      */
+    @SuppressWarnings("SuspiciousToArrayCall")
     private static void verifyProperties(final DefaultConversion op, final boolean swapSourceAxes) {
         assertEquals("name",       "Paris to Greenwich", op.getName().getCode());
         assertEquals("sourceCRS",  "NTF (Paris)",        op.getSourceCRS().getName().getCode());

Modified: sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/DefaultTransformationTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/DefaultTransformationTest.java?rev=1740146&r1=1740145&r2=1740146&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/DefaultTransformationTest.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/DefaultTransformationTest.java [UTF-8] Wed Apr 20 13:49:33 2016
@@ -69,7 +69,7 @@ public final strictfp class DefaultTrans
     /**
      * Creates a “Tokyo to JGD2000 (GSI)” transformation.
      */
-    private static DefaultTransformation createGeocentricTranslation() {
+    static DefaultTransformation createGeocentricTranslation() {
         /*
          * The following code fills the parameter values AND creates itself the MathTransform instance
          * (indirectly, through the matrix). The later step is normally not our business, since we are
@@ -108,6 +108,7 @@ public final strictfp class DefaultTrans
      * Asserts that at least some of the properties of the given {@code op} instance have the expected values
      * for an instance created by {@link #createGeocentricTranslation()}.
      */
+    @SuppressWarnings("SuspiciousToArrayCall")
     private static void verifyProperties(final DefaultTransformation op) {
         assertEquals("name",       "Tokyo to JGD2000 (GSI)",  op.getName().getCode());
         assertEquals("sourceCRS",  "Tokyo 1918",              op.getSourceCRS().getName().getCode());
@@ -177,9 +178,9 @@ public final strictfp class DefaultTrans
                 "      AXIS[“(Z)”, geocentricZ, ORDER[3]],\n" +
                 "      LENGTHUNIT[“metre”, 1]]],\n" +
                 "  METHOD[“Geocentric translations”, ID[“EPSG”, 1031]],\n" +
-                "  PARAMETER[“X-axis translation”, -146.414, ID[“EPSG”, 8605]],\n" +
-                "  PARAMETER[“Y-axis translation”, 507.337, ID[“EPSG”, 8606]],\n" +
-                "  PARAMETER[“Z-axis translation”, 680.507, ID[“EPSG”, 8607]]]", op);
+                "    PARAMETER[“X-axis translation”, -146.414, ID[“EPSG”, 8605]],\n" +
+                "    PARAMETER[“Y-axis translation”, 507.337, ID[“EPSG”, 8606]],\n" +
+                "    PARAMETER[“Z-axis translation”, 680.507, ID[“EPSG”, 8607]]]", op);
 
         assertWktEquals(Convention.WKT2_SIMPLIFIED,
                 "CoordinateOperation[“Tokyo to JGD2000 (GSI)”,\n" +
@@ -200,9 +201,9 @@ public final strictfp class DefaultTrans
                 "      Axis[“(Z)”, geocentricZ],\n" +
                 "      Unit[“metre”, 1]]],\n" +
                 "  Method[“Geocentric translations”],\n" +
-                "  Parameter[“X-axis translation”, -146.414],\n" +
-                "  Parameter[“Y-axis translation”, 507.337],\n" +
-                "  Parameter[“Z-axis translation”, 680.507]]", op);
+                "    Parameter[“X-axis translation”, -146.414],\n" +
+                "    Parameter[“Y-axis translation”, 507.337],\n" +
+                "    Parameter[“Z-axis translation”, 680.507]]", op);
     }
 
     /**

Modified: sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/matrix/MatricesTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/matrix/MatricesTest.java?rev=1740146&r1=1740145&r2=1740146&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/matrix/MatricesTest.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/matrix/MatricesTest.java [UTF-8] Wed Apr 20 13:49:33 2016
@@ -39,7 +39,7 @@ import static org.opengis.referencing.cs
  *
  * @author  Martin Desruisseaux (Geomatys)
  * @since   0.4
- * @version 0.4
+ * @version 0.7
  * @module
  */
 @DependsOn({
@@ -354,16 +354,49 @@ public final strictfp class MatricesTest
         });
         matrix = Matrices.createPassThrough(2, matrix, 1);
         assertEquals(Matrices.create(6, 7, new double[] {
-            1, 0, 0, 0, 0, 0, 0,  // Dimension added
-            0, 1, 0, 0, 0, 0, 0,  // Dimension added
-            0, 0, 2, 0, 3, 0, 8,  // Sub-matrix, row 0
-            0, 0, 0, 4, 7, 0, 5,  // Sub-matrix, row 1
-            0, 0, 0, 0, 0, 1, 0,  // Dimension added
-            0, 0, 0, 0, 0, 0, 1   // Last sub-matrix row
+            1, 0, 0, 0, 0, 0, 0,        // Dimension added
+            0, 1, 0, 0, 0, 0, 0,        // Dimension added
+            0, 0, 2, 0, 3, 0, 8,        // Sub-matrix, row 0
+            0, 0, 0, 4, 7, 0, 5,        // Sub-matrix, row 1
+            0, 0, 0, 0, 0, 1, 0,        // Dimension added
+            0, 0, 0, 0, 0, 0, 1         // Last sub-matrix row
         }), matrix);
     }
 
     /**
+     * Tests {@link Matrices#resizeAffine(Matrix, int, int)}.
+     */
+    @Test
+    public void testResizeAffine() {
+        // Add dimensions
+        MatrixSIS matrix = Matrices.create(3, 4, new double[] {
+            2, 0, 3, 8,
+            0, 4, 7, 5,
+            0, 0, 0, 1
+        });
+        assertEquals(Matrices.create(5, 6, new double[] {
+            2, 0, 3, 0, 0, 8,
+            0, 4, 7, 0, 0, 5,
+            0, 0, 1, 0, 0, 0,
+            0, 0, 0, 1, 0, 0,
+            0, 0, 0, 0, 0, 1
+        }), Matrices.resizeAffine(matrix, 5, 6));
+
+        // Remove dimensions
+        matrix = Matrices.create(4, 5, new double[] {
+            1, 2, 7, 8, 9,
+            3, 4, 6, 7, 8,
+            9, 8, 7, 6, 5,
+            4, 3, 2, 1, -1
+        });
+        assertEquals(Matrices.create(3, 3, new double[] {
+            1, 2, 9,
+            3, 4, 8,
+            4, 3, -1
+        }), Matrices.resizeAffine(matrix, 3, 3));
+    }
+
+    /**
      * Tests {@link MatrixSIS#removeRows(int, int)}
      */
     @Test

Modified: sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/matrix/NonSquareMatrixTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/matrix/NonSquareMatrixTest.java?rev=1740146&r1=1740145&r2=1740146&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/matrix/NonSquareMatrixTest.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/matrix/NonSquareMatrixTest.java [UTF-8] Wed Apr 20 13:49:33 2016
@@ -17,14 +17,13 @@
 package org.apache.sis.referencing.operation.matrix;
 
 import java.util.Random;
-import org.opengis.test.Assert;
 import org.apache.sis.test.DependsOn;
 import org.apache.sis.test.TestUtilities;
 import org.junit.AfterClass;
 import org.junit.Test;
 
 import static java.lang.Double.NaN;
-import static org.junit.Assert.*;
+import static org.opengis.test.Assert.*;
 
 
 /**
@@ -103,12 +102,12 @@ public final strictfp class NonSquareMat
             0, 0, 1
         });
         MatrixSIS inverse = m.inverse();
-        Assert.assertMatrixEquals("Inverse of non-square matrix.", new NonSquareMatrix(3, 5, new double[] {
+        assertMatrixEquals("Inverse of non-square matrix.", new NonSquareMatrix(3, 5, new double[] {
             0.5, 0,   0,    0,   0,
             0,   0,   0.25, 0,   0,
             0,   0,   0,    0,   1}), inverse, STRICT);
 
-        Assert.assertMatrixEquals("Back to original.", new NonSquareMatrix(5, 3, new double[] {
+        assertMatrixEquals("Back to original.", new NonSquareMatrix(5, 3, new double[] {
             2, 0, 0,
             0, 0, NaN,
             0, 4, 0,

Modified: sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/transform/CoordinateSystemTransformTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/transform/CoordinateSystemTransformTest.java?rev=1740146&r1=1740145&r2=1740146&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/transform/CoordinateSystemTransformTest.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/transform/CoordinateSystemTransformTest.java [UTF-8] Wed Apr 20 13:49:33 2016
@@ -17,19 +17,15 @@
 package org.apache.sis.referencing.operation.transform;
 
 import javax.measure.unit.SI;
-import javax.measure.unit.Unit;
 import org.opengis.util.FactoryException;
 import org.opengis.referencing.cs.CoordinateSystem;
-import org.opengis.referencing.cs.CoordinateSystemAxis;
 import org.opengis.referencing.cs.SphericalCS;
 import org.opengis.referencing.operation.MathTransformFactory;
 import org.opengis.referencing.operation.TransformException;
 import org.apache.sis.referencing.crs.DefaultGeocentricCRS;
 import org.apache.sis.referencing.cs.CoordinateSystems;
 import org.apache.sis.referencing.cs.AxesConvention;
-import org.apache.sis.referencing.cs.AxisFilter;
 import org.apache.sis.referencing.CommonCRS;
-import org.apache.sis.measure.Units;
 
 // Test dependencies
 import org.opengis.test.referencing.TransformTestCase;
@@ -40,10 +36,6 @@ import org.junit.BeforeClass;
 import org.junit.AfterClass;
 import org.junit.Test;
 
-// Branch-dependent imports
-import org.opengis.referencing.cs.AxisDirection;
-
-
 
 /**
  * Tests the {@link CoordinateSystemTransform} static factory method.
@@ -92,29 +84,7 @@ public final strictfp class CoordinateSy
      * Returns the given coordinate system but with linear axes in centimetres instead of metres.
      */
     private static CoordinateSystem toCentimetres(final CoordinateSystem cs) {
-        return CoordinateSystems.replaceAxes(cs, new AxisFilter() {
-            @Override public Unit<?> getUnitReplacement(CoordinateSystemAxis axis, Unit<?> unit) {
-                return Units.isLinear(unit) ? SI.CENTIMETRE : unit;
-            }
-            @Override public Unit<?> getUnitReplacement(Unit<?> unit) {
-                return Units.isLinear(unit) ? SI.CENTIMETRE : unit;
-            }
-
-            @Override
-            public boolean accept(CoordinateSystemAxis axis) {
-                return true;
-            }
-
-            @Override
-            public AxisDirection getDirectionReplacement(CoordinateSystemAxis axis, AxisDirection direction) {
-                return direction;
-            }
-
-            @Override
-            public AxisDirection getDirectionReplacement(AxisDirection direction) {
-                return direction;
-            }
-        });
+        return CoordinateSystems.replaceLinearUnit(cs, SI.CENTIMETRE);
     }
 
     /**

Modified: sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/transform/DefaultMathTransformFactoryTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/transform/DefaultMathTransformFactoryTest.java?rev=1740146&r1=1740145&r2=1740146&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/transform/DefaultMathTransformFactoryTest.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/transform/DefaultMathTransformFactoryTest.java [UTF-8] Wed Apr 20 13:49:33 2016
@@ -62,7 +62,7 @@ import static org.opengis.test.Assert.*;
  * @module
  */
 @DependsOn({
-    org.apache.sis.internal.referencing.provider.AllProvidersTest.class,
+    org.apache.sis.internal.referencing.provider.ProvidersTest.class,
     OperationMethodSetTest.class
 })
 public final strictfp class DefaultMathTransformFactoryTest extends TestCase {

Modified: sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/test/ReferencingAssert.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/test/ReferencingAssert.java?rev=1740146&r1=1740145&r2=1740146&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/test/ReferencingAssert.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/test/ReferencingAssert.java [UTF-8] Wed Apr 20 13:49:33 2016
@@ -35,6 +35,7 @@ import org.opengis.referencing.cs.Coordi
 import org.opengis.referencing.cs.RangeMeaning;
 import org.opengis.util.GenericName;
 import org.apache.sis.geometry.AbstractEnvelope;
+import org.apache.sis.geometry.Envelopes;
 import org.apache.sis.geometry.GeneralDirectPosition;
 import org.apache.sis.metadata.iso.citation.Citations;
 import org.apache.sis.referencing.IdentifiedObjects;
@@ -54,7 +55,7 @@ import org.apache.sis.internal.jdk8.JDK8
  *
  * @author  Martin Desruisseaux (Geomatys)
  * @since   0.3
- * @version 0.6
+ * @version 0.7
  * @module
  */
 public strictfp class ReferencingAssert extends MetadataAssert {
@@ -69,8 +70,8 @@ public strictfp class ReferencingAssert
      * The authority is expected to be {@link Citations#OGC}. We expect the exact same authority
      * instance because identifiers in OGC namespace are often hard-coded in SIS.
      *
-     * @param expected The expected identifier code.
-     * @param actual   The identifier to verify.
+     * @param expected  the expected identifier code.
+     * @param actual    the identifier to verify.
      *
      * @since 0.6
      */
@@ -87,8 +88,8 @@ public strictfp class ReferencingAssert
      * Asserts that the given identifier has the expected code and the {@code "EPSG"} code space.
      * The authority is expected to have the {@code "EPSG"} title, alternate title or identifier.
      *
-     * @param expected The expected identifier code.
-     * @param actual   The identifier to verify.
+     * @param expected  the expected identifier code.
+     * @param actual    the identifier to verify.
      *
      * @since 0.5
      */
@@ -106,14 +107,14 @@ public strictfp class ReferencingAssert
      * No other identifier than the given one is expected. The authority is expected to have the {@code "EPSG"} title,
      * alternate title or identifier.
      *
-     * @param name       The expected EPSG name.
-     * @param identifier The expected EPSG identifier.
-     * @param object     The object to verify.
+     * @param name        the expected EPSG name.
+     * @param identifier  the expected EPSG identifier.
+     * @param object      the object to verify.
      *
      * @since 0.6
      */
     public static void assertEpsgNameAndIdentifierEqual(final String name, final int identifier, final IdentifiedObject object) {
-        assertNotNull(object);
+        assertNotNull(name, object);
         assertEpsgIdentifierEquals(name, object.getName());
         assertEpsgIdentifierEquals(String.valueOf(identifier), TestUtilities.getSingleton(object.getIdentifiers()));
     }
@@ -122,8 +123,8 @@ public strictfp class ReferencingAssert
      * Asserts that the tip of the unique alias of the given object is equals to the expected value.
      * As a special case if the expected value is null, then this method verifies that the given object has no alias.
      *
-     * @param expected The expected alias, or {@code null} if we expect no alias.
-     * @param object   The object for which to test the alias.
+     * @param expected  the expected alias, or {@code null} if we expect no alias.
+     * @param object    the object for which to test the alias.
      */
     public static void assertAliasTipEquals(final String expected, final IdentifiedObject object) {
         final Collection<GenericName> aliases = object.getAlias();
@@ -137,14 +138,14 @@ public strictfp class ReferencingAssert
     /**
      * Compares the given coordinate system axis against the expected values.
      *
-     * @param name          The expected axis name code.
-     * @param abbreviation  The expected axis abbreviation.
-     * @param direction     The expected axis direction.
-     * @param minimumValue  The expected axis minimal value.
-     * @param maximumValue  The expected axis maximal value.
-     * @param unit          The expected axis unit of measurement.
-     * @param rangeMeaning  The expected axis range meaning.
-     * @param axis          The axis to verify.
+     * @param name           the expected axis name code.
+     * @param abbreviation   the expected axis abbreviation.
+     * @param direction      the expected axis direction.
+     * @param minimumValue   the expected axis minimal value.
+     * @param maximumValue   the expected axis maximal value.
+     * @param unit           the expected axis unit of measurement.
+     * @param rangeMeaning   the expected axis range meaning.
+     * @param axis           the axis to verify.
      */
     public static void assertAxisEquals(final String name, final String abbreviation, final AxisDirection direction,
             final double minimumValue, final double maximumValue, final Unit<?> unit, final RangeMeaning rangeMeaning,
@@ -164,9 +165,9 @@ public strictfp class ReferencingAssert
      * a positive delta. Only the elements in the given descriptor are compared, and
      * the comparisons are done in the units declared in the descriptor.
      *
-     * @param expected  The expected parameter values.
-     * @param actual    The actual parameter values.
-     * @param tolerance The tolerance threshold for comparison of numerical values.
+     * @param expected   the expected parameter values.
+     * @param actual     the actual parameter values.
+     * @param tolerance  the tolerance threshold for comparison of numerical values.
      */
     public static void assertParameterEquals(final ParameterValueGroup expected,
             final ParameterValueGroup actual, final double tolerance)
@@ -199,13 +200,13 @@ public strictfp class ReferencingAssert
      * to the given values. The matrix doesn't need to be square. The last row is handled especially
      * if the {@code affine} argument is {@code true}.
      *
-     * @param expected  The values which are expected on the diagonal. If the length of this array
-     *                  is less than the matrix size, then the last element in the array is repeated
-     *                  for all remaining diagonal elements.
-     * @param affine    If {@code true}, then the last row is expected to contains the value 1
-     *                  in the last column, and all other columns set to 0.
-     * @param matrix    The matrix to test.
-     * @param tolerance The tolerance threshold while comparing floating point values.
+     * @param expected   the values which are expected on the diagonal. If the length of this array
+     *                   is less than the matrix size, then the last element in the array is repeated
+     *                   for all remaining diagonal elements.
+     * @param affine     if {@code true}, then the last row is expected to contains the value 1
+     *                   in the last column, and all other columns set to 0.
+     * @param matrix     the matrix to test.
+     * @param tolerance  the tolerance threshold while comparing floating point values.
      */
     public static void assertDiagonalEquals(final double[] expected, final boolean affine,
             final Matrix matrix, final double tolerance)
@@ -234,9 +235,9 @@ public strictfp class ReferencingAssert
     /**
      * Compares two affine transforms for equality.
      *
-     * @param expected  The expected affine transform.
-     * @param actual    The actual affine transform.
-     * @param tolerance The tolerance threshold.
+     * @param expected   the expected affine transform.
+     * @param actual     the actual affine transform.
+     * @param tolerance  the tolerance threshold.
      */
     public static void assertTransformEquals(final AffineTransform expected, final AffineTransform actual, final double tolerance) {
         assertEquals("scaleX",     expected.getScaleX(),     actual.getScaleX(),     tolerance);
@@ -250,10 +251,10 @@ public strictfp class ReferencingAssert
     /**
      * Asserts that two rectangles have the same location and the same size.
      *
-     * @param expected The expected rectangle.
-     * @param actual   The rectangle to compare with the expected one.
-     * @param tolx     The tolerance threshold on location along the <var>x</var> axis.
-     * @param toly     The tolerance threshold on location along the <var>y</var> axis.
+     * @param expected  the expected rectangle.
+     * @param actual    the rectangle to compare with the expected one.
+     * @param tolx      the tolerance threshold on location along the <var>x</var> axis.
+     * @param toly      the tolerance threshold on location along the <var>y</var> axis.
      */
     public static void assertRectangleEquals(final RectangularShape expected,
             final RectangularShape actual, final double tolx, final double toly)
@@ -269,6 +270,36 @@ public strictfp class ReferencingAssert
     }
 
     /**
+     * Asserts that two envelopes have the same minimum and maximum ordinates.
+     * This method ignores the envelope type (i.e. the implementation class) and the CRS.
+     *
+     * @param expected    the expected envelope.
+     * @param actual      the envelope to compare with the expected one.
+     * @param tolerances  the tolerance threshold on location along each axis. If this array length is shorter
+     *                    than the number of dimensions, then the last tolerance is reused for all remaining axes.
+     *                    If this array is empty, then the tolerance threshold is zero.
+     *
+     * @since 0.7
+     */
+    public static void assertEnvelopeEquals(final Envelope expected, final Envelope actual, final double... tolerances) {
+        final int dimension = expected.getDimension();
+        assertEquals("dimension", dimension, actual.getDimension());
+        double tolerance = 0;
+        for (int i=0; i<dimension; i++) {
+            if (i < tolerances.length) {
+                tolerance = tolerances[i];
+            }
+            if (abs(expected.getMinimum(i) - actual.getMinimum(i)) > tolerance ||
+                abs(expected.getMaximum(i) - actual.getMaximum(i)) > tolerance)
+            {
+                fail("Envelopes are not equal:\n"
+                        + "expected " + Envelopes.toString(expected) + "\n"
+                        + " but got " + Envelopes.toString(actual));
+            }
+        }
+    }
+
+    /**
      * Tests if the given {@code outer} shape contains the given {@code inner} rectangle.
      * This method will also verify class consistency by invoking the {@code intersects}
      * method, and by interchanging the arguments.
@@ -276,8 +307,8 @@ public strictfp class ReferencingAssert
      * <p>This method can be used for testing the {@code outer} implementation -
      * it should not be needed for standard JDK implementations.</p>
      *
-     * @param outer The shape which is expected to contains the given rectangle.
-     * @param inner The rectangle which should be contained by the shape.
+     * @param outer  the shape which is expected to contains the given rectangle.
+     * @param inner  the rectangle which should be contained by the shape.
      */
     public static void assertContains(final RectangularShape outer, final Rectangle2D inner) {
         assertTrue("outer.contains(inner)",   outer.contains  (inner));
@@ -295,8 +326,8 @@ public strictfp class ReferencingAssert
      * This method will also verify class consistency by invoking the {@code intersects}
      * method, and by interchanging the arguments.
      *
-     * @param outer The envelope which is expected to contains the given inner envelope.
-     * @param inner The envelope which should be contained by the outer envelope.
+     * @param outer  the envelope which is expected to contains the given inner envelope.
+     * @param inner  the envelope which should be contained by the outer envelope.
      */
     public static void assertContains(final AbstractEnvelope outer, final Envelope inner) {
         assertTrue("outer.contains(inner)",   outer.contains  (inner, true));
@@ -325,8 +356,8 @@ public strictfp class ReferencingAssert
      * <p>This method can be used for testing the {@code r1} implementation - it should not
      * be needed for standard implementations.</p>
      *
-     * @param r1 The first shape to test.
-     * @param r2 The second rectangle to test.
+     * @param r1  the first shape to test.
+     * @param r2  the second rectangle to test.
      */
     public static void assertDisjoint(final RectangularShape r1, final Rectangle2D r2) {
         assertFalse("r1.intersects(r2)", r1.intersects(r2));
@@ -358,8 +389,8 @@ public strictfp class ReferencingAssert
      * This method will also verify class consistency by invoking the {@code contains} method,
      * and by interchanging the arguments.
      *
-     * @param e1 The first envelope to test.
-     * @param e2 The second envelope to test.
+     * @param e1  the first envelope to test.
+     * @param e2  the second envelope to test.
      */
     public static void assertDisjoint(final AbstractEnvelope e1, final Envelope e2) {
         assertFalse("e1.intersects(e2)", e1.intersects(e2, false));
@@ -398,7 +429,7 @@ public strictfp class ReferencingAssert
      * Tests if the given transform is the identity transform.
      * If the current transform is linear, then this method will also verifies {@link Matrix#isIdentity()}.
      *
-     * @param transform The transform to test.
+     * @param transform  the transform to test.
      *
      * @since 0.6
      */
@@ -413,7 +444,7 @@ public strictfp class ReferencingAssert
      * Tests if the given transform is <strong>not</strong> the identity transform.
      * If the current transform is linear, then this method will also verifies {@link Matrix#isIdentity()}.
      *
-     * @param transform The transform to test.
+     * @param transform  the transform to test.
      *
      * @since 0.6
      */

Modified: sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/test/suite/ReferencingTestSuite.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/test/suite/ReferencingTestSuite.java?rev=1740146&r1=1740145&r2=1740146&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/test/suite/ReferencingTestSuite.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/test/suite/ReferencingTestSuite.java [UTF-8] Wed Apr 20 13:49:33 2016
@@ -112,6 +112,7 @@ import org.junit.BeforeClass;
     org.apache.sis.referencing.operation.transform.ScaleTransformTest.class,
     org.apache.sis.referencing.operation.transform.ProjectiveTransformTest.class,
     org.apache.sis.referencing.operation.transform.LinearTransformTest.class,
+    org.apache.sis.referencing.operation.transform.LinearInterpolator1DTest.class,
     org.apache.sis.referencing.operation.transform.ExponentialTransform1DTest.class,
     org.apache.sis.referencing.operation.transform.LogarithmicTransform1DTest.class,
     org.apache.sis.referencing.operation.transform.CopyTransformTest.class,
@@ -147,7 +148,7 @@ import org.junit.BeforeClass;
     org.apache.sis.internal.referencing.provider.NADCONTest.class,
     org.apache.sis.internal.referencing.provider.MapProjectionTest.class,
     org.apache.sis.internal.referencing.provider.TransverseMercatorTest.class,
-    org.apache.sis.internal.referencing.provider.AllProvidersTest.class,
+    org.apache.sis.internal.referencing.provider.ProvidersTest.class,
     org.apache.sis.referencing.operation.transform.InterpolatedTransformTest.class,
     org.apache.sis.referencing.operation.transform.InterpolatedGeocentricTransformTest.class,
     org.apache.sis.referencing.operation.transform.InterpolatedMolodenskyTransformTest.class,
@@ -170,7 +171,6 @@ import org.junit.BeforeClass;
     org.apache.sis.referencing.operation.SingleOperationMarshallingTest.class,
     org.apache.sis.referencing.operation.DefaultPassThroughOperationTest.class,
     org.apache.sis.referencing.operation.DefaultConcatenatedOperationTest.class,
-    org.apache.sis.referencing.operation.CoordinateOperationInferenceTest.class,
     org.apache.sis.referencing.crs.DefaultProjectedCRSTest.class,
     org.apache.sis.referencing.crs.DefaultDerivedCRSTest.class,
     org.apache.sis.referencing.crs.SubTypesTest.class,
@@ -216,6 +216,13 @@ import org.junit.BeforeClass;
     org.apache.sis.referencing.AuthorityFactoriesTest.class,
     org.apache.sis.referencing.CRSTest.class,
 
+    // Coordinate operation finders are last, since they need everything else.
+    org.apache.sis.referencing.operation.CoordinateOperationRegistryTest.class,
+    org.apache.sis.referencing.operation.CoordinateOperationFinderTest.class,
+    org.apache.sis.referencing.operation.DefaultCoordinateOperationFactoryTest.class,
+    org.apache.sis.referencing.operation.builder.LinearTransformBuilderTest.class,
+
+    // Geometry
     org.apache.sis.geometry.AbstractDirectPositionTest.class,
     org.apache.sis.geometry.GeneralDirectPositionTest.class,
     org.apache.sis.geometry.DirectPosition1DTest.class,
@@ -227,11 +234,10 @@ import org.junit.BeforeClass;
     org.apache.sis.geometry.Envelope2DTest.class,
     org.apache.sis.geometry.CurveExtremumTest.class,
     org.apache.sis.geometry.EnvelopesTest.class,
+    org.apache.sis.internal.referencing.ServicesForMetadataTest.class,
 
     org.apache.sis.distance.LatLonPointRadiusTest.class,        // Pending refactoring in a geometry package.
 
-    org.apache.sis.referencing.operation.builder.LinearTransformBuilderTest.class,
-    org.apache.sis.internal.referencing.ServicesForMetadataTest.class,
     org.apache.sis.test.integration.DatumShiftTest.class,
     org.apache.sis.test.integration.MetadataTest.class,
     org.apache.sis.test.integration.ConsistencyTest.class

Modified: sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/internal/converter/StringConverter.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/internal/converter/StringConverter.java?rev=1740146&r1=1740145&r2=1740146&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/internal/converter/StringConverter.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/internal/converter/StringConverter.java [UTF-8] Wed Apr 20 13:49:33 2016
@@ -155,7 +155,7 @@ abstract class StringConverter<T> extend
      */
     public static final class Number extends StringConverter<java.lang.Number> {
         private static final long serialVersionUID = 8356246549731207392L;
-        public Number() {super(java.lang.Number.class);} // Instantiated by ServiceLoader.
+        public Number() {super(java.lang.Number.class);}                            // Instantiated by ServiceLoader.
 
         @Override java.lang.Number doConvert(String source) throws NumberFormatException {
             return Numbers.narrowestNumber(source);
@@ -164,7 +164,7 @@ abstract class StringConverter<T> extend
 
     public static final class Double extends StringConverter<java.lang.Double> {
         private static final long serialVersionUID = -8576620873911755486L;
-        public Double() {super(java.lang.Double.class);} // Instantiated by ServiceLoader.
+        public Double() {super(java.lang.Double.class);}                            // Instantiated by ServiceLoader.
 
         @Override java.lang.Double doConvert(String source) throws NumberFormatException {
             return java.lang.Double.parseDouble(source);
@@ -173,7 +173,7 @@ abstract class StringConverter<T> extend
 
     public static final class Float extends StringConverter<java.lang.Float> {
         private static final long serialVersionUID = 2301101264860653956L;
-        public Float() {super(java.lang.Float.class);} // Instantiated by ServiceLoader.
+        public Float() {super(java.lang.Float.class);}                              // Instantiated by ServiceLoader.
 
         @Override java.lang.Float doConvert(String source) throws NumberFormatException {
             return java.lang.Float.parseFloat(source);
@@ -182,7 +182,7 @@ abstract class StringConverter<T> extend
 
     public static final class Long extends StringConverter<java.lang.Long> {
         private static final long serialVersionUID = 4711495660311641145L;
-        public Long() {super(java.lang.Long.class);} // Instantiated by ServiceLoader.
+        public Long() {super(java.lang.Long.class);}                                // Instantiated by ServiceLoader.
 
         @Override java.lang.Long doConvert(String source) throws NumberFormatException {
             return java.lang.Long.parseLong(source);
@@ -191,7 +191,7 @@ abstract class StringConverter<T> extend
 
     public static final class Integer extends StringConverter<java.lang.Integer> {
         private static final long serialVersionUID = -5024227987148221073L;
-        public Integer() {super(java.lang.Integer.class);} // Instantiated by ServiceLoader.
+        public Integer() {super(java.lang.Integer.class);}                          // Instantiated by ServiceLoader.
 
         @Override java.lang.Integer doConvert(String source) throws NumberFormatException {
             return java.lang.Integer.parseInt(source);
@@ -200,7 +200,7 @@ abstract class StringConverter<T> extend
 
     public static final class Short extends StringConverter<java.lang.Short> {
         private static final long serialVersionUID = 4067703596268901375L;
-        public Short() {super(java.lang.Short.class);} // Instantiated by ServiceLoader.
+        public Short() {super(java.lang.Short.class);}                              // Instantiated by ServiceLoader.
 
         @Override java.lang.Short doConvert(String source) throws NumberFormatException {
             return java.lang.Short.parseShort(source);
@@ -209,7 +209,7 @@ abstract class StringConverter<T> extend
 
     public static final class Byte extends StringConverter<java.lang.Byte> {
         private static final long serialVersionUID = 6934470534898203474L;
-        public Byte() {super(java.lang.Byte.class);} // Instantiated by ServiceLoader.
+        public Byte() {super(java.lang.Byte.class);}                                // Instantiated by ServiceLoader.
 
         @Override java.lang.Byte doConvert(String source) throws NumberFormatException {
             return java.lang.Byte.parseByte(source);
@@ -218,7 +218,7 @@ abstract class StringConverter<T> extend
 
     public static final class BigDecimal extends StringConverter<java.math.BigDecimal> {
         private static final long serialVersionUID = -5949128086478498785L;
-        public BigDecimal() {super(java.math.BigDecimal.class);} // Instantiated by ServiceLoader.
+        public BigDecimal() {super(java.math.BigDecimal.class);}                    // Instantiated by ServiceLoader.
 
         @Override java.math.BigDecimal doConvert(String source) throws NumberFormatException {
             return new java.math.BigDecimal(source);
@@ -227,7 +227,7 @@ abstract class StringConverter<T> extend
 
     public static final class BigInteger extends StringConverter<java.math.BigInteger> {
         private static final long serialVersionUID = 6387019773702794255L;
-        public BigInteger() {super(java.math.BigInteger.class);} // Instantiated by ServiceLoader.
+        public BigInteger() {super(java.math.BigInteger.class);}                    // Instantiated by ServiceLoader.
 
         @Override java.math.BigInteger doConvert(String source) throws NumberFormatException {
             return new java.math.BigInteger(source);
@@ -236,7 +236,7 @@ abstract class StringConverter<T> extend
 
     public static final class Boolean extends StringConverter<java.lang.Boolean> {
         private static final long serialVersionUID = 4689076223535035309L;
-        public Boolean() {super(java.lang.Boolean.class);} // Instantiated by ServiceLoader.
+        public Boolean() {super(java.lang.Boolean.class);}                          // Instantiated by ServiceLoader.
 
         /** See {@link StringConverter} for the conversion table. */
         @Override java.lang.Boolean doConvert(final String source) throws UnconvertibleObjectException {
@@ -250,7 +250,7 @@ abstract class StringConverter<T> extend
 
     public static final class Locale extends StringConverter<java.util.Locale> {
         private static final long serialVersionUID = -794933131690043494L;
-        public Locale() {super(java.util.Locale.class);} // Instantiated by ServiceLoader.
+        public Locale() {super(java.util.Locale.class);}                            // Instantiated by ServiceLoader.
 
         @Override java.util.Locale doConvert(String source) throws IllformedLocaleException {
             return Locales.parse(source);
@@ -259,7 +259,7 @@ abstract class StringConverter<T> extend
 
     public static final class Charset extends StringConverter<java.nio.charset.Charset> {
         private static final long serialVersionUID = 4375157214436581095L;
-        public Charset() {super(java.nio.charset.Charset.class);} // Instantiated by ServiceLoader.
+        public Charset() {super(java.nio.charset.Charset.class);}                   // Instantiated by ServiceLoader.
 
         @Override java.nio.charset.Charset doConvert(String source) throws UnsupportedCharsetException {
             return java.nio.charset.Charset.forName(source);
@@ -268,7 +268,7 @@ abstract class StringConverter<T> extend
 
     public static final class File extends StringConverter<java.io.File> {
         private static final long serialVersionUID = -2157537605361631529L;
-        public File() {super(java.io.File.class);} // Instantiated by ServiceLoader.
+        public File() {super(java.io.File.class);}                                  // Instantiated by ServiceLoader.
 
         @Override java.io.File doConvert(String source) {
             return new java.io.File(source);
@@ -277,7 +277,7 @@ abstract class StringConverter<T> extend
 
     public static final class Path extends StringConverter<java.nio.file.Path> {
         private static final long serialVersionUID = -1737315635965906042L;
-        public Path() {super(java.nio.file.Path.class);} // Instantiated by ServiceLoader.
+        public Path() {super(java.nio.file.Path.class);}                            // Instantiated by ServiceLoader.
 
         @Override java.nio.file.Path doConvert(String source) throws InvalidPathException {
             return java.nio.file.Paths.get(source);
@@ -286,7 +286,7 @@ abstract class StringConverter<T> extend
 
     public static final class URI extends StringConverter<java.net.URI> {
         private static final long serialVersionUID = 7266486748714603336L;
-        public URI() {super(java.net.URI.class);} // Instantiated by ServiceLoader.
+        public URI() {super(java.net.URI.class);}                                   // Instantiated by ServiceLoader.
 
         @Override java.net.URI doConvert(String source) throws URISyntaxException {
             return new java.net.URI(source);
@@ -295,7 +295,7 @@ abstract class StringConverter<T> extend
 
     public static final class URL extends StringConverter<java.net.URL> {
         private static final long serialVersionUID = -6518011235037500143L;
-        public URL() {super(java.net.URL.class);} // Instantiated by ServiceLoader.
+        public URL() {super(java.net.URL.class);}                                   // Instantiated by ServiceLoader.
 
         @Override java.net.URL doConvert(String source) throws MalformedURLException {
             return new java.net.URL(source);
@@ -305,7 +305,7 @@ abstract class StringConverter<T> extend
     public static final class Unit extends StringConverter<javax.measure.unit.Unit<?>> {
         private static final long serialVersionUID = -1809497218136016210L;
         @SuppressWarnings("unchecked")
-        public Unit() {super((Class) javax.measure.unit.Unit.class);} // Instantiated by ServiceLoader.
+        public Unit() {super((Class) javax.measure.unit.Unit.class);}               // Instantiated by ServiceLoader.
 
         @Override javax.measure.unit.Unit<?> doConvert(String source) throws IllegalArgumentException {
             return Units.valueOf(source);
@@ -314,7 +314,7 @@ abstract class StringConverter<T> extend
 
     public static final class Angle extends StringConverter<org.apache.sis.measure.Angle> {
         private static final long serialVersionUID = -6937967772504961327L;
-        public Angle() {super(org.apache.sis.measure.Angle.class);} // Instantiated by ServiceLoader.
+        public Angle() {super(org.apache.sis.measure.Angle.class);}                 // Instantiated by ServiceLoader.
 
         @Override org.apache.sis.measure.Angle doConvert(String source) throws NumberFormatException {
             return new org.apache.sis.measure.Angle(source);

Modified: sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/internal/util/CollectionsExt.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/internal/util/CollectionsExt.java?rev=1740146&r1=1740145&r2=1740146&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/internal/util/CollectionsExt.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/internal/util/CollectionsExt.java [UTF-8] Wed Apr 20 13:49:33 2016
@@ -246,7 +246,7 @@ public final class CollectionsExt extend
                 return array;
             }
         }
-        throw new IllegalArgumentException(Errors.format(Errors.Keys.IllegalPropertyClass_2, name, valueType));
+        throw new IllegalArgumentException(Errors.format(Errors.Keys.IllegalPropertyValueClass_2, name, valueType));
     }
 
     /**

Modified: sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/internal/util/LazySet.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/internal/util/LazySet.java?rev=1740146&r1=1740145&r2=1740146&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/internal/util/LazySet.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/internal/util/LazySet.java [UTF-8] Wed Apr 20 13:49:33 2016
@@ -16,8 +16,10 @@
  */
 package org.apache.sis.internal.util;
 
+import java.util.List;
 import java.util.Arrays;
 import java.util.Iterator;
+import java.util.ServiceLoader;
 import java.util.NoSuchElementException;
 import org.apache.sis.util.Workaround;
 
@@ -35,7 +37,8 @@ import java.util.Objects;
  * a new iteration. See
  * {@link org.apache.sis.referencing.operation.transform.DefaultMathTransformFactory#DefaultMathTransformFactory()}.</p>
  *
- * <p>Another usage for this class is to prepend some values before the elements given by the source {@code Iterable}.</p>
+ * <p>Some usages for this class are to prepend some values before the elements given by the source {@code Iterable},
+ * or to replace some values when they are loaded.</p>
  *
  * <p>This class is not thread-safe. Synchronization, if desired, shall be done by the caller.</p>
  *
@@ -49,9 +52,9 @@ import java.util.Objects;
 @Workaround(library="JDK", version="1.8.0_31-b13")
 public class LazySet<E> extends SetOfUnknownSize<E> {
     /**
-     * The original source of elements, or {@code null} if unknown.
+     * The type of service to request with {@link ServiceLoader}, or {@code null} if unknown.
      */
-    private final Iterable<? extends E> source;
+    private final Class<E> service;
 
     /**
      * The iterator to use for filling this set, or {@code null} if the iteration did not started yet
@@ -82,11 +85,11 @@ public class LazySet<E> extends SetOfUnk
      * only when first needed, and at most one iteration will be performed (unless {@link #reload()}
      * is invoked).
      *
-     * @param source The source of elements to use for filling this set.
+     * @param service  the type of service to request with {@link ServiceLoader}, or {@code null} if unknown.
      */
-    public LazySet(final Iterable<? extends E> source) {
-        Objects.requireNonNull(source);
-        this.source = source;
+    public LazySet(final Class<E> service) {
+        Objects.requireNonNull(service);
+        this.service = service;
     }
 
     /**
@@ -98,23 +101,19 @@ public class LazySet<E> extends SetOfUnk
     public LazySet(final Iterator<? extends E> iterator) {
         Objects.requireNonNull(iterator);
         sourceIterator = iterator;
-        source = null;
+        service = null;
         createCache();
     }
 
     /**
      * Notifies this {@code LazySet} that it should re-fetch the elements from the source given at construction time.
-     * This method does not verify if the source needs also to be reloaded; it is up to the caller to verify.
-     *
-     * @return The original source of elements, or {@code null} if unknown.
      */
-    public Iterable<? extends E> reload() {
-        if (source != null) {
+    public void reload() {
+        if (service != null) {
             sourceIterator = null;
             cachedElements = null;
             numCached = 0;
         }
-        return source;
     }
 
     /**
@@ -156,7 +155,7 @@ public class LazySet<E> extends SetOfUnk
      */
     private boolean canPullMore() {
         if (sourceIterator == null && cachedElements == null) {
-            sourceIterator = source.iterator();
+            sourceIterator = ServiceLoader.load(service).iterator();
             if (createCache()) {
                 return true;
             }
@@ -198,11 +197,12 @@ public class LazySet<E> extends SetOfUnk
     }
 
     /**
-     * Adds the given element to the {@link #cachedElements} array.
+     * Caches a new element. Subclasses can override this method is they want to substitute the given value
+     * by another value.
      *
      * @param element The element to add to the cache.
      */
-    private void cache(final E element) {
+    protected void cache(final E element) {
         if (numCached >= cachedElements.length) {
             cachedElements = Arrays.copyOf(cachedElements, numCached << 1);
         }
@@ -210,6 +210,16 @@ public class LazySet<E> extends SetOfUnk
     }
 
     /**
+     * Returns an unmodifiable view over the elements cached so far.
+     * The returned list does not contain any elements that were not yet fetched from the source.
+     *
+     * @return  the elements cached so far.
+     */
+    protected final List<E> cached() {
+        return UnmodifiableArrayList.wrap(cachedElements, 0, numCached);
+    }
+
+    /**
      * Returns {@code true} if an element exists at the given index.
      * The element is not loaded immediately.
      *

Modified: sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/internal/util/LocalizedException.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/internal/util/LocalizedException.java?rev=1740146&r1=1740145&r2=1740146&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/internal/util/LocalizedException.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/internal/util/LocalizedException.java [UTF-8] Wed Apr 20 13:49:33 2016
@@ -22,13 +22,13 @@ import org.apache.sis.util.Localized;
 
 /**
  * An exception which can produce an error message in the given locale.
- * Exceptions implementing this interface uses the following policy:
+ * Exceptions implementing this interface use the following policy:
  *
  * <ul>
  *   <li>{@link Throwable#getMessage()} returns the message in the {@linkplain Locale#getDefault() default locale}.
  *       In a client-server architecture, this is often the locale on the server side.</li>
- *   <li>{@link Throwable#getLocalizedMessage()} returns the message in the locale returned by the
- *       {@link #getLocale()} method. This is often the locale used by a {@link java.text.Format}
+ *   <li>{@link Throwable#getLocalizedMessage()} returns the message in a locale that depends on the context
+ *       in which the exception has been thrown. This is often the locale used by a {@link java.text.Format}
  *       object for example, and can be presumed to be the locale on the client side.</li>
  *   <li>{@link #getLocalizedMessage(Locale)} returns the message in the given locale.
  *       This method is specific to Apache SIS however.</li>
@@ -36,29 +36,26 @@ import org.apache.sis.util.Localized;
  *
  * @author  Martin Desruisseaux (Geomatys)
  * @since   0.3
- * @version 0.3
+ * @version 0.7
  * @module
  *
  * @see org.apache.sis.util.Exceptions#getLocalizedMessage(Throwable, Locale)
  */
-public interface LocalizedException extends Localized {
+public interface LocalizedException {
     /**
-     * The locale of the string returned by {@link #getLocalizedMessage()}.
-     *
-     * @return The locale of the localized exception message.
-     */
-    @Override
-    Locale getLocale();
-
-    /**
-     * Returns the message in the default locale.
+     * Returns the message in the {@linkplain Locale#getDefault() default locale}.
      *
      * @return The exception message in the default locale.
      */
     String getMessage();
 
     /**
-     * Returns the message in the locale specified by {@link #getLocale()}.
+     * Returns the message in the locale that depends on the context in which this exception has been thrown.
+     * For example it may be the local of a client application connected to a distant server.
+     *
+     * <p>If the context locale is known, then this {@code LocalizedException} instance will also implement
+     * the {@link Localized} interface and the context locale can be obtained by a call to
+     * {@link Localized#getLocale()}.</p>
      *
      * @return The localized exception message.
      */

Modified: sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/internal/util/LocalizedParseException.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/internal/util/LocalizedParseException.java?rev=1740146&r1=1740145&r2=1740146&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/internal/util/LocalizedParseException.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/internal/util/LocalizedParseException.java [UTF-8] Wed Apr 20 13:49:33 2016
@@ -20,6 +20,7 @@ import java.util.Locale;
 import java.text.ParsePosition;
 import java.text.ParseException;
 import org.apache.sis.util.Workaround;
+import org.apache.sis.util.Localized;
 import org.apache.sis.util.CharSequences;
 import org.apache.sis.util.resources.Errors;
 
@@ -39,10 +40,10 @@ import org.apache.sis.util.resources.Err
  *
  * @author  Martin Desruisseaux (Geomatys)
  * @since   0.3
- * @version 0.3
+ * @version 0.7
  * @module
  */
-public final class LocalizedParseException extends ParseException implements LocalizedException {
+public final class LocalizedParseException extends ParseException implements LocalizedException, Localized {
     /**
      * For cross-version compatibility.
      */



Mime
View raw message