You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sis.apache.org by de...@apache.org on 2017/03/02 09:00:24 UTC
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/
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(\u2026) 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(\u03c6) >= TransverseMercator.Zoner.NORWAY_BOUNDS) {
+ if (ZONER.isSpecialCase(zone, \u03c6)) {
isValid = Math.abs(zoneError) == 1; // Tolerance in zone numbers for high latitudes.
} else {
final double r\u03bb = Math.IEEEremainder(\u03bb - 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 \u03c6, final double \u03bb) {
int zone = super.zone(\u03c6, \u03bb);
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 \u03c6) {
+ if (zone >= 31 && zone <= 37) {
+ return isSvalbard(\u03c6) || (zone <= 32 && isNorway(\u03c6));
+ }
+ 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 \u03c6 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 \u03c6) {
+ 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 \u03c6 the latitude in degrees to test.
* @return whether the given latitude is in the Norway latitude band.
*/
public static boolean isNorway(final double \u03c6) {
- return (\u03c6 >= NORWAY_BOUNDS) && (\u03c6 < 64);
+ return (\u03c6 >= 56) && (\u03c6 < 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 \u03c6 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�.
*/