How to use the timezonefinder.global_settings.INT2COORD_FACTOR function in timezonefinder

To help you get started, we’ve selected a few timezonefinder examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github MrMinimal64 / timezonefinder / test / test_helpers.py View on Github external
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)),
        ]
github MrMinimal64 / timezonefinder / test / test_it.py View on Github external
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)
github MrMinimal64 / timezonefinder / timezonefinder / helpers_numba.py View on Github external
def int2coord(i4):
    return float(i4 * INT2COORD_FACTOR)
github MrMinimal64 / timezonefinder / timezonefinder / helpers.py View on Github external
def int2coord(i4):
    return float(i4 * INT2COORD_FACTOR)
github MrMinimal64 / timezonefinder / timezonefinder / helpers_numba.py View on Github external
def int2coord(i4):
    return float(i4 * INT2COORD_FACTOR)