sis-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From desruisse...@apache.org
Subject svn commit: r1785089 - in /sis/branches/JDK8/core: sis-referencing-by-identifiers/src/main/java/org/apache/sis/referencing/gazetteer/ sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/
Date Thu, 02 Mar 2017 09:00:24 GMT
Author: desruisseaux
Date: Thu Mar  2 09:00:23 2017
New Revision: 1785089

URL: http://svn.apache.org/viewvc?rev=1785089&view=rev
Log:
Move the check for special cases into a Zoner.isSpecialCase(…) method.

Modified:
    sis/branches/JDK8/core/sis-referencing-by-identifiers/src/main/java/org/apache/sis/referencing/gazetteer/MilitaryGridReferenceSystem.java
    sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/TransverseMercator.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=1785089&r1=1785088&r2=1785089&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] Thu Mar  2 09:00:23 2017
@@ -1166,7 +1166,7 @@ parse:                  switch (part) {
                         if (zoneError != 0) {
                             final int zc = ZONER.zoneCount();
                             if (zoneError > zc/2) zoneError -= zc;
-                            if (Math.abs(φ) >= TransverseMercator.Zoner.NORWAY_BOUNDS)
{
+                            if (ZONER.isSpecialCase(zone, φ)) {
                                 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.

Modified: sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/TransverseMercator.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/TransverseMercator.java?rev=1785089&r1=1785088&r2=1785089&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/TransverseMercator.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/TransverseMercator.java
[UTF-8] Thu Mar  2 09:00:23 2017
@@ -155,6 +155,7 @@ public final class TransverseMercator ex
          * </table></blockquote>
          */
         UTM(Longitude.MIN_VALUE, 6, 0.9996, 500000, 10000000) {
+            /** Computes the zone from a meridian in the zone. */
             @Override public int zone(final double φ, final double λ) {
                 int zone = super.zone(φ, λ);
                 switch (zone) {
@@ -171,6 +172,14 @@ public final class TransverseMercator ex
                 }
                 return zone;
             }
+
+            /** Indicates whether the given zone needs to be handled in a special way for
the given latitude. */
+            @Override public boolean isSpecialCase(final int zone, final double φ) {
+                if (zone >= 31 && zone <= 37) {
+                    return isSvalbard(φ) || (zone <= 32 && isNorway(φ));
+                }
+                return false;
+            }
         },
 
         /**
@@ -352,19 +361,30 @@ public final class TransverseMercator ex
         }
 
         /**
+         * Indicates whether the given zone needs to be handled in a special way for the
given latitude.
+         *
+         * @param  zone  the zone to test if it is a special case.
+         * @param  φ     the latitude for which to test if there is a special case.
+         * @return whether the given zone at the given latitude is a special case.
+         */
+        public boolean isSpecialCase(final int zone, final double φ) {
+            return false;
+        }
+
+        /**
          * First exception in UTM projection, corresponding to latitude band V.
-         * This method is public for {@code MGRSEncoderTest.verifyZonerConsistency()} purpose
only.
+         * This method is public for {@code MilitaryGridReferenceSystemTest.verifyZonerConsistency()}
purpose only.
          *
          * @param  φ  the latitude in degrees to test.
          * @return whether the given latitude is in the Norway latitude band.
          */
         public static boolean isNorway(final double φ) {
-            return (φ >= NORWAY_BOUNDS) && (φ < 64);
+            return (φ >= 56) && (φ < 64);
         }
 
         /**
          * Second exception in UTM projection, corresponding to latitude band X.
-         * This method is public for {@code MGRSEncoderTest.verifyZonerConsistency()} purpose
only.
+         * This method is public for {@code MilitaryGridReferenceSystemTest.verifyZonerConsistency()}
purpose only.
          *
          * @param  φ  the latitude in degrees to test.
          * @return whether the given latitude is in the Svalbard latitude band.
@@ -381,16 +401,6 @@ public final class TransverseMercator ex
         public static final double SOUTH_BOUNDS = -80;
 
         /**
-         * Northernmost bounds (exclusive) of the latitudes that do not require special case.
-         * Coordinates at latitudes equal or greater than this value may be subject to special
-         * rules regarding their UTM zones.
-         *
-         * @see #isNorway(double)
-         * @see #isSvalbard(double)
-         */
-        public static final double NORWAY_BOUNDS = 56;
-
-        /**
          * Southernmost bounds (inclusive) of the last latitude band, which contains Svalbard.
          * This latitude band is 12° height instead of 8°.
          */



Mime
View raw message