[Qgis-developer] Get list of dirty features and their attributes
madmanwoo at gmail.com
Fri Nov 30 06:47:09 PST 2012
Couldn't we just expose to the API the collection of changed features via
On Sat, Dec 1, 2012 at 12:45 AM, Martin Dobias <wonder.sk at gmail.com> wrote:
> Hi Ivan
> On Thu, Nov 29, 2012 at 2:15 PM, Ivan Mincik <ivan.mincik at gmail.com>wrote:
>> sure you know this - when editing/adding multiple features to layer and
>> pressing 'save' button an error message appears because of some database
>> constraint violation or invalid data type in attribute table.
>> There is very hard to find out a problematic features when many of them
>> where changed or added.
>> We wrote a small Python console script to print all dirty features with
>> their attributes and WKT geometry:
>> # QGIS 1.7, 1.8, author: Marcel Dancak, Gista s.r.o.
>> layer = qgis.utils.iface.activeLayer()
>> map = qgis.utils.iface.mapCanvas()
>> layer.select(map.fullExtent(), False)
>> fields = layer.dataProvider().fields()
>> features = layer.selectedFeatures()
>> # filter only new features
>> features = [f for f in features if f.id() < 0]
>> for f in features:
>> attribs = dict([(unicode(fields[k].name().toUtf8()),
>> unicode(v.toString().toUtf8())) for k, v in f.attributeMap().iteritems()])
>> print f.id(), attribs, f.geometry().type(),
> Are you interested just in newly added features or any "dirty" features,
> i.e. also changed features and removed features? Because the above would
> work just for new features. Currently it's not possible to access
> uncommitted changes... but in theory you could still iterate over vector
> layer and then iterate through its data provider and compare the results to
> detect all changes.
> If you decide to create a plugin, you could listen to signals from
> QgsVectorLayer (featureAdded, featureDeleted and others) to immediately
> detect any changes.
> In general, any tools that would lead to easier detection of problems
> would be welcome.
> Qgis-developer mailing list
> Qgis-developer at lists.osgeo.org
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Qgis-developer