[gdal-dev] Creating a vector mbtile with several layers

DELEPINE Christophe christophe.delepine at thalesgroup.com
Fri Jul 1 03:16:03 PDT 2022


I also tried the MVT driver and got the same problem : the output metadata.json only lists one layer.
Should I create all layers first before adding features to them ?

The C++ API documentation does not explain how to write several layers in the case of a MBTILES/MVT dataset


De : DELEPINE Christophe
Envoyé : jeudi 30 juin 2022 17:17
À : 'gdal-dev at lists.osgeo.org' <gdal-dev at lists.osgeo.org>
Objet : Creating a vector mbtile with several layers

Hello

I am trying to create a vector mbtile containing several layers (using C++ GDAL API) but it does not work. My output mbtile only contains one layer (ogrinfo only lists one layer)
What I do is the following :

GDALDriver* driver = (GDALDriver*)GDALGetDriverByName("MBTiles");
GDALDataset* poDS = driver->Create(mbtiles.c_str(), 0, 0, 0, GDT_Unknown, datasetCreationOptions);
for (auto& layer : layers)
{
       OGRLayer* oLayer = poDS->CreateLayer(layer.name_.c_str(), &srs3857_, wkbUnknown);
OGRFeature *oFeature = OGRFeature::CreateFeature(oLayer->GetLayerDefn());
oFeature->SetGeometryDirectly(geom);
oLayer->CreateFeature(oFeature);
}
GDALClose(poDS);


Any idea what is wrong ?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/gdal-dev/attachments/20220701/432a3fe1/attachment.htm>


More information about the gdal-dev mailing list