[QGIS-Developer] QGIS/OGR: FeatureIds reassigned on write to data provider?
Sandro Mani
manisandro at gmail.com
Wed Jul 5 05:56:09 PDT 2017
On 05.07.2017 12:18, Even Rouault wrote:
>
> On mercredi 5 juillet 2017 12:04:04 CEST Sandro Mani wrote:
>
> > On 05.07.2017 11:30, Even Rouault wrote:
>
> > > My feeling is that, for good or worse, they are definitely people
>
> > > wanting to have QGIS and "put here the name of your favorite
>
> > > proprietary GIS software" running at the same time, and possibly on
>
> > > the same datasets. This is apparently important in migration scenarios
>
> > > where people aren't ready yet to jump completely to QGIS. That said,
>
> > > this is also tricky to do in a reliable way.
>
> >
>
> > Could ogr expose oldId -> newId information which the qgsogrprovider
>
> > would then emit as a signal when the layer is repacked? I don't mean a
>
> > persistent mapping, but just for the single repack operation.
>
> That could potentially be done using the current OGR API. Basically in
> pseudo code, to execute before executing REPACK
>
> OGR_L_ResetReading(layer)
>
> char** ignored_fields = CSLAddString(NULL, "OGR_GEOMETRY" );
>
> OGR_L_SetIgnoredFields( layer, ignored_fields); // for performance.
>
> CSLDestroy(ignored_fields);
>
> OGR_L_SetAttributeFilter( layer, NULL )
>
> OGR_L_SetSpatialFilter( layer, NULL )
>
> std::map<GIntBig, GIntBig> mapOldIdToNewId;
>
> GIntBig newId = 0;
>
> while( feature = OGR_L_GetNextFeature(layer) )
>
> {
>
> mapOldIdToNewId[OGR_F_GetFID(feature)] = newId;
>
> newId ++;
>
> OGR_F_destroy(feature);
>
> }
>
> OGR_L_SetIgnoredFields( layer, NULL );
>
Ok cool, that sounds like a plan - I'll give it a shot.
Thanks
Sandro
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/qgis-developer/attachments/20170705/aa9d5786/attachment-0001.html>
More information about the QGIS-Developer
mailing list