Skip to content

Commit

Permalink
Merge pull request #3052 from tbonfort/default-ovr-blocksize-test
Browse files Browse the repository at this point in the history
add test for default tiff ovrview blocksize (#1611)
  • Loading branch information
rouault authored Oct 13, 2020
2 parents 20d44a1 + 3fc73a7 commit f5e5738
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions autotest/gcore/tiff_write.py
Original file line number Diff line number Diff line change
Expand Up @@ -7388,6 +7388,40 @@ def test_tiff_write_internal_ovr_blocksize(blockSize, numThreads):
ds = None
gdaltest.tiff_drv.Delete(fname)

###############################################################################
# Test blocksize propagation while creating (internal) overviews
# on a newly created dataset

@pytest.mark.parametrize("blockSize,numThreads", [[64, None], [256, 8]])
def test_tiff_write_internal_ovr_default_blocksize(blockSize, numThreads):

src_ds = gdal.Open('../gdrivers/data/utm.tif')
fname = 'tmp/tiff_write_internal_ovr_default_bs%d.tif' % blockSize

ds = gdal.GetDriverByName('GTiff').Create(fname, 1024, 1024, 1,
options=['TILED=YES','COMPRESS=LZW',
'BLOCKXSIZE=%d'%blockSize,
'BLOCKYSIZE=%d'%blockSize])

data = src_ds.GetRasterBand(1).ReadRaster(0, 0, 512, 512, 1024, 1024)
ds.GetRasterBand(1).WriteRaster(0, 0, 1024, 1024, data)
opts = {}
if numThreads:
opts['GDAL_NUM_THREADS'] = str(numThreads)
with gdaltest.config_options(opts):
ds.BuildOverviews('AVERAGE', overviewlist=[2])

src_ds = None
ds = None

ds = gdal.Open(fname)
(bsx,bsy) = ds.GetRasterBand(1).GetOverview(0).GetBlockSize()
assert bsx == blockSize
assert bsy == blockSize
ds = None
gdaltest.tiff_drv.Delete(fname)



def test_tiff_write_cleanup():
gdaltest.tiff_drv = None

0 comments on commit f5e5738

Please sign in to comment.