[Qgis-developer] fTools buffer bug

Alessandro Pasotti apasotti at gmail.com
Fri Oct 22 07:38:33 EDT 2010


Hi,

I'm preparing a QGIS demo for tomorrow's italian Linux Day meeting and I'm
hitting an error with Ftools->buffering.

Basically, I'm building a 20 m buffer around a selected linestring (first I
select one geometry from a postgis vector layer, but I get the same result
if the selected geometry comes from a sqlite file), I'm saving the buffer in
/home/me/tmp/buf.shp, the plugin says :

Shapefile in ouput creato:

/home/me/tmp/buf.shp

but the file is not there (and this is a bug: the message shouldn't say the
the file has been created when it is not), adding to the legend throws an
error since the file does not exists and cannot be loaded.

The problem originates from QGIS shapefile writer which cannot resolve
conflicts between field names (which are truncated at 8 chars or so AFAIK).

I soved hacking the ftools plugin code

$ diff tmp/ftool.mod
/usr/share/qgis/python/plugins/fTools/tools/doGeoprocessing.py
297,298d296
<     # ABP:
<     fields = { 0 : fields[0] }

a couple of thoughts:

1 - fTools (or QgsVectorFileWriter<http://doc.qgis.org/stable/classQgsVectorFileWriter.html#2353ce27918c2f711dba97f1d6b96a23>?)
should better handle errors when shapefile conversion - save fails
2 - an option to save buffer and other results to temporary in-memory layer
should be provided
3 - is it really necessary to copy all source vector fields in the result
file ? Not in the buffer function, maybe in the other tools ?
4 - the docs say QgsFileWriter will support other output formats, is there a
roadmap for this feature ? This could eventually solve many conversion
errors due to shapefile (DBF) limitations
5 - it's not clear to me how to catch QgsFileWriter errors from python code
while delegating real writing to the destructor (see: "del writer" in the
plugin's code), this could solve point 1 in this list


-- 
Alessandro Pasotti
w3:   www.itopen.it
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/qgis-developer/attachments/20101022/332b7b41/attachment-0001.html


More information about the Qgis-developer mailing list