rio-pmtiles improvements to defaults (#545)

* rio-pmtiles: show progress by default

* change --progress-bar to --silent [#338]

* rio-pmtiles: change defaults from JPEG/256/nearest to WEBP/512/bilinear [#338]

* rename title to name [#338]

* rio-pmtiles: automatic guessing of maxzoom [#338]

* determine maxzoom based on image dimensions and tile_size.

* rio-pmtiles: 1.0.0
This commit is contained in:
Brandon Liu
2025-04-02 12:21:01 +08:00
committed by GitHub
parent 29de7d2521
commit c793dc6435
3 changed files with 46 additions and 29 deletions

View File

@@ -11,6 +11,7 @@ from rasterio.rio.main import main_group
from pmtiles.reader import Reader, MmapSource, all_tiles
import rio_pmtiles.scripts.cli
from rio_pmtiles.scripts.cli import guess_maxzoom
from conftest import mock
@@ -72,7 +73,7 @@ def test_export_tiles(tmpdir, data):
with open(outputfile, 'rb') as f:
src = MmapSource(f)
assert len(list(all_tiles(src))) == 6
assert len(list(all_tiles(src))) == 19
def test_export_zoom(tmpdir, data):
inputfile = str(data.join("RGB.byte.tif"))
@@ -96,7 +97,7 @@ def test_export_jobs(tmpdir, data):
with open(outputfile, 'rb') as f:
src = MmapSource(f)
assert len(list(all_tiles(src))) == 6
assert len(list(all_tiles(src))) == 19
def test_export_src_nodata(tmpdir, data):
@@ -111,7 +112,7 @@ def test_export_src_nodata(tmpdir, data):
with open(outputfile, 'rb') as f:
src = MmapSource(f)
assert len(list(all_tiles(src))) == 6
assert len(list(all_tiles(src))) == 19
def test_export_bilinear(tmpdir, data):
@@ -125,7 +126,7 @@ def test_export_bilinear(tmpdir, data):
with open(outputfile, 'rb') as f:
src = MmapSource(f)
assert len(list(all_tiles(src))) == 6
assert len(list(all_tiles(src))) == 19
def test_skip_empty(tmpdir, empty_data):
@@ -153,7 +154,7 @@ def test_include_empty(tmpdir, empty_data):
with open(outputfile, 'rb') as f:
src = MmapSource(f)
assert len(list(all_tiles(src))) == 6
assert len(list(all_tiles(src))) == 19
def test_invalid_format_rgba(tmpdir, empty_data):
@@ -217,7 +218,6 @@ def test_progress_bar(tmpdir, data, filename):
main_group,
[
"pmtiles",
"-#",
"--zoom-levels",
"4..11",
"--rgba",
@@ -249,7 +249,6 @@ def test_cutline_progress_bar(tmpdir, data, rgba_cutline_path, filename):
main_group,
[
"pmtiles",
"-#",
"--zoom-levels",
"4..11",
"--rgba",
@@ -275,7 +274,6 @@ def test_invalid_cutline(tmpdir, data, rgba_points_path, filename):
main_group,
[
"pmtiles",
"-#",
"--zoom-levels",
"4..11",
"--rgba",
@@ -288,3 +286,14 @@ def test_invalid_cutline(tmpdir, data, rgba_points_path, filename):
],
)
assert result.exit_code == 1
@pytest.mark.parametrize(
"crs,bounds,width,height,tile_size,maxzoom",
[
("EPSG:4326",[-180,-90,180,90],256,256,256,0),
("EPSG:4326",[-180,-90,180,90],512,512,256,1),
("EPSG:4326",[-180,-90,180.00000000007202,90],512,1,256,1),
],
)
def test_guess_maxzoom(crs, bounds, width, height, tile_size, maxzoom):
assert guess_maxzoom(crs, bounds, width, height, tile_size) == maxzoom