sis-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From desruisse...@apache.org
Subject svn commit: r1783998 - in /sis/branches/JDK8/core/sis-referencing/src: main/java/org/apache/sis/referencing/gazetteer/MilitaryGridReferenceSystem.java test/java/org/apache/sis/referencing/gazetteer/MilitaryGridReferenceSystemTest.java
Date Wed, 22 Feb 2017 10:04:17 GMT
Author: desruisseaux
Date: Wed Feb 22 10:04:17 2017
New Revision: 1783998

URL: http://svn.apache.org/viewvc?rev=1783998&view=rev
Log:
Fix an occasional 2000 km error in decode(CharSequence).

Modified:
    sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/gazetteer/MilitaryGridReferenceSystem.java
    sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/gazetteer/MilitaryGridReferenceSystemTest.java

Modified: sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/gazetteer/MilitaryGridReferenceSystem.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/gazetteer/MilitaryGridReferenceSystem.java?rev=1783998&r1=1783997&r2=1783998&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/gazetteer/MilitaryGridReferenceSystem.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/gazetteer/MilitaryGridReferenceSystem.java
[UTF-8] Wed Feb 22 10:04:17 2017
@@ -426,9 +426,9 @@ public class MilitaryGridReferenceSystem
             final ProjectedCRS crs = datum.universal(Math.signum(φs), λ0);
             final DirectPosition2D position = new DirectPosition2D(φs, λ0);
             final MathTransform projection = crs.getConversionFromBase().getMathTransform();
-            final double northing = Math.floor(projection.transform(position, position).getOrdinate(1)
-                                    / (GRID_SQUARE_SIZE * GRID_ROW_COUNT))
-                                    * (GRID_SQUARE_SIZE * GRID_ROW_COUNT);
+            double northing = projection.transform(position, position).getOrdinate(1) / (GRID_SQUARE_SIZE
* GRID_ROW_COUNT);
+            northing = (φs >= 0) ? Math.floor(northing) : Math.ceil(northing);      //
Round toward equator.
+            northing *= (GRID_SQUARE_SIZE * GRID_ROW_COUNT);
             position.setCoordinateReferenceSystem(crs);
             position.x = col * GRID_SQUARE_SIZE;
             position.y = row * GRID_SQUARE_SIZE + northing;

Modified: sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/gazetteer/MilitaryGridReferenceSystemTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/gazetteer/MilitaryGridReferenceSystemTest.java?rev=1783998&r1=1783997&r2=1783998&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/gazetteer/MilitaryGridReferenceSystemTest.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/gazetteer/MilitaryGridReferenceSystemTest.java
[UTF-8] Wed Feb 22 10:04:17 2017
@@ -171,6 +171,11 @@ public final strictfp class MilitaryGrid
         assertSame("crs", CommonCRS.WGS84.universal(82, 10), position.getCoordinateReferenceSystem());
         assertEquals("Easting",   422407, position.getOrdinate(0), STRICT);
         assertEquals("Northing", 9108183, position.getOrdinate(1), STRICT);
+
+        position = coder.decode("32FNL9360826322");
+        assertSame("crs", CommonCRS.WGS84.universal(-49.4, 10.3), position.getCoordinateReferenceSystem());
+        assertEquals("Easting",   593608, position.getOrdinate(0), STRICT);
+        assertEquals("Northing", 4526322, position.getOrdinate(1), STRICT);
     }
 
     /**
@@ -305,7 +310,7 @@ public final strictfp class MilitaryGrid
      *
      * @throws TransformException if an error occurred while computing the coordinate.
      */
-//  @Test
+    @Test
     @DependsOnMethod({"testEncoding", "testDecoding"})
     public void verifyConsistency() throws TransformException {
         final Random random = TestUtilities.createRandomNumberGenerator();



Mime
View raw message