sis-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From desruisse...@apache.org
Subject svn commit: r1718273 [2/2] - in /sis/branches/JDK8: core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/ core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/ core/sis-referencing/src/main/java/org/apache/sis/...
Date Mon, 07 Dec 2015 09:56:50 GMT
Modified: sis/branches/JDK8/core/sis-referencing/src/main/resources/META-INF/services/org.opengis.referencing.operation.OperationMethod
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/main/resources/META-INF/services/org.opengis.referencing.operation.OperationMethod?rev=1718273&r1=1718272&r2=1718273&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/main/resources/META-INF/services/org.opengis.referencing.operation.OperationMethod
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/main/resources/META-INF/services/org.opengis.referencing.operation.OperationMethod
[UTF-8] Mon Dec  7 09:56:50 2015
@@ -39,4 +39,5 @@ org.apache.sis.internal.referencing.prov
 org.apache.sis.internal.referencing.provider.PolarStereographicNorth
 org.apache.sis.internal.referencing.provider.PolarStereographicSouth
 org.apache.sis.internal.referencing.provider.ObliqueStereographic
+org.apache.sis.internal.referencing.provider.NTv2
 org.apache.sis.internal.referencing.provider.FranceGeocentricInterpolation

Modified: sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/internal/referencing/provider/AllProvidersTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/internal/referencing/provider/AllProvidersTest.java?rev=1718273&r1=1718272&r2=1718273&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/internal/referencing/provider/AllProvidersTest.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/internal/referencing/provider/AllProvidersTest.java
[UTF-8] Mon Dec  7 09:56:50 2015
@@ -90,6 +90,7 @@ public final strictfp class AllProviders
             PolarStereographicNorth.class,
             PolarStereographicSouth.class,
             ObliqueStereographic.class,
+            NTv2.class,
             FranceGeocentricInterpolation.class
         };
     }

Modified: sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/internal/referencing/provider/FranceGeocentricInterpolationTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/internal/referencing/provider/FranceGeocentricInterpolationTest.java?rev=1718273&r1=1718272&r2=1718273&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/internal/referencing/provider/FranceGeocentricInterpolationTest.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/internal/referencing/provider/FranceGeocentricInterpolationTest.java
[UTF-8] Mon Dec  7 09:56:50 2015
@@ -148,6 +148,7 @@ public final strictfp class FranceGeocen
         try (final BufferedReader in = Files.newBufferedReader(file)) {
             grid = FranceGeocentricInterpolation.load(in, file);
         }
+        assertEquals("cellPrecision",   0.005, grid.getCellPrecision(), STRICT);
         assertEquals("getCellMean",  168.2587, grid.getCellMean(0), 0.0001);
         assertEquals("getCellMean",   58.7163, grid.getCellMean(1), 0.0001);
         assertEquals("getCellMean", -320.1801, grid.getCellMean(2), 0.0001);
@@ -175,6 +176,7 @@ public final strictfp class FranceGeocen
                 FranceGeocentricInterpolation.TZ},          // -320 metres
                 FranceGeocentricInterpolation.PRECISION);
         assertInstanceOf("Failed to compress 'float' values into 'short' values.", DatumShiftGridCompressed.class,
grid);
+        assertEquals("cellPrecision", 0.0005, grid.getCellPrecision(), STRICT);
         assertEquals("getCellMean",  168, grid.getCellMean(0), STRICT);
         assertEquals("getCellMean",   60, grid.getCellMean(1), STRICT);
         assertEquals("getCellMean", -320, grid.getCellMean(2), STRICT);
@@ -204,9 +206,10 @@ public final strictfp class FranceGeocen
          * Directions (signs) are reversed compared to NTG_88 document.
          */
         assertEquals("translationDimensions", 3, grid.getTranslationDimensions());
-        assertEquals("getCellValue",  168.196, grid.getCellValue(0, 2, 1), STRICT);
-        assertEquals("getCellValue",   58.778, grid.getCellValue(1, 2, 1), STRICT);
-        assertEquals("getCellValue", -320.127, grid.getCellValue(2, 2, 1), STRICT);
+        assertEquals("grid.accuracy",      0.05, grid.accuracy,              STRICT);
+        assertEquals("getCellValue",    168.196, grid.getCellValue(0, 2, 1), STRICT);
+        assertEquals("getCellValue",     58.778, grid.getCellValue(1, 2, 1), STRICT);
+        assertEquals("getCellValue",   -320.127, grid.getCellValue(2, 2, 1), STRICT);
         /*
          * Interpolate the (ΔX, ΔY, ΔZ) at a point.
          * Directions (signs) are reversed compared to NTG_88 document.

Added: sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/internal/referencing/provider/NTv2Test.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/internal/referencing/provider/NTv2Test.java?rev=1718273&view=auto
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/internal/referencing/provider/NTv2Test.java
(added)
+++ sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/internal/referencing/provider/NTv2Test.java
[UTF-8] Mon Dec  7 09:56:50 2015
@@ -0,0 +1,267 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.sis.internal.referencing.provider;
+
+import java.net.URL;
+import java.net.URISyntaxException;
+import java.io.IOException;
+import java.nio.ByteBuffer;
+import java.nio.ByteOrder;
+import java.nio.channels.WritableByteChannel;
+import java.nio.charset.StandardCharsets;
+import javax.measure.unit.NonSI;
+import javax.measure.quantity.Angle;
+import org.opengis.geometry.Envelope;
+import org.opengis.util.FactoryException;
+import org.opengis.referencing.operation.TransformException;
+import org.apache.sis.referencing.operation.matrix.Matrix3;
+import org.apache.sis.referencing.operation.transform.LinearTransform;
+import org.apache.sis.geometry.Envelope2D;
+import org.apache.sis.geometry.Envelopes;
+import org.apache.sis.test.TestCase;
+import org.junit.Test;
+
+import static org.opengis.test.Assert.*;
+
+// Branch-dependent imports
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.nio.file.Files;
+import java.nio.file.StandardOpenOption;
+
+
+/**
+ * Tests the {@link NTv2} grid loader.
+ *
+ * @author  Martin Desruisseaux (Geomatys)
+ * @since   0.7
+ * @version 0.7
+ * @module
+ *
+ * @see GeocentricTranslationTest#testFranceGeocentricInterpolationPoint()
+ * @see org.apache.sis.referencing.operation.transform.MolodenskyTransformTest#testFranceGeocentricInterpolationPoint()
+ */
+public final strictfp class NTv2Test extends TestCase {
+    /**
+     * Name of the file containing a small extract of the "{@code NTF_R93.gsb}" file.
+     * The amount of data in this test file is less than 0.14% of the original file.
+     */
+    public static final String TEST_FILE = "NTF_R93-extract.gsb";
+
+    /**
+     * Conversion factor from degrees to seconds.
+     */
+    private static final double DEGREES_TO_SECONDS = 3600;
+
+    /**
+     * Best accuracy found in the "{@code NTF_R93.gsb}" file.
+     */
+    private static final float ACCURACY = 0.001618f;
+
+    /**
+     * Tests loading a grid file and interpolating a sample point. The point used for
+     * this test is given by {@link FranceGeocentricInterpolationTest#samplePoint(int)}.
+     *
+     * @throws URISyntaxException if the URL to the test file can not be converted to a path.
+     * @throws IOException if an error occurred while loading the grid.
+     * @throws FactoryException if an error occurred while computing the grid.
+     * @throws TransformException if an error occurred while computing the envelope.
+     */
+    @Test
+    public void testLoader() throws URISyntaxException, IOException, FactoryException, TransformException
{
+        final URL url = NTv2Test.class.getResource(TEST_FILE);
+        assertNotNull("Test file \"" + TEST_FILE + "\" not found.", url);
+        testRGF93(Paths.get(url.toURI()),
+                 36000 - 360 * (72 + 5),    // Subgrid of RGF93 beginning at gridX = 72
+                 36000 - 360 * (72),        // Subgrid uses 6 cells along longitude axis
+                147600 + 360 * (74),        // Subgrid of RGF93 beginning at gridY = 74
+                147600 + 360 * (74 + 6));   // Subgrid uses 7 cells along latitude axis
+    }
+
+    /**
+     * Tests loading an official {@code "NTF_R93.gsb"} datum shift grid file and interpolating
the sample point
+     * given by {@link FranceGeocentricInterpolationTest#samplePoint(int)}. This test is
normally not executed
+     * because Apache SIS does not redistribute the {@code "NTF_R93.gsb"}. But developers
can invoke this method
+     * explicitely if they can provide a path to the {@code "NTF_R93.gsb"} file.
+     *
+     * @param  file Path to the official {@code "NTF_R93.gsb"} file.
+     * @throws IOException if an error occurred while loading the grid.
+     * @throws FactoryException if an error occurred while computing the grid.
+     * @throws TransformException if an error occurred while computing the envelope.
+     */
+    public static void testRGF93(final Path file) throws IOException, FactoryException, TransformException
{
+        testRGF93(file, -19800, 36000, 147600, 187200);
+    }
+
+    /**
+     * Implementation of {@link #testLoader()} and {@link #testRGF93(Path)}.
+     *
+     * @param xmin Negative of value of {@code "W_LONG"} record.
+     * @param xmax Negative of value of {@code "E_LONG"} record.
+     * @param ymin Value of the {@code "S_LAT"} record.
+     * @param ymax Value of the {@code "N_LAT"} record.
+     */
+    private static void testRGF93(final Path file, final double xmin, final double xmax,
+            final double ymin, final double ymax) throws IOException, FactoryException, TransformException
+    {
+        final double cellSize = 360;
+        final DatumShiftGridFile<Angle,Angle> grid = NTv2.getOrLoad(file);
+        assertInstanceOf("Should not be compressed.", DatumShiftGridFile.Float.class, grid);
+        assertEquals("coordinateUnit",  NonSI.SECOND_ANGLE, grid.getCoordinateUnit());
+        assertEquals("translationUnit", NonSI.SECOND_ANGLE, grid.getTranslationUnit());
+        assertEquals("translationDimensions", 2, grid.getTranslationDimensions());
+        assertTrue  ("isCellValueRatio", grid.isCellValueRatio());
+        assertEquals("cellPrecision", (ACCURACY / 10) / cellSize, grid.getCellPrecision(),
0.5E-6 / cellSize);
+        /*
+         * Verify the envelope and the conversion between geographic coordinates and grid
indices.
+         * The cells are expected to have the same size (360″ or 0.1°) in longitudes and
latitudes.
+         */
+        final Envelope envelope = grid.getDomainOfValidity();
+        assertEquals("xmin", xmin - cellSize/2, envelope.getMinimum(0), STRICT);
+        assertEquals("xmax", xmax + cellSize/2, envelope.getMaximum(0), STRICT);
+        assertEquals("ymin", ymin - cellSize/2, envelope.getMinimum(1), STRICT);
+        assertEquals("ymax", ymax + cellSize/2, envelope.getMaximum(1), STRICT);
+        assertMatrixEquals("coordinateToGrid",
+                new Matrix3(-cellSize,  0,  xmax,
+                            0,  +cellSize,  ymin,
+                            0,          0,    1),
+                ((LinearTransform) grid.getCoordinateToGrid().inverse()).getMatrix(), STRICT);
+        /*
+         * Test the same point than FranceGeocentricInterpolationTest, which is itself derived
from the
+         * NTG_88 guidance note.  If we were using the official NTF_R93.gsb file, we would
obtain after
+         * conversion the grid indices listed on the left side. But since we are using a
sub-set of the
+         * grid, we rather obtain the grid indices on the right side.
+         *
+         *   gridX ≈ 75.7432814 in official file,   ≈ 3.7432814 in the test file.
+         *   gridY ≈ 78.4451225 in official file,   ≈ 4.4451225 in the test file.
+         */
+        final double[] position = FranceGeocentricInterpolationTest.samplePoint(1);
+        final double[] expected = FranceGeocentricInterpolationTest.samplePoint(3);
+        final double[] indices  = new double[position.length];
+        final double[] vector   = new double[2];
+        for (int i=0; i<expected.length; i++) {
+            position[i] *= DEGREES_TO_SECONDS;
+            expected[i] *= DEGREES_TO_SECONDS;
+            expected[i] -= position[i];  // We will test the interpolated shifts rather than
final coordinates.
+        }
+        grid.getCoordinateToGrid().transform(position, 0, indices, 0, 1);
+        grid.interpolateInCell(indices[0], indices[1], vector);
+        vector[0] *= -cellSize;   // Was positive toward west.
+        vector[1] *= +cellSize;
+        assertArrayEquals("interpolateInCell", expected, vector,
+                FranceGeocentricInterpolationTest.ANGULAR_TOLERANCE * DEGREES_TO_SECONDS);
+
+        // Same test than above, but let DatumShiftGrid do the conversions for us.
+        assertArrayEquals("interpolateAt", expected, grid.interpolateAt(position),
+                FranceGeocentricInterpolationTest.ANGULAR_TOLERANCE * DEGREES_TO_SECONDS);
+        assertSame("Grid should be cached.", grid, NTv2.getOrLoad(file));
+    }
+
+
+
+
+    //////////////////////////////////////////////////
+    ////////                                  ////////
+    ////////        TEST FILE CREATION        ////////
+    ////////                                  ////////
+    //////////////////////////////////////////////////
+
+    /**
+     * Writes a sub-grid of the given grid in pseudo-NTv2 format. This method is used only
for creating the test file.
+     * The file created by this method is not fully NTv2 compliant (in particular, we do
not write complete header),
+     * but we take this opportunity for testing {@code NTv2.Loader} capability to be lenient.
+     *
+     * <p>This method has been executed once for creating the {@code "NTF_R93-extract.gsb"}
test file and should not
+     * be needed anymore, but we keep it around in case we have new test files to generate.
The parameter used for
+     * creating the test file are:</p>
+     *
+     * <ul>
+     *   <li>{@code gridX} = 72</li>
+     *   <li>{@code gridY} = 74</li>
+     *   <li>{@code nx}    =  6</li>
+     *   <li>{@code ny}    =  7</li>
+     * </ul>
+     *
+     * This ensure that the grid indices (75.7432814, 78.4451225) is included in the test
file.
+     * Those grid indices is the location of the (2°25′32.4187″N 48°50′40.2441″W)
test point to interpolate.
+     *
+     * <div class="section">Limitations</div>
+     * This method assumes that bounding box and increments have integer values, and that
any fractional part
+     * is rounding errors. This is usually the case when using the {@code "SECONDS"} unit
of measurement.
+     * This assumption does not apply to the shift values.
+     *
+     * @param grid  The full grid from which to extract a few values.
+     * @param out   Where to write the test file.
+     * @param gridX Index along the longitude axis of the first cell to write.
+     * @param gridY Index along the latitude axis of the first cell to write.
+     * @param nx    Number of cells to write along the longitude axis.
+     * @param ny    Number of cells to write along the latitude axis.
+     * @throws TransformException if an error occurred while computing the envelope.
+     * @throws IOException if an error occurred while writing the test file.
+     */
+    public static void writeSubGrid(final DatumShiftGridFile<Angle,Angle> grid, final
Path out,
+            final int gridX, final int gridY, final int nx, final int ny) throws IOException,
TransformException
+    {
+        Envelope envelope = new Envelope2D(null, gridX, gridY, nx - 1, ny - 1);
+        envelope = Envelopes.transform(grid.getCoordinateToGrid().inverse(), envelope);
+        final ByteBuffer buffer = ByteBuffer.allocate(4096);
+        buffer.order(ByteOrder.LITTLE_ENDIAN);
+        writeString(buffer, "NUM_OREC"); buffer.putInt(5); nextRecord(buffer);
+        writeString(buffer, "NUM_SREC"); buffer.putInt(7); nextRecord(buffer);
+        writeString(buffer, "NUM_FILE"); buffer.putInt(1); nextRecord(buffer);
+        writeString(buffer, "GS_TYPE");  writeString(buffer, "SECONDS");
+        writeString(buffer, "VERSION");  writeString(buffer, "SIS_TEST");   // Last overview
record.
+        writeString(buffer, "S_LAT");    buffer.putDouble(Math.rint( envelope.getMinimum(1)));
+        writeString(buffer, "N_LAT");    buffer.putDouble(Math.rint( envelope.getMaximum(1)));
+        writeString(buffer, "E_LONG");   buffer.putDouble(Math.rint(-envelope.getMaximum(0)));
 // Sign reversed.
+        writeString(buffer, "W_LONG");   buffer.putDouble(Math.rint(-envelope.getMinimum(0)));
+        writeString(buffer, "LAT_INC");  buffer.putDouble(Math.rint( envelope.getSpan(1)
/ (ny - 1)));
+        writeString(buffer, "LONG_INC"); buffer.putDouble(Math.rint( envelope.getSpan(0)
/ (nx - 1)));
+        writeString(buffer, "GS_COUNT"); buffer.putInt(nx * ny); nextRecord(buffer);
+        for (int y=0; y<ny; y++) {
+            for (int x=0; x<nx; x++) {
+                buffer.putFloat((float) grid.getCellValue(1, gridX + x, gridY + y));
+                buffer.putFloat((float) grid.getCellValue(0, gridX + x, gridY + y));
+                buffer.putFloat(ACCURACY);
+                buffer.putFloat(ACCURACY);
+            }
+        }
+        writeString(buffer, "END");
+        nextRecord(buffer);
+        try (final WritableByteChannel c = Files.newByteChannel(out, StandardOpenOption.CREATE,
StandardOpenOption.WRITE)) {
+            buffer.flip();
+            c.write(buffer);
+        }
+    }
+
+    /**
+     * Writes the given string in the given buffer. It is caller's responsibility to ensure
that the
+     * string does not occupy more than 8 bytes in US-ASCII encoding.
+     */
+    private static void writeString(final ByteBuffer buffer, final String keyword) {
+        final int upper = buffer.position() + 8;    // "8" is the space allowed for strings
in NTv2 format.
+        buffer.put(keyword.getBytes(StandardCharsets.US_ASCII));
+        while (buffer.position() != upper) buffer.put((byte) ' ');
+    }
+
+    /**
+     * Moves the buffer position to the next record.
+     */
+    private static void nextRecord(final ByteBuffer buffer) {
+        buffer.position(((buffer.position() / 16) + 1) * 16);
+    }
+}

Propchange: sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/internal/referencing/provider/NTv2Test.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/internal/referencing/provider/NTv2Test.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain;charset=UTF-8

Modified: sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/transform/InterpolatedGeocentricTransformTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/transform/InterpolatedGeocentricTransformTest.java?rev=1718273&r1=1718272&r2=1718273&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/transform/InterpolatedGeocentricTransformTest.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/transform/InterpolatedGeocentricTransformTest.java
[UTF-8] Mon Dec  7 09:56:50 2015
@@ -59,11 +59,12 @@ import static org.opengis.test.Assert.*;
 })
 public final strictfp class InterpolatedGeocentricTransformTest extends MathTransformTestCase
{
     /**
-     * Creates the <cite>"France geocentric interpolation"</cite> transform.
+     * Creates the <cite>"France geocentric interpolation"</cite> transform,
+     * including the normalization and denormalization parts.
      *
      * @throws FactoryException if an error occurred while loading the grid.
      */
-    private void create() throws FactoryException {
+    private void createGeodeticTransformation() throws FactoryException {
         final URL file = FranceGeocentricInterpolationTest.class.getResource(FranceGeocentricInterpolationTest.TEST_FILE);
         assertNotNull("Test file \"" + FranceGeocentricInterpolationTest.TEST_FILE + "\"
not found.", file);
         final Ellipsoid source = HardCodedDatum.NTF.getEllipsoid();     // Clarke 1880 (IGN)
@@ -89,7 +90,7 @@ public final strictfp class Interpolated
      */
     @Test
     public void testForwardTransform() throws FactoryException, TransformException {
-        create();   // Create the inverse of the transform we are interrested in.
+        createGeodeticTransformation();   // Create the inverse of the transform we are interrested
in.
         transform = transform.inverse();
         isInverseTransformSupported = false;
         verifyTransform(FranceGeocentricInterpolationTest.samplePoint(3),
@@ -111,7 +112,7 @@ public final strictfp class Interpolated
     @Test
     @DependsOnMethod("testForwardTransform")
     public void testInverseTransform() throws FactoryException, TransformException {
-        create();
+        createGeodeticTransformation();
         isInverseTransformSupported = false;
         verifyTransform(FranceGeocentricInterpolationTest.samplePoint(1),
                         FranceGeocentricInterpolationTest.samplePoint(3));
@@ -119,6 +120,24 @@ public final strictfp class Interpolated
     }
 
     /**
+     * Tests the derivatives at the sample point. This method compares the derivatives computed
by
+     * the transform with an estimation of derivatives computed by the finite differences
method.
+     *
+     * @throws FactoryException if an error occurred while loading the grid.
+     * @throws TransformException if an error occurred while transforming the coordinate.
+     */
+    @Test
+    @DependsOnMethod("testForwardTransform")
+    public void testDerivative() throws FactoryException, TransformException {
+        createGeodeticTransformation();
+        transform = transform.inverse();
+        final double delta = (100.0 / 60) / 1852;      // Approximatively 100 metres.
+        derivativeDeltas = new double[] {delta, delta};
+        tolerance = 1E-5;   // Empirical value.
+        verifyDerivative(FranceGeocentricInterpolationTest.samplePoint(1));
+    }
+
+    /**
      * Tests the Well Known Text (version 1) formatting.
      * The result is what we show to users, but may quite different than what SIS has in
memory.
      *
@@ -127,7 +146,7 @@ public final strictfp class Interpolated
      */
     @Test
     public void testWKT() throws FactoryException, TransformException {
-        create();
+        createGeodeticTransformation();
         transform = transform.inverse();
         assertWktEqualsRegex("(?m)\\Q" +
                 "PARAM_MT[“Geocentric interpolation”,\n" +
@@ -161,7 +180,7 @@ public final strictfp class Interpolated
      */
     @Test
     public void testInternalWKT() throws FactoryException, TransformException {
-        create();
+        createGeodeticTransformation();
         assertInternalWktEqualsRegex("(?m)\\Q" +
                 "Concat_MT[\n" +
                 "  Param_MT[“Affine parametric transformation”,\n" +

Added: sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/transform/InterpolatedTransformTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/transform/InterpolatedTransformTest.java?rev=1718273&view=auto
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/transform/InterpolatedTransformTest.java
(added)
+++ sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/transform/InterpolatedTransformTest.java
[UTF-8] Mon Dec  7 09:56:50 2015
@@ -0,0 +1,141 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.sis.referencing.operation.transform;
+
+import java.net.URL;
+import org.opengis.util.FactoryException;
+import org.opengis.parameter.ParameterValueGroup;
+import org.opengis.referencing.operation.MathTransformFactory;
+import org.opengis.referencing.operation.TransformException;
+import org.apache.sis.internal.referencing.provider.NTv2;
+import org.apache.sis.internal.referencing.Formulas;
+import org.apache.sis.internal.system.DefaultFactories;
+
+// Test dependencies
+import org.apache.sis.internal.referencing.provider.FranceGeocentricInterpolationTest;
+import org.apache.sis.internal.referencing.provider.NTv2Test;
+import org.apache.sis.test.DependsOnMethod;
+import org.apache.sis.test.DependsOn;
+import org.junit.Test;
+
+import static org.junit.Assert.assertNotNull;
+
+
+/**
+ * Tests {@link InterpolatedTransform}.
+ *
+ * @author  Martin Desruisseaux (Geomatys)
+ * @since   0.7
+ * @version 0.7
+ * @module
+ */
+@DependsOn({
+    NTv2Test.class
+})
+public final strictfp class InterpolatedTransformTest extends MathTransformTestCase {
+    /**
+     * Creates the same transformation than <cite>"France geocentric interpolation"</cite>
transform
+     * (approximatively), but using shifts in geographic domain instead than in geocentric
domain.
+     *
+     * @throws FactoryException if an error occurred while loading the grid.
+     */
+    private void createGeodeticTransformation() throws FactoryException {
+        final URL file = NTv2Test.class.getResource(NTv2Test.TEST_FILE);
+        assertNotNull("Test file \"" + NTv2Test.TEST_FILE + "\" not found.", file);
+        final NTv2 provider = new NTv2();
+        final ParameterValueGroup values = provider.getParameters().createValue();
+        values.parameter("Latitude and longitude difference file").setValue(file);    //
Automatic conversion from URL to Path.
+        transform = provider.createMathTransform(DefaultFactories.forBuildin(MathTransformFactory.class),
values);
+        tolerance = Formulas.ANGULAR_TOLERANCE;
+    }
+
+    /**
+     * Tests transformation of sample point from NTF to RGF93.
+     *
+     * @throws FactoryException if an error occurred while loading the grid.
+     * @throws TransformException if an error occurred while transforming the coordinate.
+     *
+     * @see InterpolatedGeocentricTransformTest#testInverseTransform()
+     */
+    @Test
+    public void testForwardTransform() throws FactoryException, TransformException {
+        createGeodeticTransformation();
+        isInverseTransformSupported = false;
+        verifyTransform(FranceGeocentricInterpolationTest.samplePoint(1),
+                        FranceGeocentricInterpolationTest.samplePoint(3));
+        validate();
+    }
+
+    /**
+     * Tests transformation of sample point from RGF93 to NTF.
+     *
+     * @throws FactoryException if an error occurred while loading the grid.
+     * @throws TransformException if an error occurred while transforming the coordinate.
+     *
+     * @see InterpolatedGeocentricTransformTest#testForwardTransform()
+     */
+    @Test
+    @DependsOnMethod("testForwardTransform")
+    public void testInverseTransform() throws FactoryException, TransformException {
+        createGeodeticTransformation();
+        transform = transform.inverse();
+        isInverseTransformSupported = false;
+        verifyTransform(FranceGeocentricInterpolationTest.samplePoint(3),
+                        FranceGeocentricInterpolationTest.samplePoint(1));
+        validate();
+    }
+
+    /**
+     * Tests the derivatives at the sample point. This method compares the derivatives computed
by
+     * the transform with an estimation of derivatives computed by the finite differences
method.
+     *
+     * @throws FactoryException if an error occurred while loading the grid.
+     * @throws TransformException if an error occurred while transforming the coordinate.
+     */
+    @Test
+    @DependsOnMethod("testForwardTransform")
+    public void testDerivative() throws FactoryException, TransformException {
+        createGeodeticTransformation();
+        final double delta = 0.2;
+        derivativeDeltas = new double[] {delta, delta};
+        tolerance = 5E-6;   // Empirical value.
+        verifyDerivative(FranceGeocentricInterpolationTest.samplePoint(1));
+    }
+
+    /**
+     * Tests the Well Known Text (version 1) formatting.
+     * The result is what we show to users, but may quite different than what SIS has in
memory.
+     *
+     * @throws FactoryException if an error occurred while creating a transform.
+     * @throws TransformException should never happen.
+     */
+    @Test
+    public void testWKT() throws FactoryException, TransformException {
+        createGeodeticTransformation();
+        assertWktEqualsRegex("(?m)\\Q" +
+                "PARAM_MT[“NTv2”,\n" +
+                "  PARAMETER[“Latitude and longitude difference file”, “\\E.*\\W\\Q"
+
+                             NTv2Test.TEST_FILE + "”]]\\E");
+
+        transform = transform.inverse();
+        assertWktEqualsRegex("(?m)\\Q" +
+                "INVERSE_MT[\n" +
+                "  PARAM_MT[“NTv2”,\n" +
+                "    PARAMETER[“Latitude and longitude difference file”, “\\E.*\\W\\Q"
+
+                             NTv2Test.TEST_FILE + "”]]]\\E");
+    }
+}

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

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

Modified: sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/test/suite/ReferencingTestSuite.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/test/suite/ReferencingTestSuite.java?rev=1718273&r1=1718272&r2=1718273&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/test/suite/ReferencingTestSuite.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/test/suite/ReferencingTestSuite.java
[UTF-8] Mon Dec  7 09:56:50 2015
@@ -133,8 +133,10 @@ import org.junit.BeforeClass;
     org.apache.sis.internal.referencing.provider.CoordinateFrameRotationTest.class,
     org.apache.sis.internal.referencing.provider.MolodenskyTest.class,
     org.apache.sis.internal.referencing.provider.FranceGeocentricInterpolationTest.class,
+    org.apache.sis.internal.referencing.provider.NTv2Test.class,
     org.apache.sis.internal.referencing.provider.MapProjectionTest.class,
     org.apache.sis.internal.referencing.provider.AllProvidersTest.class,
+    org.apache.sis.referencing.operation.transform.InterpolatedTransformTest.class,
     org.apache.sis.referencing.operation.transform.InterpolatedGeocentricTransformTest.class,
     org.apache.sis.referencing.operation.transform.DefaultMathTransformFactoryTest.class,
 

Added: sis/branches/JDK8/core/sis-referencing/src/test/resources/org/apache/sis/internal/referencing/provider/NTF_R93-extract.gsb
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/test/resources/org/apache/sis/internal/referencing/provider/NTF_R93-extract.gsb?rev=1718273&view=auto
==============================================================================
Binary file - no diff available.

Propchange: sis/branches/JDK8/core/sis-referencing/src/test/resources/org/apache/sis/internal/referencing/provider/NTF_R93-extract.gsb
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Modified: sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/resources/Messages.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/resources/Messages.java?rev=1718273&r1=1718272&r2=1718273&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/resources/Messages.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/resources/Messages.java
[UTF-8] Mon Dec  7 09:56:50 2015
@@ -150,6 +150,11 @@ public final class Messages extends Inde
         public static final short UnknownElementsInText = 13;
 
         /**
+         * Loading of “{0}” done, but some records were ignored because of unrecognized
keywords: {1}
+         */
+        public static final short UnknownKeywordInRecord_2 = 19;
+
+        /**
          * Can not parse “{1}” as an instance of ‘{0}’. The value is stored as plain
text instead, but
          * will be ignored by some processing.
          */

Modified: sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/resources/Messages.properties
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/resources/Messages.properties?rev=1718273&r1=1718272&r2=1718273&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/resources/Messages.properties
[ISO-8859-1] (original)
+++ sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/resources/Messages.properties
[ISO-8859-1] Mon Dec  7 09:56:50 2015
@@ -32,4 +32,5 @@ MisnamedParameter_1             = Despit
 NonConformFormatting_1          = Formatting of \u201c{0}\u201d is not conform to the format
standard.
 NotFormalProjectionParameter_1  = This parameter borrowed from the \u201c{0}\u201d projection
is not formally a parameter of this projection.
 UnknownElementsInText           = The text contains unknown elements:
+UnknownKeywordInRecord_2        = Loading of \u201c{0}\u201d done, but some records were
ignored because of unrecognized keywords: {1}
 UnparsableValueStoredAsText_2   = Can not parse \u201c{1}\u201d as an instance of \u2018{0}\u2019.
The value is stored as plain text instead, but will be ignored by some processing.

Modified: sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/resources/Messages_fr.properties
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/resources/Messages_fr.properties?rev=1718273&r1=1718272&r2=1718273&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/resources/Messages_fr.properties
[ISO-8859-1] (original)
+++ sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/resources/Messages_fr.properties
[ISO-8859-1] Mon Dec  7 09:56:50 2015
@@ -39,4 +39,5 @@ MisnamedParameter_1             = Malgr\
 NonConformFormatting_1          = L\u2019\u00e9criture de \u00ab\u202f{0}\u202f\u00bb n\u2019est
pas conforme au format standard.
 NotFormalProjectionParameter_1  = Ce param\u00e8tre emprunt\u00e9 \u00e0 la projection \u00ab\u202f{0}\u202f\u00bb
n\u2019est pas formellement un param\u00e8tre de cette projection.
 UnknownElementsInText           = Le texte contient des \u00e9l\u00e9ments inconnus\u00a0:
+UnknownKeywordInRecord_2        = La lecture de \u00ab\u202f{0}\u202f\u00bb a \u00e9t\u00e9
faite, mais en ignorant certains enregistrements \u00e0 cause de mots-cl\u00e9s non reconnus:
{1}
 UnparsableValueStoredAsText_2   = La valeur \u00ab\u202f{1}\u202f\u00bb ne peut pas \u00eatre
interpr\u00e9t\u00e9e comme une instance de \u2018{0}\u2019. Elle est donc m\u00e9moris\u00e9e
sous sa forme textuelle, mais sera ignor\u00e9e par certains traitements.

Modified: sis/branches/JDK8/ide-project/NetBeans/build.xml
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/ide-project/NetBeans/build.xml?rev=1718273&r1=1718272&r2=1718273&view=diff
==============================================================================
--- sis/branches/JDK8/ide-project/NetBeans/build.xml (original)
+++ sis/branches/JDK8/ide-project/NetBeans/build.xml Mon Dec  7 09:56:50 2015
@@ -165,6 +165,7 @@
       <fileset dir="${project.root}/core/sis-referencing/src/test/resources">
         <include name="**/*.xml"/>
         <include name="**/*.txt"/>
+        <include name="**/*.gsb"/>
       </fileset>
     </copy>
     <copy todir="${build.test.classes.dir}">




Mime
View raw message