[QGIS-Developer] QGIS/OGR: FeatureIds reassigned on write to data provider?

Even Rouault even.rouault at spatialys.com
Tue Jul 4 08:36:51 PDT 2017


Sandro,

I guess this might depend on the actual OGR driver used. Somehow I assume you use shapefiles here ?

This is probably linked to shapefiles being repacked after the end of various operations 
such as addFeatures(), changeGeometryValues(), deleteFeatures(), so as to avoid issues
with other software that don't like holes in SHP and DBF files.

There have been changes in that area to rebustify shapefile recompaction that used
to work not so well on Windows (although most of them were in OGR itself),
but my understanding of 
https://github.com/qgis/QGIS/blob/release-2_12/src/providers/ogr/qgsogrprovider.cpp
is that even in 2.12, feature deletion should cause a repack of the shapefile, so
I'm not sure why the issue would be new

Even

> Hi
> 
> I'm doing work on the geometry checker in QGIS master and noticed that,
> when deleting features from an ogr vector layer, FeatureIds appear to be
> reassigned to fill up the gap in the ids. This is a pretty serious
> blocker for the geometry checker since geometry checker errors are
> identified by the feature id (and other parameters). So if the
> FeatureIds change, the geometry checker errors may suddenly reference
> the wrong feature, causing general mayhem.
> 
> Can anyone confirm that indeed FeatureIds are being purposefully
> reassigned, and whether there is a rationale behind this change (I never
> observed this before in QGIS 2.x)? And if so, what other options exist
> to reliably reference a feature over the entire lifetime of the layer
> being loaded in QGIS?
> 
> Note that in the geometry checker, I don't use the edit buffer, but
> write each change directly to the data provider. This to avoid that
> situations where, after fixing multiple errors, the final result cannot
> be committed due to a particular geometry still being invalid and the
> provider refusing to accept the change.
> 
> Thanks
> Sandro
> 
> _______________________________________________
> QGIS-Developer mailing list
> QGIS-Developer at lists.osgeo.org
> List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer
> Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer


-- 
Spatialys - Geospatial professional services
http://www.spatialys.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/qgis-developer/attachments/20170704/f4632a36/attachment.html>


More information about the QGIS-Developer mailing list