Skip to content
Permalink
Browse files

Merge pull request #6827 from borysiasty/gpkgfix

Backport 1822b76 & 24de819 - use layername instead of layerid in multilayer OGR source URI
  • Loading branch information
borysiasty committed Apr 20, 2018
2 parents c577b65 + cdb4f85 commit 6564aecb9d03b6f65907148f08417a91f64e5fda
Showing with 20 additions and 1 deletion.
  1. +20 −1 src/app/qgisapp.cpp
@@ -3947,6 +3947,9 @@ void QgisApp::askUserForOGRSublayers( QgsVectorLayer *layer )
QString layertype = layer->dataProvider()->storageType();

QgsSublayersDialog::LayerDefinitionList list;
QMap< QString, int > mapLayerNameToCount;
bool uniqueNames = true;
int lastLayerId = -1;
Q_FOREACH ( const QString& sublayer, sublayers )
{
// OGR provider returns items in this format:
@@ -3967,6 +3970,13 @@ void QgisApp::askUserForOGRSublayers( QgsVectorLayer *layer )
def.layerName = elements[1];
def.count = elements[2].toInt();
def.type = elements[3];
if ( lastLayerId != def.layerId )
{
int count = ++mapLayerNameToCount[def.layerName];
if ( count > 1 || def.layerName.isEmpty() )
uniqueNames = false;
lastLayerId = def.layerId;
}
list << def;
}
else
@@ -4003,7 +4013,16 @@ void QgisApp::askUserForOGRSublayers( QgsVectorLayer *layer )
Q_FOREACH ( const QgsSublayersDialog::LayerDefinition& def, chooseSublayersDialog.selection() )
{
QString layerGeometryType = def.type;
QString composedURI = uri + "|layerid=" + QString::number( def.layerId );
QString composedURI = uri;
if ( uniqueNames )
{
composedURI += "|layername=" + def.layerName;
}
else
{
// Only use layerId if there are ambiguities with names
composedURI += "|layerid=" + QString::number( def.layerId );
}

if ( !layerGeometryType.isEmpty() )
{

0 comments on commit 6564aec

Please sign in to comment.
You can’t perform that action at this time.