Beispiel #1
0
    def test_coord2shortcut(self):

        coord2shortcut = self.fct_dict['coord2shortcut']
        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)),
        ]

        proto_test_case(data, coord2shortcut_test_fct)
    def test_coord2shortcut(self):

        coord2shortcut = self.fct_dict['coord2shortcut']
        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)),
        ]

        proto_test_case(data, coord2shortcut_test_fct)