Skip to content

Commit dbbbaaf

Browse files
author
wonder
committedJul 8, 2008
added missing implementations for changeAttributeValues, changeGeometryValues
git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@8737 c8812cc2-4d05-0410-92ff-de0c093fc19c

File tree

1 file changed

+28
-6
lines changed

1 file changed

+28
-6
lines changed
 

‎src/providers/memory/memoryprovider.cpp

Lines changed: 28 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -306,19 +306,41 @@ bool QgsMemoryProvider::deleteAttributes(const QgsAttributeIds& attributes)
306306

307307
bool QgsMemoryProvider::changeAttributeValues(const QgsChangedAttributesMap & attr_map)
308308
{
309-
// TODO: change attribute values
310-
return FALSE;
309+
for (QgsChangedAttributesMap::const_iterator it = attr_map.begin(); it != attr_map.end(); ++it)
310+
{
311+
QgsFeatureMap::iterator fit = mFeatures.find(it.key());
312+
if (fit == mFeatures.end())
313+
continue;
314+
315+
const QgsAttributeMap& attrs = it.value();
316+
for (QgsAttributeMap::const_iterator it2 = attrs.begin(); it2 != attrs.end(); ++it2)
317+
fit->changeAttribute(it2.key(), it2.value());
318+
}
319+
return TRUE;
311320
}
312321

313322
bool QgsMemoryProvider::changeGeometryValues(QgsGeometryMap & geometry_map)
314323
{
315-
// TODO: change geometries
316-
317-
// TODO: update spatial index
324+
for (QgsGeometryMap::const_iterator it = geometry_map.begin(); it != geometry_map.end(); ++it)
325+
{
326+
QgsFeatureMap::iterator fit = mFeatures.find(it.key());
327+
if (fit == mFeatures.end())
328+
continue;
329+
330+
// update spatial index
331+
if (mSpatialIndex)
332+
mSpatialIndex->deleteFeature(*fit);
333+
334+
fit->setGeometry(it.value());
335+
336+
// update spatial index
337+
if (mSpatialIndex)
338+
mSpatialIndex->insertFeature(*fit);
339+
}
318340

319341
updateExtent();
320342

321-
return FALSE;
343+
return TRUE;
322344
}
323345

324346
bool QgsMemoryProvider::createSpatialIndex()

0 commit comments

Comments
 (0)
Please sign in to comment.