sis-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From desruisse...@apache.org
Subject svn commit: r1784774 - /sis/branches/JDK8/core/sis-referencing-by-identifiers/src/main/java/org/apache/sis/referencing/gazetteer/MilitaryGridReferenceSystem.java
Date Tue, 28 Feb 2017 16:23:40 GMT
Author: desruisseaux
Date: Tue Feb 28 16:23:40 2017
New Revision: 1784774

URL: http://svn.apache.org/viewvc?rev=1784774&view=rev
Log:
Make the UTM zone verification a little bit less permissive by checking that the error is
on the side of the zone change
(not an error on the opposite side, where we should not have any ambiguity).

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

Modified: sis/branches/JDK8/core/sis-referencing-by-identifiers/src/main/java/org/apache/sis/referencing/gazetteer/MilitaryGridReferenceSystem.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing-by-identifiers/src/main/java/org/apache/sis/referencing/gazetteer/MilitaryGridReferenceSystem.java?rev=1784774&r1=1784773&r2=1784774&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing-by-identifiers/src/main/java/org/apache/sis/referencing/gazetteer/MilitaryGridReferenceSystem.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing-by-identifiers/src/main/java/org/apache/sis/referencing/gazetteer/MilitaryGridReferenceSystem.java
[UTF-8] Tue Feb 28 16:23:40 2017
@@ -706,16 +706,19 @@ parse:                  switch (part) {
                      * we allow a tolerance if the point is close to a line of zone change.
                      */
                     final double λ = geographic.getOrdinate(1);
-                    final int actual = ZONER.zone(φ, λ);
-                    final int threshold;
-                    if (Math.abs(φ) >= TransverseMercator.Zoner.NORWAY_BOUNDS) {
-                        threshold = 1;                      // Tolerance in zone numbers
for high latitudes.
-                    } else {
-                        final double rλ = Math.IEEEremainder(λ - ZONER.origin, ZONER.width);
   // Distance to closest zone change, in degrees of longitude.
-                        final double cv = (position.x - ZONER.easting) / (λ - λ0);    
         // Approximative conversion factor from degrees to metres.
-                        threshold = Math.abs(rλ) * cv <= sx ? 1 : 0;                
           // Be tolerant if distance in metres is less than resolution.
+                    final int zoneError = ZONER.zone(φ, λ) - zone;
+                    if (zoneError != 0) {
+                        if (Math.abs(φ) >= TransverseMercator.Zoner.NORWAY_BOUNDS) {
+                            isValid = Math.abs(zoneError) == 1;         // Tolerance in zone
numbers for high latitudes.
+                        } else {
+                            final double rλ = Math.IEEEremainder(λ - ZONER.origin, ZONER.width);
   // Distance to closest zone change, in degrees of longitude.
+                            final double cv = (position.x - ZONER.easting) / (λ - λ0);
             // Approximative conversion factor from degrees to metres.
+                            isValid = (Math.abs(rλ) * cv <= sx);                    
               // Be tolerant if distance in metres is less than resolution.
+                            if (isValid) {
+                                isValid = (zoneError == (rλ < 0 ? -1 : +1));        
               // Verify also that the error is on the side of the zone change.
+                            }
+                        }
                     }
-                    isValid = Math.abs(actual - zone) <= threshold;
                 }
                 if (!isValid) {
                     position.x += sx/2;



Mime
View raw message