Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gdal2tiles: add -w mapml output, and possibilities to use custom tiling scheme / profile #2757

Merged
merged 1 commit into from
Aug 3, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
28 changes: 28 additions & 0 deletions autotest/pyscripts/test_gdal2tiles.py
Original file line number Diff line number Diff line change
Expand Up @@ -511,3 +511,31 @@ def test_gdal2tiles_py_profile_geodetic_tmscompatible_xyz():
)

shutil.rmtree('tmp/out_gdal2tiles_smallworld', ignore_errors=True)


def test_gdal2tiles_py_mapml():

script_path = test_py_scripts.get_py_script('gdal2tiles')
if script_path is None:
pytest.skip()

shutil.rmtree('tmp/out_gdal2tiles_mapml', ignore_errors=True)

gdal.Translate('tmp/byte_CBM.tif', '../gcore/data/byte.tif',
options='-a_srs EPSG:3978 -a_ullr 0 7928380 40 7928300')

test_py_scripts.run_py_script_as_external_script(
script_path,
'gdal2tiles',
'-q -p CBMTILE -w mapml -z 16-18 --url "https://foo" tmp/byte_CBM.tif tmp/out_gdal2tiles_mapml')

mapml = open('tmp/out_gdal2tiles_mapml/mapml.mapml', 'rb').read().decode('utf-8')
print(mapml)
assert '<extent units="CBMTILE">' in mapml
assert '<input name="z" type="zoom" value="18" min="16" max="18" />' in mapml
assert '<input name="x" type="location" axis="column" units="tilematrix" min="925005" max="925007" />' in mapml
assert '<input name="y" type="location" axis="row" units="tilematrix" min="837614" max="837615" />' in mapml
assert '<link tref="https://foo/out_gdal2tiles_mapml/{z}/{x}/{y}.png" rel="tile" />' in mapml

shutil.rmtree('tmp/out_gdal2tiles_mapml', ignore_errors=True)
gdal.Unlink('tmp/byte_CBM.tif')
28 changes: 28 additions & 0 deletions gdal/data/template_tiles.mapml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<mapml>
<head>
<title>states</title>
<base href="${URL}" />
<meta charset="utf-8" />
<meta content="text/mapml;projection=${TILING_SCHEME}" http-equiv="Content-Type" />
<!--
<link href="http://localhost:8080/myservice/mapml/WGS84?style=" rel="alternate" projection="WGS84" />
<link href="http://localhost:8080/myservice/mapml/OSMTILE?style=" rel="alternate" projection="OSMTILE" />
<link href="http://localhost:8080/myservice/mapml/CBMTILE?style=" rel="alternate" projection="CBMTILE" />
<link href="http://localhost:8080/myservice/mapml/APSTILE?style=" rel="alternate" projection="APSTILE" />
-->
</head>
<body>
<extent units="${TILING_SCHEME}">
<input name="z" type="zoom" value="${CURZOOM}" min="${MINZOOM}" max="${MAXZOOM}" />
<input name="x" type="location" axis="column" units="tilematrix" min="${MINTILEX}" max="${MAXTILEX}" />
<input name="y" type="location" axis="row" units="tilematrix" min="${MINTILEY}" max="${MAXTILEY}" />
<link tref="${URL}{z}/{x}/{y}.${TILEEXT}" rel="tile" />
<!--<link tref="http://localhost:8080/myservice/wmts?layer=MYLAYER&amp;style=&amp;tilematrixset=${TILING_SCHEME}&amp;service=WMTS&amp;request=GetTile&amp;version=1.0.0&amp;tilematrix={z}&amp;TileCol={x}&amp;TileRow={y}&amp;format=image/png" rel="tile" />-->
<!--
<input name="i" type="location" axis="i" units="tile" />
<input name="j" type="location" axis="j" units="tile" />
<link tref="http://localhost:8080/myservice/wmts/?LAYER=MYLAYER&amp;TILEMATRIX={z}&amp;TileCol={x}&amp;TileRow={y}&amp;TILEMATRIXSET=WGS84&amp;SERVICE=WMTS&amp;VERSION=1.0.0&amp;REQUEST=GetFeatureInfo&amp;FEATURE_COUNT=50&amp;FORMAT=image/png&amp;STYLE=&amp;INFOFORMAT=text/mapml&amp;I={i}&amp;J={j}" rel="query" />
-->
</extent>
</body>
</mapml>
268 changes: 268 additions & 0 deletions gdal/data/tms_MapML_APSTILE.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,268 @@
{
"type": "TileMatrixSetType",
"identifier": "APSTILE",
"title": "Alaska Polar Stereographic-based tiled coordinate reference system for the Arctic region.",
"supportedCRS": "http://www.opengis.net/def/crs/EPSG/0/5936",
"tileMatrix": [
{
"matrixHeight": 1,
"tileHeight": 256,
"tileWidth": 256,
"topLeftCorner": [
-28567784.109255,
32567784.109255
],
"matrixWidth": 1,
"identifier": "0",
"type": "TileMatrixType",
"scaleDenominator": 852895761.9785715
},
{
"matrixHeight": 2,
"tileHeight": 256,
"tileWidth": 256,
"topLeftCorner": [
-28567784.109255,
32567784.109255
],
"matrixWidth": 2,
"identifier": "0",
"type": "TileMatrixType",
"scaleDenominator": 426447880.98928577
},
{
"matrixHeight": 4,
"tileHeight": 256,
"tileWidth": 256,
"topLeftCorner": [
-28567784.109255,
32567784.109255
],
"matrixWidth": 4,
"identifier": "0",
"type": "TileMatrixType",
"scaleDenominator": 213223940.49464288
},
{
"matrixHeight": 8,
"tileHeight": 256,
"tileWidth": 256,
"topLeftCorner": [
-28567784.109255,
32567784.109255
],
"matrixWidth": 8,
"identifier": "0",
"type": "TileMatrixType",
"scaleDenominator": 106611970.24732144
},
{
"matrixHeight": 16,
"tileHeight": 256,
"tileWidth": 256,
"topLeftCorner": [
-28567784.109255,
32567784.109255
],
"matrixWidth": 16,
"identifier": "0",
"type": "TileMatrixType",
"scaleDenominator": 53305985.12366072
},
{
"matrixHeight": 32,
"tileHeight": 256,
"tileWidth": 256,
"topLeftCorner": [
-28567784.109255,
32567784.109255
],
"matrixWidth": 32,
"identifier": "0",
"type": "TileMatrixType",
"scaleDenominator": 26652992.56183036
},
{
"matrixHeight": 64,
"tileHeight": 256,
"tileWidth": 256,
"topLeftCorner": [
-28567784.109255,
32567784.109255
],
"matrixWidth": 64,
"identifier": "0",
"type": "TileMatrixType",
"scaleDenominator": 13326496.28091518
},
{
"matrixHeight": 128,
"tileHeight": 256,
"tileWidth": 256,
"topLeftCorner": [
-28567784.109255,
32567784.109255
],
"matrixWidth": 128,
"identifier": "0",
"type": "TileMatrixType",
"scaleDenominator": 6663248.14045759
},
{
"matrixHeight": 256,
"tileHeight": 256,
"tileWidth": 256,
"topLeftCorner": [
-28567784.109255,
32567784.109255
],
"matrixWidth": 256,
"identifier": "0",
"type": "TileMatrixType",
"scaleDenominator": 3331624.070228795
},
{
"matrixHeight": 512,
"tileHeight": 256,
"tileWidth": 256,
"topLeftCorner": [
-28567784.109255,
32567784.109255
],
"matrixWidth": 512,
"identifier": "0",
"type": "TileMatrixType",
"scaleDenominator": 1665812.0351143975
},
{
"matrixHeight": 1024,
"tileHeight": 256,
"tileWidth": 256,
"topLeftCorner": [
-28567784.109255,
32567784.109255
],
"matrixWidth": 1024,
"identifier": "0",
"type": "TileMatrixType",
"scaleDenominator": 832906.0175571988
},
{
"matrixHeight": 2048,
"tileHeight": 256,
"tileWidth": 256,
"topLeftCorner": [
-28567784.109255,
32567784.109255
],
"matrixWidth": 2048,
"identifier": "0",
"type": "TileMatrixType",
"scaleDenominator": 416453.0087785994
},
{
"matrixHeight": 4096,
"tileHeight": 256,
"tileWidth": 256,
"topLeftCorner": [
-28567784.109255,
32567784.109255
],
"matrixWidth": 4096,
"identifier": "0",
"type": "TileMatrixType",
"scaleDenominator": 208226.5043892997
},
{
"matrixHeight": 8192,
"tileHeight": 256,
"tileWidth": 256,
"topLeftCorner": [
-28567784.109255,
32567784.109255
],
"matrixWidth": 8192,
"identifier": "0",
"type": "TileMatrixType",
"scaleDenominator": 104113.25219464985
},
{
"matrixHeight": 16384,
"tileHeight": 256,
"tileWidth": 256,
"topLeftCorner": [
-28567784.109255,
32567784.109255
],
"matrixWidth": 16384,
"identifier": "0",
"type": "TileMatrixType",
"scaleDenominator": 52056.62609732492
},
{
"matrixHeight": 32768,
"tileHeight": 256,
"tileWidth": 256,
"topLeftCorner": [
-28567784.109255,
32567784.109255
],
"matrixWidth": 32768,
"identifier": "0",
"type": "TileMatrixType",
"scaleDenominator": 26028.31304866246
},
{
"matrixHeight": 65536,
"tileHeight": 256,
"tileWidth": 256,
"topLeftCorner": [
-28567784.109255,
32567784.109255
],
"matrixWidth": 65536,
"identifier": "0",
"type": "TileMatrixType",
"scaleDenominator": 13014.15652433123
},
{
"matrixHeight": 131072,
"tileHeight": 256,
"tileWidth": 256,
"topLeftCorner": [
-28567784.109255,
32567784.109255
],
"matrixWidth": 131072,
"identifier": "0",
"type": "TileMatrixType",
"scaleDenominator": 6507.078262165615
},
{
"matrixHeight": 262144,
"tileHeight": 256,
"tileWidth": 256,
"topLeftCorner": [
-28567784.109255,
32567784.109255
],
"matrixWidth": 262144,
"identifier": "0",
"type": "TileMatrixType",
"scaleDenominator": 3253.5391310828077
},
{
"matrixHeight": 524288,
"tileHeight": 256,
"tileWidth": 256,
"topLeftCorner": [
-28567784.109255,
32567784.109255
],
"matrixWidth": 524288,
"identifier": "0",
"type": "TileMatrixType",
"scaleDenominator": 1626.7695655414038
}
]
}