def vectorIdentifyTool(self, point, qgsPoint): ''' Get text for the coordinates and attributes of vector features ''' # debugging print "identify.vectorIdentifyTool()" provider = self.mainwindow.provider # fields() returns a dictionary with the field key and the name of the field fieldNamesDict = provider.fields() allAttrs = provider.attributeIndexes() selectRect = shared.makeSelectRect(self.mainwindow.geom, point, self.transform) provider.select(allAttrs, selectRect, True, False) feat = QgsFeature() while provider.nextFeature(feat): # fetch the feature geometry, which is the feature's spatial coordinates fgeom = feat.geometry() # This records the feature's ID and its spatial coordinates text = "Feature ID %d: %s\n" % (feat.id()+1, fgeom.exportToWkt()) #A QgsAttribute map is a Python dictionary (key = field id : value = # the field's value as a QtCore.QVariant()object attrs = feat.attributeMap() # This takes the field key (starting with 0 for the first field) uses it # to return the field name from the fieldNamesDictionary. The loop then # records the field name and field value for the selected feature # note: t for (key, attr) in attrs.iteritems(): text += "%s: %s\n" % (fieldNamesDict.get(key).name(), attr.toString()) # display the text to the user title = "Vector Feature Information" self.displayInformation(title, text)
def selectFeat(self, point): # debugging print "SelectTool(): selectFeat" activeVLayer = self.mainwindow.activeVLayer selectRect = shared.makeSelectRect(self.mainwindow.geom, point, self.transform) activeVLayer.select(selectRect, True) #self.mainwindow.canvas.refresh()
def selectFeat(self, point): # debugging print "Tools.selectfeatures.SelectTool().selectFeat()" activeVLayer = self.mainwindow.activeVLayer selectRect = shared.makeSelectRect(self.mainwindow.geom, point, self.transform) activeVLayer.select(selectRect, True)