On 05.07.2017 14:56, Sandro Mani wrote:
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.
Hmm so while on the provider side it works well, for the geometry
checker it is turning out to be pretty hard to deal with the changing
feature ids (just to cite one example: error fixed by merging geometry
of feature 10 with that of 11, results in {deleted: 10, updated: 11},
but after the feature id adjustment this would read {deleted: 10,
updated: 10}, meaning one would need to keep track that deleted: 10
refers to the old featureid). Not saying that it isn't doable, but the
complexitiy of properly handling the feature id changes is non-trivial.
So, other suggestion: any objections if I add a method to
QgsVectorDataProvider to temporarily freeze repacking? I could also add
a notification informing the user that the shapefile should not be used
in other applications while repacking is frozen.
Sandro
_______________________________________________
QGIS-Developer mailing list
QGIS-Developer@lists.osgeo.org
List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer
Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer