sis-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From desruisse...@apache.org
Subject svn commit: r1715436 - in /sis/branches/JDK8/core/sis-referencing/src: main/java/org/apache/sis/internal/referencing/provider/ main/java/org/apache/sis/referencing/datum/ main/java/org/apache/sis/referencing/operation/transform/ test/java/org/apache/si...
Date Fri, 20 Nov 2015 22:29:08 GMT
Author: desruisseaux
Date: Fri Nov 20 22:29:07 2015
New Revision: 1715436

URL: http://svn.apache.org/viewvc?rev=1715436&view=rev
Log:
Express the DatumShiftGrids envelopes in radians instead than degrees.
Since those grids are "low level" objects, majority of users will not handle them directly.

Modified:
    sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/DatumShiftGridFile.java
    sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/FranceGeocentricInterpolation.java
    sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/DatumShiftGrid.java
    sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/InterpolatedGeocentricTransform.java
    sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/internal/referencing/provider/FranceGeocentricInterpolationTest.java

Modified: sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/DatumShiftGridFile.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/DatumShiftGridFile.java?rev=1715436&r1=1715435&r2=1715436&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/DatumShiftGridFile.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/DatumShiftGridFile.java
[UTF-8] Fri Nov 20 22:29:07 2015
@@ -32,6 +32,8 @@ import java.nio.file.Path;
  *
  * <p>This class is in internal package (not public API) because it makes the following
assumptions:</p>
  * <ul>
+ *   <li>Values <var>x₀</var>, <var>y₀</var>, <var>Δx</var>
and <var>Δy</var>
+ *       given to the constructor are in degrees and needs to be converted to radians.</li>
  *   <li>Single floating-point precision ({@code float)} is sufficient.</li>
  *   <li>Values were defined in base 10, usually in ASCII files. This assumption has
an impact on conversions
  *       from {@code float} to {@code double} performed by the {@link #getCellValue(int,
int, int)} method.</li>
@@ -73,9 +75,10 @@ public abstract class DatumShiftGridFile
     /**
      * Creates a new datum shift grid for the given grid geometry.
      * The actual offset values need to be provided by subclasses.
+     * All {@code double} values given to this constructor will be converted from degrees
to radians.
      *
-     * @param x0  First ordinate (often longitude in radians) of the center of the cell at
grid index (0,0).
-     * @param y0  Second ordinate (often latitude in radians) of the center of the cell at
grid index (0,0).
+     * @param x0  Longitude in degrees of the center of the cell at grid index (0,0).
+     * @param y0  Latitude in degrees of the center of the cell at grid index (0,0).
      * @param Δx  Increment in <var>x</var> value between cells at index <var>gridX</var>
and <var>gridX</var> + 1.
      * @param Δy  Increment in <var>y</var> value between cells at index <var>gridY</var>
and <var>gridY</var> + 1.
      * @param nx  Number of cells along the <var>x</var> axis in the grid.
@@ -86,7 +89,11 @@ public abstract class DatumShiftGridFile
                        final int    nx, final int    ny,
                        final Path file)
     {
-        super(x0, y0, Δx, Δy, nx, ny);
+        super(Math.toRadians(x0),
+              Math.toRadians(y0),
+              Math.toRadians(Δx),
+              Math.toRadians(Δy),
+              nx, ny);
         this.file = file;
     }
 
@@ -192,6 +199,7 @@ public abstract class DatumShiftGridFile
 
         /**
          * Creates a new datum shift grid with the given grid geometry, filename and number
of shift dimensions.
+         * All {@code double} values given to this constructor will be converted from degrees
to radians.
          */
         Float(final double x0, final double y0,
               final double Δx, final double Δy,

Modified: sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/FranceGeocentricInterpolation.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/FranceGeocentricInterpolation.java?rev=1715436&r1=1715435&r2=1715436&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/FranceGeocentricInterpolation.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/FranceGeocentricInterpolation.java
[UTF-8] Fri Nov 20 22:29:07 2015
@@ -399,8 +399,8 @@ public final class FranceGeocentricInter
         do {
             final StringTokenizer t = new StringTokenizer(line.trim());
             t.nextToken();                                                // Ignored
-            final double x = Double.parseDouble(t.nextToken());           // Longitude
-            final double y = Double.parseDouble(t.nextToken());           // Latitude
+            final double x = Double.parseDouble(t.nextToken());           // Longitude in
degrees
+            final double y = Double.parseDouble(t.nextToken());           // Latitude in
degrees
             final int    i = Math.toIntExact(Math.round((x - x0) / Δx));  // Column index
             final int    j = Math.toIntExact(Math.round((y - y0) / Δy));  // Row index
             if (i < 0 || i >= nx) {

Modified: sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/DatumShiftGrid.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/DatumShiftGrid.java?rev=1715436&r1=1715435&r2=1715436&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/DatumShiftGrid.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/DatumShiftGrid.java
[UTF-8] Fri Nov 20 22:29:07 2015
@@ -159,8 +159,9 @@ public abstract class DatumShiftGrid imp
      * to the {@link #offsetAt offsetAt(x, y, …)} method. Coordinates outside that domain
of validity will still
      * be accepted, but the result of offset computation may be very wrong.
      *
-     * <p>In the datum shift grids used by {@link org.apache.sis.referencing.operation.transform.InterpolatedTransform},
-     * the domain of validity is longitude and latitude in <strong>radians</strong>.</p>
+     * <p>In datum shift grids used by {@link org.apache.sis.referencing.operation.transform.InterpolatedGeocentricTransform},
+     * the domain of validity is always expressed as longitudes and latitudes in <strong>radians</strong>.
+     * The envelope is usually in radians for simpler (non-geocentric) interpolations too,
for consistency reasons.</p>
      *
      * @return The domain covered by this grid.
      */

Modified: sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/InterpolatedGeocentricTransform.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/InterpolatedGeocentricTransform.java?rev=1715436&r1=1715435&r2=1715436&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/InterpolatedGeocentricTransform.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/InterpolatedGeocentricTransform.java
[UTF-8] Fri Nov 20 22:29:07 2015
@@ -289,7 +289,7 @@ public class InterpolatedGeocentricTrans
         final double[] offset = new double[3];
         final double λ = srcPts[srcOff];
         final double φ = srcPts[srcOff+1];
-        grid.offsetAt(Math.toDegrees(λ), Math.toDegrees(φ), offset);    // TODO: avoid
conversion to degrees.
+        grid.offsetAt(λ, φ, offset);
         return transform(λ, φ, isSource3D ? srcPts[srcOff+2] : 0,
                 dstPts, dstOff, offset[0], offset[1], offset[2], derivate);
     }

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=1715436&r1=1715435&r2=1715436&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] Fri Nov 20 22:29:07 2015
@@ -158,10 +158,10 @@ public final strictfp class FranceGeocen
      */
     private static void verifyGrid(final DatumShiftGridFile grid) {
         final Envelope envelope = grid.getDomainOfValidity();
-        assertEquals("xmin",  2.2 - 0.05, envelope.getMinimum(0), 1E-10);
-        assertEquals("xmax",  2.5 + 0.05, envelope.getMaximum(0), 1E-10);
-        assertEquals("ymin", 48.5 - 0.05, envelope.getMinimum(1), 1E-10);
-        assertEquals("ymax", 49.0 + 0.05, envelope.getMaximum(1), 1E-10);
+        assertEquals("xmin",  2.2 - 0.05, Math.toDegrees(envelope.getMinimum(0)), 1E-10);
+        assertEquals("xmax",  2.5 + 0.05, Math.toDegrees(envelope.getMaximum(0)), 1E-10);
+        assertEquals("ymin", 48.5 - 0.05, Math.toDegrees(envelope.getMinimum(1)), 1E-10);
+        assertEquals("ymax", 49.0 + 0.05, Math.toDegrees(envelope.getMaximum(1)), 1E-10);
         assertEquals("shiftDimensions", 3, grid.getShiftDimensions());
         /*
          * Interpolate the (ΔX, ΔY, ΔZ) at a point.
@@ -169,7 +169,7 @@ public final strictfp class FranceGeocen
         final double[] point    = samplePoint(1);
         final double[] expected = samplePoint(2);
         final double[] offset   = new double[3];
-        grid.offsetAt(point[0], point[1], offset);
+        grid.offsetAt(Math.toRadians(point[0]), Math.toRadians(point[1]), offset);
         assertArrayEquals("(ΔX, ΔY, ΔZ)", expected, offset, 0.0005);
     }
 



Mime
View raw message