def test_search_tiles_spitzbergen(self):
        """
        Tests the tile searching over Spitzbergen in the polar zone; ROI #defined
        by a 4-corner polygon over high latitudes (is much curved on the globe).
        """
        # TODO: STILL NEEDS TO BE CAREFULLY CHECKED! Also need to be
        # adapted for coverland!

        grid = UTMGrid(500)

        spitzbergen_geom = setup_test_geom_spitzbergen()
        spitzbergen_geom_tiles = sorted([
            'Z31N500M_E006N084T6', 'Z33N500M_E000N084T6',
            'Z33N500M_E000N090T6', 'Z33N500M_E006N084T6',
            'Z33N500M_E006N090T6', 'Z35N500M_E000N078T6',
            'Z35N500M_E000N084T6', 'Z35N500M_E000N090T6',
            'Z35N500M_E006N084T6', 'Z37N500M_E000N084T6'
        ])
        tiles = sorted(
            grid.search_tiles_in_roi(spitzbergen_geom, coverland=False))
        assert sorted(tiles) == sorted(spitzbergen_geom_tiles)

        spitzbergen_geom_tiles = sorted([
            'Z31N500M_E006N084T6', 'Z33N500M_E000N084T6',
            'Z33N500M_E000N090T6', 'Z33N500M_E006N084T6',
            'Z33N500M_E006N090T6', 'Z35N500M_E000N078T6',
            'Z35N500M_E000N084T6', 'Z35N500M_E000N090T6',
            'Z35N500M_E006N084T6', 'Z37N500M_E000N084T6'
        ])
        tiles = sorted(
            grid.search_tiles_in_roi(spitzbergen_geom, coverland=True))
        assert sorted(tiles) == sorted(spitzbergen_geom_tiles)
    def test_search_tiles_lon_lat_extent(self):
        """
        Tests searching for tiles with input of lon lat extent
        """
        # TODO: STILL NEEDS TO BE CAREFULLY CHECKED! OVER THE ARCTICS! Also need to be
        # adapted for coverland!
        # two tiles are different between GDAL3 and GDAL2!

        utm = UTMGrid(500)

        tiles = utm.search_tiles_in_roi(bbox=[(-10, 80), (5, 85)],
                                        coverland=True)

        desired_tiles = [
            'Z31N500M_E000N084T6', 'Z31N500M_E000N090T6',
            'Z00Y500M_E018N012T6', 'Z00Z500M_E018N012T6',
            'Z29N500M_E000N084T6', 'Z29N500M_E000N090T6',
            'Z30N500M_E000N084T6', 'Z30N500M_E000N090T6'
        ]
        assert sorted(tiles) == sorted(desired_tiles)

        tiles_all = utm.search_tiles_in_roi(bbox=[(-179.9, -89.9),
                                                  (179.9, 89.9)],
                                            coverland=True)

        assert len(tiles_all) == 3638
    def test_search_tiles_lon_lat_extent_by_points(self):
        """
        Tests searching for tiles with input of lon lat points
        """
        # TODO: STILL NEEDS TO BE CAREFULLY CHECKED! Also need to be
        # adapted for coverland!

        utm = UTMGrid(500)

        tiles = utm.search_tiles_in_roi(points=[(10, 40), (5, 50),
                                                (-90.9, -1.2), (-175.2, 66)],
                                        coverland=True)

        desired_tiles = [
            'Z31N500M_E006N054T6', 'Z01N500M_E000N072T6',
            'Z32N500M_E000N042T6', 'Z15S500M_E006N096T6'
        ]
        assert sorted(tiles) == sorted(desired_tiles)
    def test_search_tiles_kamchatka(self):
        """
        Tests the tile searching over Kamchatka in far east Sibiria;

        This test is especially nice, as it contains also a tile that covers both,
        the ROI and the continental zone, but the intersection of the tile and
        the ROI is outside of the zone.

        Furthermore, it also covers zones that consist of a multipolygon, as it
        is located at the 180deg/dateline.
        """

        grid = UTMGrid(500)

        kamchatka_geom = setup_geom_kamchatka()
        kamchatka_geom_tiles = sorted([
            'Z58N500M_E000N060T6', 'Z58N500M_E006N060T6',
            'Z59N500M_E000N060T6', 'Z59N500M_E006N060T6',
            'Z60N500M_E000N060T6', 'Z60N500M_E006N060T6'
        ])
        tiles = sorted(
            grid.search_tiles_in_roi(kamchatka_geom, coverland=False))

        assert sorted(tiles) == sorted(kamchatka_geom_tiles)