예제 #1
0
async def test_cog_get_overview_level(create_cog_reader, width, height):
    async with create_cog_reader(TEST_DATA[0]) as cog:
        ovr = cog._get_overview_level(cog.bounds, width, height)

        with rasterio.open(TEST_DATA[0]) as src:
            expected_ovr = rio_tiler_utils.get_overview_level(
                src, src.bounds, height, width)
            # Our index for source data is 0 while rio tiler uses -1
            expected_ovr = 0 if expected_ovr == -1 else expected_ovr
            assert ovr == expected_ovr
예제 #2
0
def test_ovr_level():
    """Should return the correct overview level."""
    with rasterio.open(COG_DST) as src_dst:
        # raw/-1: 2667x2658 0: 1329x1334, 1: 665x667, 2: 333x334, 3: 167x167
        assert (utils.get_overview_level(src_dst,
                                         src_dst.bounds,
                                         100,
                                         100,
                                         dst_crs=src_dst.crs) == 3)
        assert (utils.get_overview_level(src_dst,
                                         src_dst.bounds,
                                         200,
                                         200,
                                         dst_crs=src_dst.crs) == 2)
        assert (utils.get_overview_level(src_dst,
                                         src_dst.bounds,
                                         500,
                                         500,
                                         dst_crs=src_dst.crs) == 1)
        assert (utils.get_overview_level(src_dst,
                                         src_dst.bounds,
                                         800,
                                         800,
                                         dst_crs=src_dst.crs) == 0)
        assert (utils.get_overview_level(src_dst,
                                         src_dst.bounds,
                                         1500,
                                         1500,
                                         dst_crs=src_dst.crs) == -1)
        assert (utils.get_overview_level(src_dst,
                                         src_dst.bounds,
                                         3000,
                                         3000,
                                         dst_crs=src_dst.crs) == -1)