<html>
<head>
<meta http-equiv="content-type" content="text/html;
charset=ISO-8859-1">
</head>
<body bgcolor="#FFFFFF" text="#000000">
<meta http-equiv="CONTENT-TYPE" content="text/html;
charset=ISO-8859-1">
<p style="margin-bottom: 0cm; page-break-before: always"
lang="en-US">Hi to all,<br>
</p>
<br>
I'm working with QGIS 2.0.1 on a python plugin to help users enter
data in a Postgis database.<br>
Among others things, this plugin can convert selected features (from
points to polygons, from lines to points, etc...) <br>
<br>
<u>The plugin :</u><br>
operation_dialog.py is my main module.<br>
convert_geometries module is used to convert features <br>
<br>
In this second module, convert_geometries function accepts 2
parameters : <br>
geomlist (a list of geometries),<br>
geomoutput, (output data type : Qgis.point, Qgis.polygon ou
Qgis.line).<br>
<br>
extract :<br>
<i><font color="#cc0000">def convert_geometries(geomlist, geomtype):<br>
ret = None <br>
if len(set([geom.type() for geom in geomlist])) <> 1:
<br>
print [geom.type() for geom in geomlist]<br>
ret = None <br>
else :<br>
if geomlist[0].type() == QGis.Line and geomtype ==
QGis.Polygon: <br>
ret = linestrings_polygon(geomlist)<br>
...</font></i><br>
<br>
If geometries in geomlist have different data types, then ret=None
(and the plugin manage this error).<br>
Else, if features are lines and polygons are needed, corresponding
conversion function is started.<br>
<br>
convert_geometries is started from my main module :<br>
<br>
<i><font color="#cc0000">geom2=convert_geometries([feature.geometry()
for
feature in
self.iface.activeLayer().selectedFeatures()],geom_output) </font></i><br>
<br>
Here, geomlist is a list of geometries from features selected by
user in the active layer).<br>
geomtype=geom_output (selected by user in a combobox).<br>
<br>
<u>The problem :</u> Things go well if only one feature is selected.
However, if 2 or more features of the same type are selected, (3
lines for example), geometries are <span lang="en">systematically
corrupted</span> during passage from one module to the other,
except the last one.<br>
<br>
In the main module, this line :<br>
« <i><font color="#cc0000">print [feature.geometry() for feature in
self.iface.activeLayer().selectedFeatures()]</font></i> » <br>
returns [1,1,1] (which means [line , line, line]).<br>
However, in convert_geometries, « <i><font color="#cc0000">print
[geom.type() for geom in geomlist]</font></i> » line returns
[3,3,1]<br>
(that is [unknowm geometry, unknowm geometry, line]).<br>
If I try to display geometries in WKT format (<font color="#cc0000"><i>print
[geom.exportToWkt() for geom in geomlist]</i></font>), QGIS
closes without an error message.<br>
<br>
<u>Question :</u><br>
Thus, if a list of several geometries is given in function
parameter, they seems to be corrupted (except the last, or if there
is only one geometry)<br>
<br>
Do you have an idea of what happens ? Where is my mistake? Do you
see tests to perform in order to diagnose this issue ?
(particularly, why the last geometry of a list is not corrupted,
unlike others ?)<br>
<br>
Thanks for advance<br>
<br>
Vincent Damoy<br>
<title></title>
<meta name="GENERATOR" content="LibreOffice 3.5 (Linux)">
<style type="text/css">
<!--
@page { margin: 2cm }
P { margin-bottom: 0.21cm }
--
</style>
</body>
</html>