<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
</head>
<body>
<p>Linda,</p>
<p>the FID returned by the MVT driver, when opening on a directory,
is a composition of the (X,Y,Z) of the tile and the feature id
within it.</p>
<p>The id part of the tile is
<a class="moz-txt-link-freetext" href="https://github.com/OSGeo/gdal/blob/master/ogr/ogrsf_frmts/mvt/ogrmvtdataset.cpp#L1672">https://github.com/OSGeo/gdal/blob/master/ogr/ogrsf_frmts/mvt/ogrmvtdataset.cpp#L1672</a>
:</p>
<p> m_nFIDBase = (static_cast<GIntBig>(nX) << m_nZ) |
nY;</p>
<p>and then the feature ID is computed at
<a class="moz-txt-link-freetext" href="https://github.com/OSGeo/gdal/blob/master/ogr/ogrsf_frmts/mvt/ogrmvtdataset.cpp#L1873">https://github.com/OSGeo/gdal/blob/master/ogr/ogrsf_frmts/mvt/ogrmvtdataset.cpp#L1873</a>:</p>
<p> poFeature->SetFID(m_nFIDBase +<br>
(poUnderlyingFeature->GetFID()
<< (2 * m_nZ)));</p>
<p>so the ID in the tile is</p>
<p>(GetFID() - m_nFIDBase) >> (2 * m_nZ)</p>
<p>But I'm realizing that the (X,Y,Z) of the tile when reading the
directory are not accessible</p>
<p>Maybe you best chance is to slightly modify the driver so it
creates a field with that information</p>
<p>Even</p>
<p><br>
</p>
<div class="moz-cite-prefix">Le 23/11/2025 à 13:01, Linda Kladivová
via gdal-dev a écrit :<br>
</div>
<blockquote type="cite"
cite="mid:6oI.IlON.odzi0Q7Vfj.1f8lUH@seznam.cz">
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<p>Hi,</p>
<p><br>
</p>
<p>I’d like to ask about one specific aspect of the MVT driver. In
my workflow, I need to track the FIDs of features inside an MVT
dataset together with their corresponding internal codes (actual
parcel IDs).</p>
<p><br>
</p>
<p>My use case involves an MVT dataset of about 20 million
features that is frequently updated. For this purpose, I have
implemented an extension of the MVT driver that can open an MVT
dataset in update mode and create/delete features based on
changes detected by a preceding ETL process. Updates typically
affect only a few individual features every hour.</p>
<p><br>
</p>
<p>After the initial loading of the full dataset using <code>ogr2ogr</code>
I need a way to iterate through the dataset and build a separate
table mapping each internal FID to the parcel’s real ID. I have
tried opening and inspecting the <code>temp.db</code> file
(which I do not delete):</p>
<p><br>
</p>
<p>GDALDataset* poTempDb =<br>
(GDALDataset*) GDALOpenEx(dstTempDb.c_str(),<br>
GDAL_OF_VECTOR, nullptr, nullptr,
nullptr);<br>
<br>
OGRLayer* poTempLayer = poTempDb->GetLayerByName("temp");<br>
poTempLayer->ResetReading();<br>
<br>
OGRFeature* poFeat = nullptr;<br>
<br>
while ((poFeat = poTempLayer->GetNextFeature()) != nullptr)<br>
{<br>
GIntBig fid = poFeat->GetFID();<br>
<a class="moz-txt-link-freetext" href="std::cout">std::cout</a> << "FID=" << fid << " — ";<br>
int idx = poFeat->GetFieldIndex("feature");<br>
int blobSize = 0;<br>
const GByte* pBlob = poFeat->GetFieldAsBinary(idx,
&blobSize);<br>
<a class="moz-txt-link-freetext" href="std::cout">std::cout</a> << " Blob size=" << blobSize <<
<a class="moz-txt-link-freetext" href="std::endl">std::endl</a>;<br>
}<br>
<br>
</p>
<p>I can successfully access the <code>feature</code> blob, but I
need to decode it in order to extract my custom parcel ID
attribute and store those values externally. This would allow me
to keep track of which parcel corresponds to which internal FID.</p>
<p><br>
This is a one-time (potentially slow) process. Afterward, during
incremental updates, I will be calling <code>CreateFeature</code>
and <code>DeleteFeature</code> (and updating my external
mapping table accordingly). For edits, I currently use a
combination of <code>DeleteFeature</code> and <code>CreateFeature</code>
(I haven’t implemented <code>SetFeature</code> yet).</p>
<p><br>
</p>
<p>My question is:<br>
<span>Is there a way to decode this blob using existing GDAL/MVT
functionality, or would this require implementing a new
function?</span></p>
<p>Thank you very much for your help.</p>
<p><br>
</p>
<p>Linda Karlovská</p>
<br>
<fieldset class="moz-mime-attachment-header"></fieldset>
<pre wrap="" class="moz-quote-pre">_______________________________________________
gdal-dev mailing list
<a class="moz-txt-link-abbreviated" href="mailto:gdal-dev@lists.osgeo.org">gdal-dev@lists.osgeo.org</a>
<a class="moz-txt-link-freetext" href="https://lists.osgeo.org/mailman/listinfo/gdal-dev">https://lists.osgeo.org/mailman/listinfo/gdal-dev</a>
</pre>
</blockquote>
<pre class="moz-signature" cols="72">--
<a class="moz-txt-link-freetext" href="http://www.spatialys.com">http://www.spatialys.com</a>
My software is free, but my time generally not.</pre>
</body>
</html>