Repository: Turbo87/utm

Issue:
UTM zone exceptions error
By definition zones are left-closed, right-open intervals, e.g. zone 31: 0 <= latitude < 6.
In function latlon_to_zone_number:

```
if 72 <= latitude <= 84 and longitude >= 0:
    if longitude <= 9:
        return 31
    elif longitude <= 21:
        return 33
    elif longitude <= 33:
        return 35
    elif longitude <= 42:
        return 37
```

For latitudes >=72, this results in:
zone 31: 0  <= longitude <= 9
zone 33: 9  <   longitude <= 21
zone 35: 21<   longitude <= 33
zone 37: 33<   longitude <= 42

but for latitudes < 72:
zone 37: 36 <= latitude < 42


Discussion:

Patch:
diff --git a/utm/conversion.py b/utm/conversion.py
old mode 100755
new mode 100644
index d21742a..449f3d1
--- a/utm/conversion.py
+++ b/utm/conversion.py
@@ -216,13 +216,13 @@ def latlon_to_zone_number(latitude, longitude):
         return 32
 
     if 72 <= latitude <= 84 and longitude >= 0:
-        if longitude <= 9:
+        if longitude < 9:
             return 31
-        elif longitude <= 21:
+        elif longitude < 21:
             return 33
-        elif longitude <= 33:
+        elif longitude < 33:
             return 35
-        elif longitude <= 42:
+        elif longitude < 42:
             return 37
 
     return int((longitude + 180) / 6) + 1


Test patch:
diff --git a/test/test_utm.py b/test/test_utm.py
index 55686d7..c820cea 100755
--- a/test/test_utm.py
+++ b/test/test_utm.py
@@ -231,5 +231,22 @@ class Zone32V(unittest.TestCase):
         self.assert_zone_equal(UTM.from_latlon(64, 12), 33, 'W')
 
 
+class TestRightBoundaries(unittest.TestCase):
+
+    def assert_zone_equal(self, result, expected_number):
+        self.assertEqual(result[2], expected_number)
+
+    def test_limits(self):
+        self.assert_zone_equal(UTM.from_latlon(40, 0), 31)
+        self.assert_zone_equal(UTM.from_latlon(40, 5.999999), 31)
+        self.assert_zone_equal(UTM.from_latlon(40, 6), 32)
+
+        self.assert_zone_equal(UTM.from_latlon(72, 0), 31)
+        self.assert_zone_equal(UTM.from_latlon(72, 5.999999), 31)
+        self.assert_zone_equal(UTM.from_latlon(72, 6), 31)
+        self.assert_zone_equal(UTM.from_latlon(72, 8.999999), 31)
+        self.assert_zone_equal(UTM.from_latlon(72, 9), 33)
+
+
 if __name__ == '__main__':
     unittest.main()