Couldn't we just expose to the API the collection of changed features via QgsVectorLayer?
- Nathan On Sat, Dec 1, 2012 at 12:45 AM, Martin Dobias <[email protected]> wrote: > Hi Ivan > > On Thu, Nov 29, 2012 at 2:15 PM, Ivan Mincik <[email protected]>wrote: > >> Hi, >> 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(), >> f.geometry().exportToWkt() >> > > 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. > > Regards > Martin > > > _______________________________________________ > Qgis-developer mailing list > [email protected] > http://lists.osgeo.org/mailman/listinfo/qgis-developer > >
_______________________________________________ Qgis-developer mailing list [email protected] http://lists.osgeo.org/mailman/listinfo/qgis-developer
