Esempio n. 1
0
def test_utils_py_1():
    """ test get_ovr_idx, create_flat_raster """
    filename = 'tmp/raster.tif'
    temp_files.append(filename)
    raster_creation.create_flat_raster(filename, overview_list=[2, 4])
    ds = util.open_ds(filename)
    compression = util.get_image_structure_metadata(filename, 'COMPRESSION')
    assert compression == 'DEFLATE'
    ovr_count = util.get_ovr_count(ds) + 1
    assert ovr_count == 3
    pixel_size = util.get_pixel_size(ds)
    assert pixel_size == (10, -10)

    for i in range(-ovr_count, ovr_count):
        assert util.get_ovr_idx(filename,
                                ovr_idx=i) == (i if i >= 0 else ovr_count + i)

    for res, ovr in [(5, 0), (10, 0), (11, 0), (19.99, 0), (20, 1), (20.1, 1),
                     (39, 1), (40, 2), (41, 2), (400, 2)]:
        assert util.get_ovr_idx(filename, ovr_res=res) == ovr
        assert util.get_ovr_idx(filename,
                                float(res)) == ovr  # noqa secret functionality

    # test open_ds with multiple different inputs
    filename2 = 'tmp/raster2.tif'
    temp_files.append(filename2)
    raster_creation.create_flat_raster(filename2)
    ds_list = util.open_ds([ds, filename2])
    assert tuple(util.get_ovr_count(ds) for ds in ds_list) == (2, 0)
    ds_list = None
Esempio n. 2
0
def test_utils_py_1():
    """ test get_ovr_idx, create_flat_raster """
    filename = 'tmp/raster.tif'
    temp_files.append(filename)
    raster_creation.create_flat_raster(filename, overview_list=[2, 4])
    ds = util.open_ds(filename)
    compression = util.get_image_structure_metadata(filename, 'COMPRESSION')
    assert compression == 'DEFLATE'
    ras_count = util.get_ovr_count(ds) + 1
    assert ras_count == 3
    pixel_size = util.get_pixel_size(ds)
    assert pixel_size == (10, -10)

    for i in range(-ras_count, ras_count):
        assert util.get_ovr_idx(filename,
                                ovr_idx=i) == (i if i >= 0 else ras_count + i)

    for res, ovr in [(5, 0), (10, 0), (11, 0), (19.99, 0), (20, 1), (20.1, 1),
                     (39, 1), (40, 2), (41, 2), (400, 2)]:
        assert util.get_ovr_idx(filename, ovr_res=res) == ovr
        assert util.get_ovr_idx(
            filename, ovr_idx=float(res)) == ovr  # noqa secret functionality