Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
if coord2shortcut is None:
print('test coord2shortcut skipped.')
return
def coord2shortcut_test_fct(input):
(lng, lat) = input
return coord2shortcut(lng, lat)
data = [
# shortcut numbering starts at "the top left" with x,y= 0,0
# always (only) the "top" and "left" borders belong to a shortcut
# the other borders belong to the next neighbouring shortcut
((-180.0, 90.0), (0, 0)),
# shortcuts are constant for every 1 degree lng and 0.5 degree lat
# defined with NR_SHORTCUTS_PER_LNG, NR_SHORTCUTS_PER_LAT in timezonefinder.file_converter
((-180.0 + INT2COORD_FACTOR, 90.0 - INT2COORD_FACTOR), (0, 0)),
# shortcut numbering follows the lng, lat coordinate grid
((-179.0, 90.0), (1, 0)),
((-178.9, 89.9), (1, 0)),
((-180.0, 89.5), (0, 1)),
((-179.9, 89.4), (0, 1)),
((-180.0, 89.0), (0, 2)),
((-179.9, 88.9), (0, 2)),
# shortcut numbering end at "the top left" with x,y= 359, 359
# lng= 180.0 == -180.0
# lat =-90.0 is not allowed (=bottom border of a shortcut)
((180.0 - INT2COORD_FACTOR, -90 + INT2COORD_FACTOR), (359, 359)),
((179.8, -89.8), (359, 359)),
]
def test_shortcut_boundary(self):
# at the boundaries of the shortcut grid (coordinate system) the algorithms should still be well defined!
assert self.timezone_finder.timezone_at(lng=-180.0, lat=90.0) is None
assert self.timezone_finder.timezone_at(lng=180.0, lat=90.0) is None
assert self.timezone_finder.timezone_at(lng=180.0, lat=-90.0) == 'Antarctica/McMurdo'
assert self.timezone_finder.timezone_at(lng=-180.0, lat=-90.0) == 'Antarctica/McMurdo'
with pytest.raises(ValueError):
self.timezone_finder.timezone_at(lng=180.0 + INT2COORD_FACTOR, lat=90.0)
self.timezone_finder.timezone_at(lng=-180.0 - INT2COORD_FACTOR, lat=90.0 + INT2COORD_FACTOR)
self.timezone_finder.timezone_at(lng=-180.0, lat=90.0 + INT2COORD_FACTOR)
self.timezone_finder.timezone_at(lng=180.0 + INT2COORD_FACTOR, lat=-90.0)
self.timezone_finder.timezone_at(lng=180.0, lat=-90.0 - INT2COORD_FACTOR)
self.timezone_finder.timezone_at(lng=-180.0 - INT2COORD_FACTOR, lat=-90.0)
self.timezone_finder.timezone_at(lng=-180.0 - INT2COORD_FACTOR, lat=-90.01 - INT2COORD_FACTOR)
def int2coord(i4):
return float(i4 * INT2COORD_FACTOR)
def int2coord(i4):
return float(i4 * INT2COORD_FACTOR)
def int2coord(i4):
return float(i4 * INT2COORD_FACTOR)