Graphics Reference
In-Depth Information
canvasReleaseEvent() method to analyze the clicked-on geometry and display the
results:
info = {}
self.analyzeGeometry(geometry, layer, info)
QMessageBox.information(self.iface.mainWindow(), "debug",
repr(info))
If you now do a make deploy and reload the plugin, you should be able to click on a
feature and display information about that feature's geometry. The plugin's output should
look like the following:
This is certainly telling us something useful, but it's not very readable. Let's look at how
we can improve the way we display the statistics.
Firstly, notice that the area and perimeter values are not particularly useful; the Qg-
sDistanceArea object returns lengths and areas in meters, but for most geometries,
these values are too precise and too big. Let's make it more readable by converting the cal-
culated lengths and areas into a whole number of kilometers. To do this, make the follow-
ing highlighted changes to your analyzeGeometry() method:
...
elif geometry.type() == QGis.Line:
self.add(info, 'num_lines', 1)
Search WWH ::




Custom Search