Der QGIS developers,

I'm trying to write a python plugin to reate input data for one of our models. It basicly converts three shape files with special fields to a text file.

I have a buildings vector (polygon) layer containing three polygons (which I created for testing). This layer is called "build" in the code. To extract its geometries, I wrote a little function:

def extract_poly_geometry(self, layer):
feature = QgsFeature()
geom_list = []
while layer.dataProvider().nextFeature(feature):
geom_list.append(feature.geometry())
return geom_list

In the main part of my program it is called by "theINPolyShapeField = self.extract_poly_geometry(build)". "len(theINPolyShapeField)" returnes 3.

Later I iterate over the polygons and try to run some code for each of them:

for a in range(0, (len(theINPolyShapeField) - 1), 1): # going through buildings (polygons)
thepoly = theINPolyShapeField[a] # extract building number a
QMessageBox.information(None, "DEBUG:", str(thepoly))
# polyarea = float(thepoly.area()) --> carashes QGIS (segmentation fault)
QMessageBox.information(None, "DEBUG:", str(thepoly.asPolygon()))

I use the QMessageBoxes for debuging. The first one returns "qgis.core.QgsGeometry object at 0xbbe889c", which I assume is correct. The second one however deliveres an empty list, "[]".

I then tried to convert the geometry to MultyPoint by "str(thepoly.asMultiPoint()" and was trying to display the result using "QMessageBox.information(None, "DEBUG:", str(thepoly.asMultiPoint()))" to have a look at the points, but this also crashes QGIS with segmentation fault…

I checked the type of thepoly on the console by "print(thepoly.wkbType())" which returns "3". According to Quantum GIS API Documentation this means "WKBPolygon". So thepoly is a polygon, is it?

I tried thepoly.validateGeometry() on the python console to track down the error. When I tried it for my first geometry, it returned "[]". A call for the second one crashed QGIS with segmentation fault…

I'm afraid I'm stuck…

Regards,
Dominik
_______________________________________________
Qgis-developer mailing list
Qgis-developer@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/qgis-developer

Reply via email to