From fe09b81712a1c7ffeaf57725ae51395602f4ded3 Mon Sep 17 00:00:00 2001 From: TIM ANDERSON Date: Wed, 18 Nov 2026 13:07:21 +1000 Subject: [PATCH] Reject zone zero when converting UTM grid coordinates --- geodepy/convert.py | 2 +- geodepy/tests/test_convert.py | 12 +++++++----- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/geodepy/convert.py b/geodepy/convert.py index 30ffd63..523bc34 100644 --- a/geodepy/convert.py +++ b/geodepy/convert.py @@ -485,7 +485,7 @@ def grid2geo(zone, east, north, hemisphere="south", ellipsoid=grs80, prj=utm): "Invalid Zone - Choose from 541, 542, 543, 551, 552, 553, 561, 562, 563, 572" ) else: - if zone < 0 or zone > 60: + if zone < 1 or zone > 60: raise ValueError("Invalid Zone - Zones from 1 to 60") if east < -2830000 or east > 3830000: diff --git a/geodepy/tests/test_convert.py b/geodepy/tests/test_convert.py index 3455728..fc1559f 100644 --- a/geodepy/tests/test_convert.py +++ b/geodepy/tests/test_convert.py @@ -297,18 +297,20 @@ def test_grid2geo(self): # Test Input Validation with self.assertRaises(ValueError): grid2geo(-1, 0, 500000) + with self.assertRaises(ValueError): + grid2geo(0, 500000, 0, "North") with self.assertRaises(ValueError): grid2geo(61, 0, 500000) with self.assertRaises(ValueError): - grid2geo(0, -2830001, 500000) + grid2geo(1, -2830001, 500000) with self.assertRaises(ValueError): - grid2geo(0, 3830001, 500000) + grid2geo(1, 3830001, 500000) with self.assertRaises(ValueError): - grid2geo(0, 0, -1) + grid2geo(1, 0, -1) with self.assertRaises(ValueError): - grid2geo(0, 0, 10000001) + grid2geo(1, 0, 10000001) with self.assertRaises(ValueError): - grid2geo(0, 0, 500000, "fail") + grid2geo(1, 0, 500000, "fail") # test ValueError raised if not a valid ISG zone with self.assertRaises(ValueError): grid2geo(zone=530, east=300000, north=1500000, ellipsoid=ans, prj=isg)