Skip to content

Commit b010535

Browse files
committed
MBTiles: Add ELEVATION_TYPE creation option
1 parent 12582d4 commit b010535

2 files changed

Lines changed: 24 additions & 0 deletions

File tree

doc/source/drivers/raster/mbtiles.rst

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -338,6 +338,14 @@ The following creation options are available:
338338

339339
Whether to write the bounds 'metadata' item.
340340

341+
- .. oo:: ELEVATION_TYPE
342+
:choices: '', 'terrain-rgb'
343+
:default: ''
344+
345+
Type of elevation encoding, suitable for direct generation of
346+
Mapbox Terrain-RGB tilesets. See `Mapbox Terrain-RGB v1
347+
<https://docs.mapbox.com/data/tilesets/reference/mapbox-terrain-rgb-v1/>`__
348+
341349
- Vector only:
342350

343351
- .. co:: MINZOOM

frmts/mbtiles/mbtilesdataset.cpp

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3063,6 +3063,17 @@ bool MBTilesDataset::CreateInternal(const char *pszFilename, int nXSize,
30633063
sqlite3_exec(hDB, pszSQL, nullptr, nullptr, nullptr);
30643064
sqlite3_free(pszSQL);
30653065

3066+
const std::string osElevationType =
3067+
CSLFetchNameValueDef(papszOptions, "ELEVATION_TYPE", "");
3068+
if (!osElevationType.empty())
3069+
{
3070+
pszSQL = sqlite3_mprintf("INSERT INTO metadata (name, value) VALUES "
3071+
"('elevation_type', '%q')",
3072+
osElevationType.c_str());
3073+
sqlite3_exec(hDB, pszSQL, nullptr, nullptr, nullptr);
3074+
sqlite3_free(pszSQL);
3075+
}
3076+
30663077
const char *pszTF = CSLFetchNameValue(papszOptions, "TILE_FORMAT");
30673078
if (pszTF)
30683079
m_eTF = GDALGPKGMBTilesGetTileFormat(pszTF);
@@ -3754,6 +3765,11 @@ void GDALRegister_MBTiles()
37543765
" <Value>overlay</Value>"
37553766
" <Value>baselayer</Value>"
37563767
" </Option>"
3768+
" <Option name='ELEVATION_TYPE' scope='raster' type='string-select' "
3769+
"description='Type of elevation encoding' default=''>"
3770+
" <Value></Value>"
3771+
" <Value>terrain-rgb</Value>"
3772+
" </Option>"
37573773
" <Option name='VERSION' scope='raster' type='string' "
37583774
"description='The version of the tileset, as a plain number' "
37593775
"default='1.1'/>"

0 commit comments

Comments
 (0)