aeag / mask

AEAG Mask plugin
12 stars 6 forks source link

error calling aeag_mask.do in another plugin #63

Closed ju4e closed 7 years ago

ju4e commented 7 years ago

hello, I'm tying to generate a mask using aeag_mask.do function in another plugin. When i call this fuction, using geometry of selected feature in a layer, an error occur : "Traceback (most recent call last): File "", line 3, in File "C:/Users/Julien/.qgis2/python/plugins\mask\aeag_mask.py", line 61, in do this.layer = this.apply_mask_parameters(this.layer, this.parameters, crs, poly, name, keep_layer = False ) File "C:/Users/Julien/.qgis2/python/plugins\mask\aeag_mask.py", line 459, in apply_mask_parameters layer = QgsVectorLayer("MultiPolygon?crs=%s" % dest_crs.authid(), mask_name, "memory") AttributeError: 'int' object has no attribute 'authid'"

I have correctly defined do function's parameters (layer's crs, feature's geometry..) so i don't understand this error. Could you enlighten me on that? thanks Julien

xcaeag commented 7 years ago

Hello, I do this in one of our plugins, it's works:

from mask import aeag_mask mapcrs = iface.canvas.mapSettings().destinationCrs() geom = QgsGeometry(...) aeag_mask.do(mapcrs, [geom], "layerName")

Can you tell me more about the plugin or QGis version ?

Thanks

ju4e commented 7 years ago

Hello, Thank you for your reply. Here are my system specifications :

the error described in my first post always appears..

Any idea?

Thanks.

xcaeag commented 7 years ago

Try this :

from mask import aeag_mask # build a QgsCoordinateReferenceSystem object mymapcrs = QgsCoordinateReferenceSystem(2154) # two parenthesis for a simple polygon geom=QgsGeometry.fromWkt("Polygon(( 468157 6360943, 468136 6360937, 468134 6360946, 468119 6360953, 468128 6360970, 468147 6360975, 468157 6360943 ))") # and then, pass a array of geom aeag_mask.do(mymapcrs, [geom], masklayerName)

Casteljaloux, ce n'est pas très loin d'ici !

ju4e commented 7 years ago

Thank you, it's working! It seems that defining the pcrs by its only epsg code is not enough..

Et oui, Casteljaloux est aussi sur le territoire d'intervention de l'aeag! ;)

xcaeag commented 7 years ago

Perfect, I will try to enrich the doc...