<table cellspacing="0" cellpadding="0" border="0" ><tr><td valign="top" style="font: inherit;">Is editing an existing shape file using C++ supported in QGIS 1.6? Almost all of the tools create a new shape file instead of updating the existing one. I would like to not waste my time if it is not possible to modify/overwrite an existing data file.<br><br>Thank you,<br><br>maaza<br><br>--- On <b>Fri, 4/29/11, maaza mekuria <i><sailmcm@yahoo.com></i></b> wrote:<br><blockquote style="border-left: 2px solid rgb(16, 16, 255); margin-left: 5px; padding-left: 5px;"><br>From: maaza mekuria <sailmcm@yahoo.com><br>Subject: [Qgis-developer] Attribute data update of a shape file<br>To: qgis-developer@lists.osgeo.org<br>Date: Friday, April 29, 2011, 10:56 AM<br><br><div id="yiv1303950513"><table border="0" cellpadding="0" cellspacing="0"><tbody><tr><td style="font: inherit;" valign="top">Dear QGIS Gurus:<br>I have a written a plugin that updates an attribute
of a shape file and it tells me it ran fine and yet, I am not able to see the changes in the attribute table once the program finishes. I am using QGIS 1.6 Copiapo on Windows). I am compiling using the 1.7 source, but I have tried using the trunk version and it does not seem to matter at all.<br><br>I can see the edit starting with all the extent selected and it finishes without an error. I also write a log file before and after the feature attribute change and the feature values change correctly.<br>What am i doing wrong?<br><br>The simplified code is posted below,<br><br><code> QgsVectorDataProvider* vProvider = theVectorLayer->dataProvider();<br> theVectorLayer->select(vProvider->attributeIndexes(),
<br> theVectorLayer->extent(), true, false);<br> QgsFeature currentFeature;<br> QgsGeometry* currentGeometry = 0;<br> bool blnEdit = theVectorLayer->startEditing();<br> QgsAttributeList attrList = vProvider->attributeIndexes();<br> vProvider->select(attrList);<br> blnFeat = vProvider->nextFeature(currentFeature);<br> QgsAttributeMap atMap1;<br> vProvider->createSpatialIndex();<br> QgsAttributeList attrList = vProvider->attributeIndexes();<br> vProvider->select(attrList);<br> blnFeat =
vProvider->nextFeature(currentFeature);<br> QgsAttributeMap atMap1;<br> QString featureAttributesString;<br> int ltsVal = 10;<br> int ltsFldIdx = 1;<br> QVariant fld0 ;<br> while(blnFeat)<br> {<br> atMap1 = currentFeature.attributeMap();<br> fld0 = atMap1.value(0);<br> currentGeometry = currentFeature.geometry();<br> if(!currentGeometry)<br> {<br> continue;<br> } <br>
else<br> {<br> currentFeature.changeAttribute(ltsFldIdx,QVariant(ltsVal)); <br> }<br> blnFeat = vProvider->nextFeature(currentFeature);<br> }<br> blnAttrAdded = theVectorLayer->commitChanges();<br> theVectorLayer->endEditCommand();<br></code></td></tr></tbody></table></div><br>-----Inline Attachment Follows-----<br><br><div class="plainMail">_______________________________________________<br>Qgis-developer mailing list<br><a ymailto="mailto:Qgis-developer@lists.osgeo.org" href="/mc/compose?to=Qgis-developer@lists.osgeo.org">Qgis-developer@lists.osgeo.org</a><br><a href="http://lists.osgeo.org/mailman/listinfo/qgis-developer"
target="_blank">http://lists.osgeo.org/mailman/listinfo/qgis-developer</a><br></div></blockquote></td></tr></table>