<html>
<head>
<meta http-equiv="Content-Type" content="text/html;
charset=windows-1252">
</head>
<body text="#000000" bgcolor="#FFFFFF">
<p><br>
</p>
<br>
<div class="moz-cite-prefix">On 05.07.2017 14:56, Sandro Mani wrote:<br>
</div>
<blockquote type="cite"
cite="mid:df68b08f-3a9e-b06a-de6e-5ebdefba8fd7@gmail.com">
<meta http-equiv="Content-Type" content="text/html;
charset=windows-1252">
<blockquote type="cite" cite="mid:2744153.04fHL4qHcD@even-i700">
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px;
margin-right:0px; -qt-block-indent:0; text-indent:0px;
-qt-user-state:0;">That could potentially be done using the
current OGR API. Basically in pseudo code, to execute before
executing REPACK</p>
<p style="-qt-paragraph-type:empty; margin-top:0px;
margin-bottom:0px; margin-left:0px; margin-right:0px;
-qt-block-indent:0; text-indent:0px; "> </p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px;
margin-right:0px; -qt-block-indent:0; text-indent:0px;
-qt-user-state:0;">OGR_L_ResetReading(layer)</p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px;
margin-right:0px; -qt-block-indent:0; text-indent:0px;
-qt-user-state:0;">char** ignored_fields = CSLAddString(NULL,
"OGR_GEOMETRY" );</p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px;
margin-right:0px; -qt-block-indent:0; text-indent:0px;
-qt-user-state:0;">OGR_L_SetIgnoredFields( layer,
ignored_fields); // for performance.</p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px;
margin-right:0px; -qt-block-indent:0; text-indent:0px;
-qt-user-state:0;">CSLDestroy(ignored_fields);</p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px;
margin-right:0px; -qt-block-indent:0; text-indent:0px;
-qt-user-state:0;">OGR_L_SetAttributeFilter( layer, NULL )</p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px;
margin-right:0px; -qt-block-indent:0; text-indent:0px;
-qt-user-state:0;">OGR_L_SetSpatialFilter( layer, NULL )</p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px;
margin-right:0px; -qt-block-indent:0; text-indent:0px;
-qt-user-state:0;">std::map<GIntBig, GIntBig>
mapOldIdToNewId;</p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px;
margin-right:0px; -qt-block-indent:0; text-indent:0px;
-qt-user-state:0;">GIntBig newId = 0;</p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px;
margin-right:0px; -qt-block-indent:0; text-indent:0px;
-qt-user-state:0;">while( feature =
OGR_L_GetNextFeature(layer) )</p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px;
margin-right:0px; -qt-block-indent:0; text-indent:0px;
-qt-user-state:0;">{</p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px;
margin-right:0px; -qt-block-indent:0; text-indent:0px;
-qt-user-state:0;"> mapOldIdToNewId[OGR_F_GetFID(feature)] =
newId;</p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px;
margin-right:0px; -qt-block-indent:0; text-indent:0px;
-qt-user-state:0;"> newId ++;</p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px;
margin-right:0px; -qt-block-indent:0; text-indent:0px;
-qt-user-state:0;"> OGR_F_destroy(feature);</p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px;
margin-right:0px; -qt-block-indent:0; text-indent:0px;
-qt-user-state:0;">}</p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px;
margin-right:0px; -qt-block-indent:0; text-indent:0px;
-qt-user-state:0;">OGR_L_SetIgnoredFields( layer, NULL );</p>
<p style="-qt-paragraph-type:empty; margin-top:0px;
margin-bottom:0px; margin-left:0px; margin-right:0px;
-qt-block-indent:0; text-indent:0px; ">
</p>
</blockquote>
Ok cool, that sounds like a plan - I'll give it a shot.<br>
<br>
</blockquote>
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.<br>
<br>
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.<br>
<br>
Sandro<br>
</body>
</html>