[Qgis-developer] plugin dev - save to ogr vector file
Rob Nickerson
rob.j.nickerson at gmail.com
Tue Jul 3 11:17:59 PDT 2012
Hi All,
I am brand new to QGIS (having got here from my work with OpenStreetMap) so
apologies if I am posting this in the wrong place. What I am trying to do
is adapt the fTools plugin so that it can save to any ogr verctor file
format. The reason behind this is that I found the ESRI shapefile format to
be restrictive (e.g. attribute values are limited to 254 chars - 80 in
QGIS??).
So far Carson has kindly pointed me in the direction of the QGIS repo and I
have exposed the other ogr formats in the save file dialog. This is where I
get stuck. I can call QgsEncodingFileDialog().selectedNameFilter() to get
the file name format however this is not compatible with the way
QgsVectorFileWriter() works. The file writer requires the "driver name" as
a format (e.g. ESRI Shapefile) whereas selectedNameFilter() returns the
hard coded name in the save dialogues drop down box (e.g. ESRI Shapefiles
[OGR] (*.shp *.SHP) ).
Q: Is there an easy way to get just the driver name?
- - - - - - - - - - - - - - -
FYI I have looked at gdal tools. They set up a dictionary to be able to
lookup any "LONGNAME" and return the driver name (SHORTNAME). The longnames
are hard coded in the plugin and represent the QGIS save dialogues drop
down format names (with the [OGR] and bracketed file extensions cut). The
shortnames are the driver names from ogr. This code can be seen here:
http://hub.qgis.org/projects/quantum-gis/repository/revisions/master/entry/python/plugins/GdalTools/tools/GdalTools_utils.py#L562
Although this should work, it would seem odd to have this hard coding in
every plugin that wants to write to any ogr format!!
Any ideas appreciated
Regards,
Rob
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/qgis-developer/attachments/20120703/e7a30653/attachment.html>
More information about the Qgis-developer
mailing list