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

Sandro Mani manisandro at gmail.com
Tue Jul 4 08:51:09 PDT 2017


Hi Even

Thanks for the reply. Yes I am indeed testing with shapefiles.

Not sure why I never observed this behaviour previously, but indeed I 
have up to now never observed this myself, nor have received bug reports 
concerned with this kind breakage - and this is a pretty hard to miss 
issue since the plugin will essentially behave randomly.

In any event, so I suppose other than manually introducing a UUID 
attribute to the features and identifying them by a attribute filter 
expression, there is no way to reliably identify a feature over the 
lifetime of the layer being loaded in QGIS?

I'm kinda inclined to think that I'm not the only one relying on feature 
ids to identify features?

Sandro

On 04.07.2017 17:36, Even Rouault wrote:
>
> 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/8705b0bb/attachment-0001.html>


More information about the QGIS-Developer mailing list