sis-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From desruisse...@apache.org
Subject svn commit: r1714052 [2/2] - in /sis/branches/JDK7: ./ core/sis-metadata/src/main/java/org/apache/sis/io/wkt/ core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/ core/sis-referencing/src/main/java/org/apache/sis/referencing...
Date Thu, 12 Nov 2015 14:24:25 GMT
Modified: sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/internal/referencing/provider/CoordinateOperationMethodsHTML.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/internal/referencing/provider/CoordinateOperationMethodsHTML.java?rev=1714052&r1=1714051&r2=1714052&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/internal/referencing/provider/CoordinateOperationMethodsHTML.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/internal/referencing/provider/CoordinateOperationMethodsHTML.java [UTF-8] Thu Nov 12 14:24:24 2015
@@ -68,7 +68,7 @@ import org.apache.sis.internal.jdk8.JDK8
  * @version 0.6
  * @module
  */
-public final class CoordinateOperationMethodsHTML extends HTMLGenerator {
+public final strictfp class CoordinateOperationMethodsHTML extends HTMLGenerator {
     /**
      * Generates the HTML report.
      *

Modified: sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/internal/referencing/provider/GeocentricTranslationTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/internal/referencing/provider/GeocentricTranslationTest.java?rev=1714052&r1=1714051&r2=1714052&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/internal/referencing/provider/GeocentricTranslationTest.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/internal/referencing/provider/GeocentricTranslationTest.java [UTF-8] Thu Nov 12 14:24:24 2015
@@ -19,11 +19,13 @@ package org.apache.sis.internal.referenc
 import org.opengis.util.FactoryException;
 import org.opengis.parameter.ParameterValueGroup;
 import org.opengis.referencing.datum.Ellipsoid;
+import org.opengis.referencing.operation.MathTransform;
 import org.opengis.referencing.operation.MathTransformFactory;
 import org.opengis.referencing.operation.TransformException;
 import org.opengis.test.ToleranceModifier;
 import org.apache.sis.internal.system.DefaultFactories;
 import org.apache.sis.internal.referencing.Formulas;
+import org.apache.sis.parameter.Parameters;
 import org.apache.sis.referencing.CommonCRS;
 import org.apache.sis.referencing.operation.transform.CoordinateDomain;
 import org.apache.sis.referencing.operation.transform.LinearTransform;
@@ -48,7 +50,7 @@ import static org.junit.Assert.*;
     AffineTest.class,
     org.apache.sis.referencing.operation.transform.ProjectiveTransformTest.class,
     org.apache.sis.referencing.operation.transform.ConcatenatedTransformTest.class,
-    org.apache.sis.referencing.operation.transform.EllipsoidalToCartesianTransformTest.class,
+    org.apache.sis.referencing.operation.transform.EllipsoidToCentricTransformTest.class,
     org.apache.sis.referencing.datum.BursaWolfParametersTest.class
 })
 public final strictfp class GeocentricTranslationTest extends MathTransformTestCase {
@@ -122,25 +124,42 @@ public final strictfp class GeocentricTr
     }
 
     /**
-     * Tests transformation of the sample point from WGS84 to ED50.
+     * Creates a transformation for the given method.
      *
-     * @param method     The method to test.
-     * @param sourceStep The {@link #samplePoint(int)} to use as the source coordinate.
-     * @param targetStep The {@link #samplePoint(int)} expected as a result of the transformation.
+     * @param method The method to test.
      */
-    private void datumShift(final GeocentricAffine method, final int sourceStep, final int targetStep)
-            throws FactoryException, TransformException
-    {
+    private void create(final GeocentricAffine method) throws FactoryException {
         final ParameterValueGroup values = method.getParameters().createValue();
-        values.parameter("X-axis translation").setValue( 84.87);
-        values.parameter("Y-axis translation").setValue( 96.49);
-        values.parameter("Z-axis translation").setValue(116.95);
+        setTranslation(values);
         if (method instanceof GeocentricAffineBetweenGeographic) {
             setEllipsoids(values, CommonCRS.WGS84.ellipsoid(), CommonCRS.ED50.ellipsoid());
         }
-        tolerance = precision(targetStep);
         transform = method.createMathTransform(DefaultFactories.forBuildin(MathTransformFactory.class), values);
-        verifyTransform(samplePoint(sourceStep), samplePoint(targetStep));
+    }
+
+    /**
+     * Creates a "Geographic 2D to 3D → Geocentric → Affine → Geographic → Geographic 3D to 2D" chain
+     * using EPSG or OGC standard operation methods and parameters. This is used for integration tests.
+     *
+     * @param  factory The math transform factory to use for creating and concatenating the transform.
+     * @return The chain of transforms.
+     * @throws FactoryException if an error occurred while creating a transform.
+     */
+    public static MathTransform createDatumShiftForGeographic2D(final MathTransformFactory factory) throws FactoryException {
+        final Parameters values = Parameters.castOrWrap(factory.getDefaultParameters("Geocentric translations (geog2D domain)"));
+        setTranslation(values);
+        setEllipsoids(values, CommonCRS.WGS84.ellipsoid(), CommonCRS.ED50.ellipsoid());
+        return Geographic3Dto2DTest.createDatumShiftForGeographic2D(factory,
+                new GeocentricTranslation().createMathTransform(factory, values), values);
+    }
+
+    /**
+     * Sets the translation parameters in the given parameter value group.
+     */
+    private static void setTranslation(final ParameterValueGroup values) {
+        values.parameter("X-axis translation").setValue( 84.87);
+        values.parameter("Y-axis translation").setValue( 96.49);
+        values.parameter("Z-axis translation").setValue(116.95);
     }
 
     /**
@@ -154,6 +173,18 @@ public final strictfp class GeocentricTr
     }
 
     /**
+     * Tests transformation of the sample point from WGS84 to ED50.
+     *
+     * @param sourceStep The {@link #samplePoint(int)} to use as the source coordinate.
+     * @param targetStep The {@link #samplePoint(int)} expected as a result of the transformation.
+     */
+    private void datumShift(final int sourceStep, final int targetStep) throws TransformException {
+        tolerance = precision(targetStep);
+        verifyTransform(samplePoint(sourceStep), samplePoint(targetStep));
+        validate();
+    }
+
+    /**
      * Tests <cite>"Geocentric translations (geocentric domain)"</cite> (EPSG:1031).
      *
      * @throws FactoryException if an error occurred while creating the transform.
@@ -161,10 +192,10 @@ public final strictfp class GeocentricTr
      */
     @Test
     public void testGeocentricDomain() throws FactoryException, TransformException {
-        derivativeDeltas = new double[] {100, 100, 100};    // In metres
-        datumShift(new GeocentricTranslation(), 2, 3);
+        create(new GeocentricTranslation());
         assertTrue(transform instanceof LinearTransform);
-        validate();
+        derivativeDeltas = new double[] {100, 100, 100};    // In metres
+        datumShift(2, 3);
     }
 
     /**
@@ -176,13 +207,13 @@ public final strictfp class GeocentricTr
     @Test
     @DependsOnMethod("testGeocentricDomain")
     public void testGeographicDomain() throws FactoryException, TransformException {
+        create(new GeocentricTranslation3D());
+        assertFalse(transform instanceof LinearTransform);
         final double delta = toRadians(100.0 / 60) / 1852;      // Approximatively 100 metres
         derivativeDeltas = new double[] {delta, delta, 100};    // (Δλ, Δφ, Δh)
         zTolerance = Formulas.LINEAR_TOLERANCE / 2;             // Half the precision of h value given by EPSG
         zDimension = new int[] {2};                             // Dimension of h where to apply zTolerance
-        datumShift(new GeocentricTranslation3D(), 1, 4);
-        assertFalse(transform instanceof LinearTransform);
-        validate();
+        datumShift(1, 4);
     }
 
     /**
@@ -201,19 +232,53 @@ public final strictfp class GeocentricTr
     }
 
     /**
+     * Tests Well Known Text formatting of a two-dimensional transform.
+     * The main point of this test is to verify that Geographic 2D/3D conversions have been
+     * inserted before and after the transform, and that Geographic/Geocentric conversions
+     * have been replaced by Bursa-Wolf parameters for formatting purpose.
+     *
+     * @throws FactoryException if an error occurred while creating the transform.
+     */
+    @Test
+    @DependsOnMethod("testWKT3D")
+    public void testWKT2D() throws FactoryException {
+        create(new GeocentricTranslation2D());
+        verifyWKT2D();
+    }
+
+    /**
+     * Verifies the WKT formatting of current transform.
+     */
+    private void verifyWKT2D() {
+        assertWktEquals("CONCAT_MT[\n" +
+                        "  INVERSE_MT[PARAM_MT[“Geographic3D to 2D conversion”]],\n" +
+                        "  PARAM_MT[“Ellipsoid_To_Geocentric”,\n" +
+                        "    PARAMETER[“semi_major”, 6378137.0],\n" +
+                        "    PARAMETER[“semi_minor”, 6356752.314245179]],\n" +
+                        "  PARAM_MT[“Geocentric translations (geocentric domain)”,\n" +
+                        "    PARAMETER[“dx”, 84.87],\n" +
+                        "    PARAMETER[“dy”, 96.49],\n" +
+                        "    PARAMETER[“dz”, 116.95]],\n" +
+                        "  PARAM_MT[“Geocentric_To_Ellipsoid”,\n" +
+                        "    PARAMETER[“semi_major”, 6378388.0],\n" +
+                        "    PARAMETER[“semi_minor”, 6356911.9461279465]],\n" +
+                        "  PARAM_MT[“Geographic3D to 2D conversion”]]");
+    }
+
+    /**
      * Tests Well Known Text formatting.
      * The main point of this test is to verify that the affine transform between the two
      * Geographic/Geocentric conversions have been replaced by Bursa-Wolf parameters for
      * formatting purpose.
      *
      * @throws FactoryException if an error occurred while creating the transform.
-     * @throws TransformException if transformation of a sample point failed.
      */
     @Test
     @DependsOnMethod("testGeographicDomain")
-    public void testWKT() throws FactoryException, TransformException {
-        testGeographicDomain();     // For creating the transform.
-        assertWktEquals("CONCAT_MT[PARAM_MT[“Ellipsoid_To_Geocentric”,\n" +
+    public void testWKT3D() throws FactoryException {
+        create(new GeocentricTranslation3D());
+        assertWktEquals("CONCAT_MT[\n" +
+                        "  PARAM_MT[“Ellipsoid_To_Geocentric”,\n" +
                         "    PARAMETER[“semi_major”, 6378137.0],\n" +
                         "    PARAMETER[“semi_minor”, 6356752.314245179]],\n" +
                         "  PARAM_MT[“Geocentric translations (geocentric domain)”,\n" +
@@ -228,14 +293,16 @@ public final strictfp class GeocentricTr
          * affines before, after and between the two Geographic/Geocentric conversions.
          */
         assertInternalWktEquals(
-                "Concat_MT[Param_MT[“Affine”,\n" +
+                "Concat_MT[\n" +
+                "  Param_MT[“Affine”,\n" +
                 "    Parameter[“num_row”, 4],\n" +
                 "    Parameter[“num_col”, 4],\n" +
                 "    Parameter[“elt_0_0”, 0.017453292519943295],\n" +
                 "    Parameter[“elt_1_1”, 0.017453292519943295],\n" +
                 "    Parameter[“elt_2_2”, 1.567855942887398E-7]],\n" +
-                "  Param_MT[“Ellipsoidal to Cartesian”,\n" +
+                "  Param_MT[“Ellipsoid to centric”,\n" +
                 "    Parameter[“eccentricity”, 0.08181919084262157],\n" +
+                "    Parameter[“target”, “CARTESIAN”],\n" +
                 "    Parameter[“dim”, 3]],\n" +
                 "  Param_MT[“Affine”,\n" +
                 "    Parameter[“num_row”, 4],\n" +
@@ -246,8 +313,9 @@ public final strictfp class GeocentricTr
                 "    Parameter[“elt_1_3”, 1.512764667185502E-5],\n" +
                 "    Parameter[“elt_2_2”, 0.9999606483644456],\n" +
                 "    Parameter[“elt_2_3”, 1.8335353697517302E-5]],\n" +
-                "  Param_MT[“Cartesian to ellipsoidal”,\n" +
+                "  Param_MT[“Centric to ellipsoid”,\n" +
                 "    Parameter[“eccentricity”, 0.08199188997902956],\n" +
+                "    Parameter[“target”, “CARTESIAN”],\n" +
                 "    Parameter[“dim”, 3]],\n" +
                 "  Param_MT[“Affine”,\n" +
                 "    Parameter[“num_row”, 4],\n" +
@@ -256,4 +324,18 @@ public final strictfp class GeocentricTr
                 "    Parameter[“elt_1_1”, 57.29577951308232],\n" +
                 "    Parameter[“elt_2_2”, 6378388.0]]]");
     }
+
+    /**
+     * Tests "Geographic 2D to 3D → Geocentric → Affine → Geographic → Geographic 3D to 2D" chain
+     * created from a {@link MathTransformFactory}. Because this test involves a lot of steps,
+     * this is more an integration test than a unit test: a failure here may not be easy to debug.
+     *
+     * @throws FactoryException if an error occurred while creating the transform.
+     */
+    @Test
+    @DependsOnMethod("testWKT2D")
+    public void testIntegration() throws FactoryException {
+        transform = createDatumShiftForGeographic2D(DefaultFactories.forBuildin(MathTransformFactory.class));
+        verifyWKT2D();
+    }
 }

Modified: sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/parameter/ParameterValueGroupWrapper.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/parameter/ParameterValueGroupWrapper.java?rev=1714052&r1=1714051&r2=1714052&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/parameter/ParameterValueGroupWrapper.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/parameter/ParameterValueGroupWrapper.java [UTF-8] Thu Nov 12 14:24:24 2015
@@ -34,7 +34,7 @@ import org.opengis.parameter.ParameterDe
  * @module
  */
 @SuppressWarnings("CloneInNonCloneableClass")
-final class ParameterValueGroupWrapper implements ParameterValueGroup {
+final strictfp class ParameterValueGroupWrapper implements ParameterValueGroup {
     /**
      * The implementation to hide.
      */

Modified: sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/GeodeticObjectBuilder.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/GeodeticObjectBuilder.java?rev=1714052&r1=1714051&r2=1714052&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/GeodeticObjectBuilder.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/GeodeticObjectBuilder.java [UTF-8] Thu Nov 12 14:24:24 2015
@@ -46,7 +46,7 @@ import org.apache.sis.util.resources.Err
  * @version 0.6
  * @module
  */
-public class GeodeticObjectBuilder extends Builder<GeodeticObjectBuilder> {
+public strictfp class GeodeticObjectBuilder extends Builder<GeodeticObjectBuilder> {
     /**
      * The name of the conversion used by {@code ProjectedCRS} or {@code DerivedCRS},
      * or {@code null} if unspecified.

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=1714052&r1=1714051&r2=1714052&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] Thu Nov 12 14:24:24 2015
@@ -41,7 +41,7 @@ import static org.apache.sis.test.TestUt
     DefaultTransformationTest.class,
     SingleOperationMarshallingTest.class
 })
-public strictfp final class DefaultConcatenatedOperationTest extends XMLTestCase {
+public final strictfp class DefaultConcatenatedOperationTest extends XMLTestCase {
     /**
      * An XML file in this package containing a projected CRS definition.
      */

Modified: sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/DefaultPassThroughOperationTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/DefaultPassThroughOperationTest.java?rev=1714052&r1=1714051&r2=1714052&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/DefaultPassThroughOperationTest.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/DefaultPassThroughOperationTest.java [UTF-8] Thu Nov 12 14:24:24 2015
@@ -43,7 +43,7 @@ import static org.opengis.test.Assert.*;
     DefaultTransformationTest.class,
     SingleOperationMarshallingTest.class
 })
-public strictfp final class DefaultPassThroughOperationTest extends XMLTestCase {
+public final strictfp class DefaultPassThroughOperationTest extends XMLTestCase {
     /**
      * An XML file in this package containing a projected CRS definition.
      */

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=1714052&r1=1714051&r2=1714052&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] Thu Nov 12 14:24:24 2015
@@ -364,17 +364,17 @@ public final strictfp class MatricesTest
     }
 
     /**
-     * Tests {@link Matrices#removeRows(Matrix, int, int)}
+     * Tests {@link MatrixSIS#removeRows(int, int)}
      */
     @Test
     public void testRemoveRows() {
-        Matrix matrix = Matrices.create(4, 5, new double[] {
+        MatrixSIS 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, 0
         });
-        matrix = Matrices.removeRows(matrix, 3, 4);
+        matrix = matrix.removeRows(3, 4);
         assertEquals(Matrices.create(3, 5, new double[] {
             1, 2, 7, 8, 9,
             3, 4, 6, 7, 8,
@@ -383,17 +383,17 @@ public final strictfp class MatricesTest
     }
 
     /**
-     * Tests {@link Matrices#removeColumns(Matrix, int, int)}
+     * Tests {@link MatrixSIS#removeColumns(int, int)}
      */
     @Test
     public void testRemoveColumns() {
-        Matrix matrix = Matrices.create(4, 5, new double[] {
+        MatrixSIS 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, 0
         });
-        matrix = Matrices.removeColumns(matrix, 2, 4);
+        matrix = matrix.removeColumns(2, 4);
         assertEquals(Matrices.create(4, 3, new double[] {
             1, 2, 9,
             3, 4, 8,

Modified: sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/projection/MercatorTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/projection/MercatorTest.java?rev=1714052&r1=1714051&r2=1714052&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/projection/MercatorTest.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/projection/MercatorTest.java [UTF-8] Thu Nov 12 14:24:24 2015
@@ -18,6 +18,7 @@ package org.apache.sis.referencing.opera
 
 import org.opengis.util.FactoryException;
 import org.opengis.referencing.operation.TransformException;
+import org.opengis.referencing.operation.NoninvertibleTransformException;
 import org.apache.sis.internal.referencing.Formulas;
 import org.apache.sis.internal.referencing.provider.Mercator1SP;
 import org.apache.sis.internal.referencing.provider.Mercator2SP;
@@ -43,7 +44,7 @@ import static org.apache.sis.referencing
  * @author  Simon Reynard (Geomatys)
  * @author  Rémi Maréchal (Geomatys)
  * @since   0.6
- * @version 0.6
+ * @version 0.7
  * @module
  */
 @DependsOn(ConformalProjectionTest.class)
@@ -69,14 +70,56 @@ public final strictfp class MercatorTest
      * the ellipsoid eccentricity. We expect nothing else because all other parameters are used
      * by the (de)normalization affine transforms instead than the {@link Mercator} class itself.
      *
+     * @throws NoninvertibleTransformException should never happen.
+     *
      * @see LambertConicConformalTest#testNormalizedWKT()
      */
     @Test
-    public void testNormalizedWKT() {
+    public void testNormalizedWKT() throws NoninvertibleTransformException {
         createNormalizedProjection(true);
-        assertWktEquals(
-                "PARAM_MT[“Mercator”,\n" +
-                "  PARAMETER[“eccentricity”, 0.0818191908426215]]");
+        assertWktEquals("PARAM_MT[“Mercator”,\n" +
+                        "  PARAMETER[“eccentricity”, 0.0818191908426215]]");
+
+        transform = transform.inverse();
+        assertWktEquals("INVERSE_MT[\n" +
+                        "  PARAM_MT[“Mercator”,\n" +
+                        "    PARAMETER[“eccentricity”, 0.0818191908426215]]]");
+    }
+
+    /**
+     * Tests WKT of a complete map projection.
+     *
+     * @throws FactoryException if an error occurred while creating the map projection.
+     * @throws NoninvertibleTransformException should never happen.
+     */
+    @Test
+    @DependsOnMethod("testNormalizedWKT")
+    public void testCompleteWKT() throws FactoryException, NoninvertibleTransformException {
+        createCompleteProjection(new Mercator1SP(), true,
+                  0.5,    // Central meridian
+                  0,      // Latitude of origin (none)
+                  0,      // Standard parallel (none)
+                  0.997,  // Scale factor
+                200,      // False easting
+                100);     // False northing
+
+        assertWktEquals("PARAM_MT[“Mercator_1SP”,\n" +
+                        "  PARAMETER[“semi_major”, 6378137.0],\n" +
+                        "  PARAMETER[“semi_minor”, 6356752.314245179],\n" +
+                        "  PARAMETER[“central_meridian”, 0.5],\n" +
+                        "  PARAMETER[“scale_factor”, 0.997],\n" +
+                        "  PARAMETER[“false_easting”, 200.0],\n" +
+                        "  PARAMETER[“false_northing”, 100.0]]");
+
+        transform = transform.inverse();
+        assertWktEquals("INVERSE_MT[\n" +
+                        "  PARAM_MT[“Mercator_1SP”,\n" +
+                        "    PARAMETER[“semi_major”, 6378137.0],\n" +
+                        "    PARAMETER[“semi_minor”, 6356752.314245179],\n" +
+                        "    PARAMETER[“central_meridian”, 0.5],\n" +
+                        "    PARAMETER[“scale_factor”, 0.997],\n" +
+                        "    PARAMETER[“false_easting”, 200.0],\n" +
+                        "    PARAMETER[“false_northing”, 100.0]]]");
     }
 
     /**

Modified: sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/transform/ConcatenatedTransformTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/transform/ConcatenatedTransformTest.java?rev=1714052&r1=1714051&r2=1714052&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/transform/ConcatenatedTransformTest.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/transform/ConcatenatedTransformTest.java [UTF-8] Thu Nov 12 14:24:24 2015
@@ -16,6 +16,7 @@
  */
 package org.apache.sis.referencing.operation.transform;
 
+import org.opengis.util.FactoryException;
 import org.opengis.referencing.operation.MathTransform;
 import org.opengis.referencing.operation.TransformException;
 import org.apache.sis.internal.referencing.j2d.AffineTransform2D;
@@ -31,7 +32,7 @@ import static org.opengis.test.Assert.*;
  *
  * @author  Martin Desruisseaux (Geomatys)
  * @since   0.5
- * @version 0.5
+ * @version 0.7
  * @module
  */
 @DependsOn(ProjectiveTransformTest.class)
@@ -81,11 +82,12 @@ public final strictfp class Concatenated
      * Tests the concatenation of two affine transforms than can not be represented as a
      * {@link ConcatenatedTransformDirect}. The slower {@link ConcatenatedTransform} shall be used.
      *
+     * @throws FactoryException Should never happen.
      * @throws TransformException Should never happen.
      */
     @Test
     @org.junit.Ignore("Missing implementation of DimensionFilter.")
-    public void testGeneric() throws TransformException {
+    public void testGeneric() throws FactoryException, TransformException {
         final MathTransform first = null; //MathTransforms.dimensionFilter(4, new int[] {1,3});
 
         final AffineTransform2D second = new AffineTransform2D(0.5, 0, 0, 0.25, 0, 0);  // scale(0.5, 0.25);
@@ -100,7 +102,7 @@ public final strictfp class Concatenated
         verifyTransform(source, target);
 
         // Optimized case.
-        transform = ConcatenatedTransform.create(first, second);
+        transform = ConcatenatedTransform.create(first, second, null);
         assertInstanceOf("Expected optimized concatenation through matrix multiplication.", ProjectiveTransform.class, transform);
         validate();
         verifyTransform(source, target);
@@ -110,13 +112,15 @@ public final strictfp class Concatenated
      * Tests the concatenation of a 3D affine transform with a pass-through transform.
      * The {@link ConcatenatedTransform#create(MathTransform, MathTransform)} method
      * should optimize this case.
+     *
+     * @throws FactoryException Should never happen.
      */
     @Test
-    public void testPassthrough() {
+    public void testPassthrough() throws FactoryException {
         final MathTransform kernel = new PseudoTransform(2, 3); // Any non-linear transform.
         final MathTransform passth = PassThroughTransform.create(0, kernel, 1);
         final Matrix4 matrix = new Matrix4();
-        transform = ConcatenatedTransform.create(MathTransforms.linear(matrix), passth);
+        transform = ConcatenatedTransform.create(MathTransforms.linear(matrix), passth, null);
         assertSame("Identity transform should be ignored.", passth, transform);
         assertEquals("Source dimensions", 3, transform.getSourceDimensions());
         assertEquals("Target dimensions", 4, transform.getTargetDimensions());
@@ -127,7 +131,7 @@ public final strictfp class Concatenated
          */
         matrix.m00 = 3;
         matrix.m13 = 2;
-        transform = ConcatenatedTransform.create(MathTransforms.linear(matrix), passth);
+        transform = ConcatenatedTransform.create(MathTransforms.linear(matrix), passth, null);
         assertInstanceOf("Expected a new passthrough transform.", PassThroughTransform.class, transform);
         final MathTransform subTransform = ((PassThroughTransform) transform).subTransform;
         assertInstanceOf("Expected a new concatenated transform.", ConcatenatedTransform.class, subTransform);
@@ -139,7 +143,7 @@ public final strictfp class Concatenated
          * can not anymore be concatenated with the sub-transform.
          */
         matrix.m22 = 4;
-        transform = ConcatenatedTransform.create(MathTransforms.linear(matrix), passth);
+        transform = ConcatenatedTransform.create(MathTransforms.linear(matrix), passth, null);
         assertInstanceOf("Expected a new concatenated transform.", ConcatenatedTransform.class, transform);
         assertSame(passth, ((ConcatenatedTransform) transform).transform2);
         assertEquals("Source dimensions", 3, transform.getSourceDimensions());

Modified: sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/transform/CoordinateDomainTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/transform/CoordinateDomainTest.java?rev=1714052&r1=1714051&r2=1714052&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/transform/CoordinateDomainTest.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/transform/CoordinateDomainTest.java [UTF-8] Thu Nov 12 14:24:24 2015
@@ -34,7 +34,7 @@ import static org.junit.Assert.*;
  * @version 0.6
  * @module
  */
-public class CoordinateDomainTest extends TestCase {
+public strictfp class CoordinateDomainTest extends TestCase {
     /**
      * The tolerance threshold used in this test suite.
      */

Modified: sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/transform/CopyTransformTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/transform/CopyTransformTest.java?rev=1714052&r1=1714051&r2=1714052&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/transform/CopyTransformTest.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/transform/CopyTransformTest.java [UTF-8] Thu Nov 12 14:24:24 2015
@@ -18,20 +18,23 @@ package org.apache.sis.referencing.opera
 
 import org.opengis.referencing.operation.TransformException;
 import org.apache.sis.internal.referencing.provider.Affine;
+import org.apache.sis.referencing.operation.matrix.Matrices;
 
 // Test imports
 import org.junit.Test;
 import org.apache.sis.test.DependsOn;
+import org.apache.sis.test.DependsOnMethod;
 
 import static org.apache.sis.test.ReferencingAssert.*;
 
 
 /**
  * Tests the {@link CopyTransform} class.
+ * Also opportunistically tests consistency with {@link ProjectiveTransform}.
  *
  * @author  Martin Desruisseaux (Geomatys)
  * @since   0.5
- * @version 0.6
+ * @version 0.7
  * @module
  */
 @DependsOn({
@@ -88,7 +91,7 @@ public final strictfp class CopyTransfor
      * @throws TransformException should never happen.
      */
     @Test
-    public void test3D() throws TransformException {
+    public void testConstantDimension() throws TransformException {
         create(3, 2, 1, 0);
         assertIsNotIdentity(transform);
 
@@ -111,7 +114,8 @@ public final strictfp class CopyTransfor
      * @throws TransformException should never happen.
      */
     @Test
-    public void test3Dto2D() throws TransformException {
+    @DependsOnMethod("testConstantDimension")
+    public void testDimensionReduction() throws TransformException {
         isInverseTransformSupported = false;
         create(3, 0, 1);
         assertIsNotIdentity(transform);
@@ -128,4 +132,25 @@ public final strictfp class CopyTransfor
         makeProjectiveTransform();
         verifyTransform(source, target);
     }
+
+    /**
+     * Tests a transform with more output dimensions than input dimensions.
+     * The extra dimension has values set to 0. This kind of transform happen
+     * in the inverse of <cite>"Geographic 3D to 2D conversion"</cite> (EPSG:9659).
+     *
+     * @throws TransformException should never happen.
+     */
+    @Test
+    @DependsOnMethod("testDimensionReduction")
+    public void testDimensionAugmentation() throws TransformException {
+        transform = new ProjectiveTransform(Matrices.create(4, 3, new double[] {
+                0, 1, 0,
+                1, 0, 0,
+                0, 0, 0,
+                0, 0, 1}));
+
+        assertInstanceOf("inverse", CopyTransform.class, transform.inverse());
+        verifyTransform(new double[] {2,3,    6,0,    2, Double.NaN},
+                        new double[] {3,2,0,  0,6,0,  Double.NaN, 2, 0});
+    }
 }

Modified: sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/transform/MolodenskyTransformTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/transform/MolodenskyTransformTest.java?rev=1714052&r1=1714051&r2=1714052&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/transform/MolodenskyTransformTest.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/transform/MolodenskyTransformTest.java [UTF-8] Thu Nov 12 14:24:24 2015
@@ -140,7 +140,7 @@ public final strictfp class MolodenskyTr
     }
 
     /**
-     * Tests using the same EPSG example than the one provided in {@link EllipsoidalToCartesianTransformTest}.
+     * Tests using the same EPSG example than the one provided in {@link EllipsoidToCentricTransformTest}.
      *
      * <ul>
      *   <li>Source point in WGS84: 53°48'33.820"N, 02°07'46.380"E, 73.00 metres.</li>
@@ -295,7 +295,8 @@ public final strictfp class MolodenskyTr
     public void testInternalWKT() throws FactoryException, TransformException {
         create(true);
         assertInternalWktEquals(
-                "Concat_MT[Param_MT[“Affine”,\n" +
+                "Concat_MT[\n" +
+                "  Param_MT[“Affine”,\n" +
                 "    Parameter[“num_row”, 4],\n" +
                 "    Parameter[“num_col”, 4],\n" +
                 "    Parameter[“elt_0_0”, 0.017453292519943295],\n" +       // Degrees to radians conversion

Modified: sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/transform/ProjectiveTransformTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/transform/ProjectiveTransformTest.java?rev=1714052&r1=1714051&r2=1714052&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/transform/ProjectiveTransformTest.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/transform/ProjectiveTransformTest.java [UTF-8] Thu Nov 12 14:24:24 2015
@@ -17,6 +17,7 @@
 package org.apache.sis.referencing.operation.transform;
 
 import org.opengis.referencing.operation.Matrix;
+import org.opengis.referencing.operation.MathTransform;
 import org.opengis.referencing.operation.MathTransform1D;
 import org.opengis.referencing.operation.MathTransform2D;
 import org.opengis.referencing.operation.MathTransformFactory;
@@ -44,11 +45,11 @@ import org.opengis.test.referencing.Affi
  *
  * @author  Martin Desruisseaux (Geomatys)
  * @since   0.5
- * @version 0.5
+ * @version 0.7
  * @module
  */
 @RunWith(JUnit4.class)
-@DependsOn(AbstractMathTransformTest.class)
+@DependsOn({AbstractMathTransformTest.class, ScaleTransformTest.class})
 public strictfp class ProjectiveTransformTest extends AffineTransformTest {
     /**
      * For {@link LinearTransformTest} constructor only.
@@ -63,12 +64,22 @@ public strictfp class ProjectiveTransfor
     public ProjectiveTransformTest() {
         super(new MathTransformFactoryBase() {
             @Override
-            public ProjectiveTransform createAffineTransform(final Matrix matrix) {
+            public MathTransform createAffineTransform(final Matrix matrix) {
+                final ProjectiveTransform pt;
                 if (matrix.getNumRow() == 3 && matrix.getNumCol() == 3) {
-                    return new ProjectiveTransform2D(matrix);
+                    pt = new ProjectiveTransform2D(matrix);
                 } else {
-                    return new ProjectiveTransform(matrix);
+                    pt = new ProjectiveTransform(matrix);
                 }
+                MathTransform tr = pt.optimize();
+                if (tr != pt) {
+                    /*
+                     * Opportunistically tests ScaledTransform together with ProjectiveTransform.
+                     * We takes ScaledTransform as a reference implementation since it is simpler.
+                     */
+                    tr = new TransformResultComparator(tr, pt);
+                }
+                return tr;
             }
         });
     }
@@ -106,6 +117,9 @@ public strictfp class ProjectiveTransfor
      */
     @After
     public final void ensureImplementRightInterface() {
+        if (transform instanceof TransformResultComparator) {
+            transform = ((TransformResultComparator) transform).tested;
+        }
         /*
          * Below is a copy of MathTransformTestCase.validate(), with minor modifications
          * due to the fact that this class does not extend MathTransformTestCase.

Modified: sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/transform/TransferFunctionTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/transform/TransferFunctionTest.java?rev=1714052&r1=1714051&r2=1714052&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/transform/TransferFunctionTest.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/transform/TransferFunctionTest.java [UTF-8] Thu Nov 12 14:24:24 2015
@@ -36,7 +36,7 @@ import static org.opengis.test.Assert.*;
  * @module
  */
 @DependsOn(ExponentialTransform1DTest.class)
-public final class TransferFunctionTest extends TestCase {
+public final strictfp class TransferFunctionTest extends TestCase {
     /**
      * Tests the creation of a linear transfer function.
      */

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=1714052&r1=1714051&r2=1714052&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] Thu Nov 12 14:24:24 2015
@@ -105,6 +105,7 @@ import org.junit.BeforeClass;
     org.apache.sis.referencing.operation.transform.CoordinateDomainTest.class,
     org.apache.sis.referencing.operation.transform.IterationStrategyTest.class,
     org.apache.sis.referencing.operation.transform.AbstractMathTransformTest.class,
+    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.ExponentialTransform1DTest.class,
@@ -115,7 +116,7 @@ import org.junit.BeforeClass;
     org.apache.sis.referencing.operation.transform.TransferFunctionTest.class,
     org.apache.sis.referencing.operation.transform.MathTransformsTest.class,
     org.apache.sis.referencing.operation.transform.ContextualParametersTest.class,
-    org.apache.sis.referencing.operation.transform.EllipsoidalToCartesianTransformTest.class,
+    org.apache.sis.referencing.operation.transform.EllipsoidToCentricTransformTest.class,
     org.apache.sis.referencing.operation.transform.MolodenskyTransformTest.class,
     org.apache.sis.referencing.operation.DefaultFormulaTest.class,
     org.apache.sis.referencing.operation.DefaultOperationMethodTest.class,
@@ -124,6 +125,7 @@ import org.junit.BeforeClass;
 
     // Registration of map projections and other math transforms.
     org.apache.sis.internal.referencing.provider.AffineTest.class,
+    org.apache.sis.internal.referencing.provider.Geographic3Dto2DTest.class,
     org.apache.sis.internal.referencing.provider.LongitudeRotationTest.class,
     org.apache.sis.internal.referencing.provider.GeocentricTranslationTest.class,
     org.apache.sis.internal.referencing.provider.PositionVector7ParamTest.class,

Modified: sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/util/ArraysExt.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/util/ArraysExt.java?rev=1714052&r1=1714051&r2=1714052&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/util/ArraysExt.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/util/ArraysExt.java [UTF-8] Thu Nov 12 14:24:24 2015
@@ -75,6 +75,7 @@ import java.util.Objects;
  *
  * @see Arrays
  */
+@SuppressWarnings("ReturnOfCollectionOrArrayField")     // Array constants in this class are immutable empty arrays.
 public final class ArraysExt extends Static {
     /**
      * An empty array of {@code double} primitive type.
@@ -399,6 +400,7 @@ public final class ArraysExt extends Sta
      * @throws IllegalArgumentException  If {@code length} is negative.
      * @throws IndexOutOfBoundsException If {@code first} or {@code first+length} is out of array bounds.
      */
+    @SuppressWarnings("SuspiciousSystemArraycopy")
     private static <T> T doRemove(final T array, final int first, final int length)
             throws NullArgumentException, IllegalArgumentException, IndexOutOfBoundsException
     {
@@ -668,6 +670,7 @@ public final class ArraysExt extends Sta
      * @throws IllegalArgumentException  If {@code length} is negative.
      * @throws IndexOutOfBoundsException If {@code first} or {@code first+length} is out of array bounds.
      */
+    @SuppressWarnings("SuspiciousSystemArraycopy")
     private static <T> T doInsert(final T array, final int first, final int length)
             throws NullArgumentException, IllegalArgumentException, IndexOutOfBoundsException
     {
@@ -961,6 +964,7 @@ public final class ArraysExt extends Sta
      * @throws IllegalArgumentException  If {@code length} is negative.
      * @throws IndexOutOfBoundsException If {@code srcOff}, {@code srcOff+length} or {@code dstOff} is out of array bounds,
      */
+    @SuppressWarnings("SuspiciousSystemArraycopy")
     private static <T> T doInsert(final T src, final int srcOff,
                                   final T dst, final int dstOff, final int length)
             throws NullArgumentException, IllegalArgumentException, IndexOutOfBoundsException

Modified: sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/util/resources/Errors_fr.properties
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/util/resources/Errors_fr.properties?rev=1714052&r1=1714051&r2=1714052&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/util/resources/Errors_fr.properties [ISO-8859-1] (original)
+++ sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/util/resources/Errors_fr.properties [ISO-8859-1] Thu Nov 12 14:24:24 2015
@@ -112,7 +112,7 @@ MismatchedArrayLengths            = Les
 MismatchedCRS                     = Le syst\u00e8me de r\u00e9f\u00e9rence des coordonn\u00e9es doit \u00eatre le m\u00eame pour tous les objets.
 MismatchedDimension_2             = Les dimensions des objets ({0}D et {1}D) ne concordent pas.
 MismatchedDimension_3             = L\u2019argument \u2018{0}\u2019 a {2} dimension{2,choice,1#|2#s}, alors qu\u2019on en attendait {1}.
-MismatchedMatrixSize_4            = Une matrice de taille de {0}\u00d7{1} \u00e9tait attendue mais la matrice donn\u00e9es est de taille {2}\u00d7{3}.
+MismatchedMatrixSize_4            = Une matrice de taille de {0}\u00d7{1} \u00e9tait attendue mais la matrice donn\u00e9e est de taille {2}\u00d7{3}.
 MismatchedParameterDescriptor_1   = Le descripteur du param\u00e8tre \u00ab\u202f{0}\u202f\u00bb ne correspond pas.
 MismatchedPropertyType_1          = Le type de la propri\u00e9t\u00e9 \u00ab\u202f{0}\u202f\u00bb ne correspond pas.
 MismatchedTransformDimension_3    = La {0,choice,0#source|1#destination} de la transformation a {2} dimension{2,choice,1#|2#s}, alors qu\u2019on en attendait {1}.

Modified: sis/branches/JDK7/ide-project/NetBeans/nbproject/genfiles.properties
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/ide-project/NetBeans/nbproject/genfiles.properties?rev=1714052&r1=1714051&r2=1714052&view=diff
==============================================================================
--- sis/branches/JDK7/ide-project/NetBeans/nbproject/genfiles.properties [ISO-8859-1] (original)
+++ sis/branches/JDK7/ide-project/NetBeans/nbproject/genfiles.properties [ISO-8859-1] Thu Nov 12 14:24:24 2015
@@ -3,6 +3,6 @@
 build.xml.data.CRC32=58e6b21c
 build.xml.script.CRC32=462eaba0
 build.xml.stylesheet.CRC32=28e38971@1.53.1.46
-nbproject/build-impl.xml.data.CRC32=8bd6b764
+nbproject/build-impl.xml.data.CRC32=21ae62d4
 nbproject/build-impl.xml.script.CRC32=e337b80c
 nbproject/build-impl.xml.stylesheet.CRC32=05530350@1.79.1.48

Modified: sis/branches/JDK7/storage/sis-shapefile/src/main/java/org/apache/sis/storage/shapefile/InputFeatureStream.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/storage/sis-shapefile/src/main/java/org/apache/sis/storage/shapefile/InputFeatureStream.java?rev=1714052&r1=1714051&r2=1714052&view=diff
==============================================================================
--- sis/branches/JDK7/storage/sis-shapefile/src/main/java/org/apache/sis/storage/shapefile/InputFeatureStream.java [UTF-8] (original)
+++ sis/branches/JDK7/storage/sis-shapefile/src/main/java/org/apache/sis/storage/shapefile/InputFeatureStream.java [UTF-8] Thu Nov 12 14:24:24 2015
@@ -21,10 +21,12 @@ import java.io.InputStream;
 import java.sql.SQLFeatureNotSupportedException;
 import java.text.DecimalFormat;
 import java.text.MessageFormat;
+import java.util.List;
 
 import org.apache.sis.feature.DefaultFeatureType;
 import org.apache.sis.internal.shapefile.SQLShapefileNotFoundException;
 import org.apache.sis.internal.shapefile.ShapefileByteReader;
+import org.apache.sis.internal.shapefile.ShapefileDescriptor;
 import org.apache.sis.internal.shapefile.jdbc.*;
 import org.apache.sis.internal.shapefile.jdbc.connection.DBFConnection;
 import org.apache.sis.internal.shapefile.jdbc.metadata.DBFDatabaseMetaData;
@@ -167,6 +169,33 @@ public class InputFeatureStream extends
     }
     
     /**
+     * Return the features type.
+     * @return Features type.
+     */
+    public DefaultFeatureType getFeaturesType()
+    {
+        return this.featuresType;
+    }
+    
+    /**
+     * Returns the shapefile descriptor.
+     * @return Shapefile descriptor.
+     */
+    public ShapefileDescriptor getShapefileDescriptor()
+    {
+        return this.shapefileReader.getShapefileDescriptor();
+    }
+    
+    /** 
+     * Returns the database fields descriptors.
+     * @return List of fields descriptors. 
+     */
+    public List<DBase3FieldDescriptor> getDatabaseFieldsDescriptors()
+    {
+        return this.shapefileReader.getFieldsDescriptors();
+    }
+    
+    /**
      * Read next feature responding to the SQL query.
      * @return Feature, null if no more feature is available.
      * @throws SQLNotNumericException if a field expected numeric isn't.

Modified: sis/branches/JDK7/storage/sis-shapefile/src/main/java/org/apache/sis/storage/shapefile/ShapeFile.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/storage/sis-shapefile/src/main/java/org/apache/sis/storage/shapefile/ShapeFile.java?rev=1714052&r1=1714051&r2=1714052&view=diff
==============================================================================
--- sis/branches/JDK7/storage/sis-shapefile/src/main/java/org/apache/sis/storage/shapefile/ShapeFile.java [UTF-8] (original)
+++ sis/branches/JDK7/storage/sis-shapefile/src/main/java/org/apache/sis/storage/shapefile/ShapeFile.java [UTF-8] Thu Nov 12 14:24:24 2015
@@ -17,8 +17,13 @@
 package org.apache.sis.storage.shapefile;
 
 import java.io.File;
+import java.util.List;
 import java.util.Objects;
 
+import org.apache.sis.feature.DefaultFeatureType;
+import org.apache.sis.internal.shapefile.ShapefileDescriptor;
+import org.apache.sis.internal.shapefile.jdbc.DBase3FieldDescriptor;
+
 /**
  * Provides a ShapeFile Reader.
  *
@@ -37,6 +42,15 @@ public class ShapeFile {
     /** Database file. */
     private File databaseFile;
 
+    /** Type of the features contained in this shapefile. */
+    private DefaultFeatureType featuresType;
+
+    /** Shapefile descriptor. */
+    private ShapefileDescriptor shapefileDescriptor;
+    
+    /** Database field descriptors. */
+    private List<DBase3FieldDescriptor> databaseFieldsDescriptors;
+    
     /**
      * Construct a Shapefile from a file.
      * @param shpfile file to read.
@@ -53,6 +67,30 @@ public class ShapeFile {
     }
 
     /**
+     * Return the default feature type.
+     * @return Feature type.
+     */
+    public DefaultFeatureType getFeaturesType() {
+        return this.featuresType;
+    }
+    
+    /**
+     * Returns the shapefile descriptor.
+     * @return Shapefile descriptor.
+     */
+    public ShapefileDescriptor getShapefileDescriptor() {
+        return this.shapefileDescriptor;
+    }
+    
+    /** 
+     * Returns the database fields descriptors.
+     * @return List of fields descriptors. 
+     */
+    public List<DBase3FieldDescriptor> getDatabaseFieldsDescriptors() {
+        return this.databaseFieldsDescriptors;
+    }
+
+    /**
      * Find features corresponding to an SQL request SELECT * FROM database.
      * @return Features
      * @throws DbaseFileNotFoundException if the database file has not been found.
@@ -61,6 +99,25 @@ public class ShapeFile {
      * @throws InvalidShapefileFormatException if the shapefile format is invalid.
      */
     public InputFeatureStream findAll() throws InvalidDbaseFileFormatException, ShapefileNotFoundException, DbaseFileNotFoundException, InvalidShapefileFormatException {
-        return new InputFeatureStream(shapeFile, databaseFile);
+        InputFeatureStream is = new InputFeatureStream(shapeFile, databaseFile);
+        this.featuresType = is.getFeaturesType();
+        this.shapefileDescriptor = is.getShapefileDescriptor();
+        this.databaseFieldsDescriptors = is.getDatabaseFieldsDescriptors();
+        return is;
+    }
+
+    /**
+     * Load shapefile descriptors : features types, shapefileDescriptor, database field descriptors :
+     * this is also automatically done when executing a query on it, by findAll.
+     * @throws DbaseFileNotFoundException if the database file has not been found.
+     * @throws ShapefileNotFoundException if the shapefile has not been found.
+     * @throws InvalidDbaseFileFormatException if the database file format is invalid.
+     * @throws InvalidShapefileFormatException if the shapefile format is invalid.
+     */
+    public void loadDescriptors() throws InvalidDbaseFileFormatException, InvalidShapefileFormatException, ShapefileNotFoundException, DbaseFileNotFoundException {
+        // Doing an simple query will init the internal descriptors.
+        // It prepares a SELECT * FROM <DBase> but don't read a record by itself.
+        try(InputFeatureStream is = findAll()) {
+        }
     }
 }

Modified: sis/branches/JDK7/storage/sis-shapefile/src/test/java/org/apache/sis/storage/shapefile/ShapeFileTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/storage/sis-shapefile/src/test/java/org/apache/sis/storage/shapefile/ShapeFileTest.java?rev=1714052&r1=1714051&r2=1714052&view=diff
==============================================================================
--- sis/branches/JDK7/storage/sis-shapefile/src/test/java/org/apache/sis/storage/shapefile/ShapeFileTest.java [UTF-8] (original)
+++ sis/branches/JDK7/storage/sis-shapefile/src/test/java/org/apache/sis/storage/shapefile/ShapeFileTest.java [UTF-8] Thu Nov 12 14:24:24 2015
@@ -16,8 +16,12 @@
  */
 package org.apache.sis.storage.shapefile;
 
+import static org.junit.Assert.assertNotNull;
+
 import java.io.File;
 import java.net.URISyntaxException;
+import java.text.MessageFormat;
+import java.util.logging.Logger;
 
 import org.apache.sis.storage.DataStoreException;
 import org.apache.sis.test.TestCase;
@@ -77,6 +81,31 @@ public final strictfp class ShapeFileTes
         readAll(shp);
      }
 
+     /**
+      * Test loading of shapefile descriptors. 
+      * @throws URISyntaxException if the resource name is incorrect.
+      * @throws DataStoreException if a general file reading trouble occurs.
+      */
+     @Test
+     public void testDescriptors() throws URISyntaxException, DataStoreException {
+         Logger log = org.apache.sis.util.logging.Logging.getLogger(ShapeFileTest.class.getName());
+         
+         ShapeFile shp = new ShapeFile(path("ABRALicenseePt_4326_clipped.shp"));
+         shp.loadDescriptors();
+         
+         assertNotNull("The features type of the shapefile should have been set.", shp.getFeaturesType());
+         log.info(MessageFormat.format("ABRALicenseePt_4326_clipped.shp features type : {0}", shp.getFeaturesType()));
+         
+         assertNotNull("The shapefile descriptor of the shapefile should have been set.", shp.getShapefileDescriptor());
+         log.info(MessageFormat.format("ABRALicenseePt_4326_clipped.shp shapefile descriptor : {0}", shp.getShapefileDescriptor()));
+
+         assertNotNull("The DBase III fields descriptors of the shapefile should have been set.", shp.getDatabaseFieldsDescriptors());
+         log.info(MessageFormat.format("ABRALicenseePt_4326_clipped.shp DBase fields descriptors : {0}", shp.getDatabaseFieldsDescriptors()));
+         
+         // Loading of the descriptor shall not prevent the shapefile from being red again.
+         readAll(shp);
+     }
+     
     /**
      * Read all the shapefile content.
      * @param shp Shapefile to read.



Mime
View raw message