[Qgis-developer] Corrections of QgsOgrProvider implementaion of GDAL 2.0

Even Rouault even.rouault at spatialys.com
Tue Mar 21 01:16:24 PDT 2017


On mardi 21 mars 2017 01:04:44 CET Mark Johnson wrote:
> > So if we want to address both we need the layer_id and layer_name. I'd say
> > when you build a OGR URI (mostly in QgisApp::askUserForOGRSublayers()),
> > then look at the uniqueness of the layer names. If there's layer name
> > unicity, then use only the layer name. Otherwise fallback to uniquely the
> > layer_id (and well in that case if the datasource changes at some point,
> > we
> > might have an issue indeed)
> 
> This is already being done in my version.
> 
> Setting the id to -1 could tell the QgsOgrProvider that the layername is
> unique
> - and remove the need of the extra parameter

>From a robustness point of view, I think we should be robust to layerid being absent from the 
URI (and I'd prefer that when we generate URI, we don't set layerId = -1 but just remove it) 
since URIs can also been built by users and not only through the UI. We shoud also be robust 
to layername from being absent as well, as done currently.

> 
> id >= 0 would tell QgsOgrProvider that the id MUST be used, because there
> are duplicate layernames.
> 

So if both a layerid and layername, you would prever layerid over layername ? So the reverse 
of
https://github.com/qgis/QGIS/blob/master/src/providers/ogr/qgsogrprovider.cpp#L3494 ?

Deciding which one is prioritary will always been a matter of arbitrary taste, but as there's 
currently a logic, I'd prefer we keep it as much as possible.

> The id and layername will be stored (as it was before) in the URI/Project.

subLayers() should return both layerid (potentially set to -1 if there's no issue of unicity) and 
layername as it does currently, but when generating a URI, it should only set one of them :
* if subLayers() returned layerId >=0 , use it in the URI
* otherwise use layerName.

> 
> Since at this point it is known that the values are valid
> - no further checks are needed and can be opened directly
> 
> Can we agree on this?
> Anything else still open?

To solve the issue of several geometry fields we also need a (optional) parameter with the 
geometry column name.

Even

-- 
Spatialys - Geospatial professional services
http://www.spatialys.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/qgis-developer/attachments/20170321/019c92fe/attachment.html>


More information about the Qgis-developer mailing list