[Qgis-developer] ogrLayerName in processing/tools/vector.py
Mark Johnson
mj10777 at googlemail.com
Tue Oct 18 02:55:21 PDT 2016
>
> The problem, as Germán found out, is that the URI passed as parameter
> is not necessarely an OGR provider URI, but a generic QGIS uri, from
> any provider, so it cannot always be opened via ogr.Open.
Yes, ogr-sysntax must be used.
# -- Spatialite provider
# dbname='/tmp/x.sqlite' table="t" (geometry) sql='
would need to call 'GetLayerByName'
Here again there is a problem between gdal 1.* and gdal 2.*
Where there is a table with more than 1 geometry the syntax
'tablename(fieldname)' can be used
In gdal 2.* that syntax can also be used with a table with only 1 geometry
- but not in gdal 1.*: there only the tablename can be used
sLayername="t(geometry)"; // ok for gdal 2.* or gdal 1.* with > 1 geometry
sLayername="t"; // ok for gdal 2.* or gdal 1.* with 1 geometry
ogrLayer = OGR_DS_GetLayerByName( ogrDataSource, TO8( sLayerName ) );
This should work for both PostgreSQL and spatialite based on your samples.
Mark Johnson
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/qgis-developer/attachments/20161018/ad8b93e7/attachment.html>
More information about the Qgis-developer
mailing list