Skip to content
Permalink
Browse files

[afs] Fix group layers are incorrectly shown in browser

These layers cannot be opened so should be skipped

Fixes #18886

(cherry-picked from c63260e)
  • Loading branch information
nyalldawson committed May 3, 2018
1 parent 4962953 commit fdafd68aefab7ec8de9a8db846815b0888db9045
Showing with 13 additions and 6 deletions.
  1. +13 −6 src/providers/arcgisrest/qgsafsdataitems.cpp
@@ -95,18 +95,25 @@ QVector<QgsDataItem *> QgsAfsConnectionItem::createChildren()
{
QVector<QgsDataItem *> layers;
QString errorTitle, errorMessage;
QVariantMap serviceData = QgsArcGisRestUtils::getServiceInfo( mUrl, errorTitle, errorMessage );
const QVariantMap serviceData = QgsArcGisRestUtils::getServiceInfo( mUrl, errorTitle, errorMessage );
if ( serviceData.isEmpty() )
{
return layers;
}
QString authid = QgsArcGisRestUtils::parseSpatialReference( serviceData[QStringLiteral( "spatialReference" )].toMap() ).authid();
const QString authid = QgsArcGisRestUtils::parseSpatialReference( serviceData.value( QStringLiteral( "spatialReference" ) ).toMap() ).authid();

foreach ( const QVariant &layerInfo, serviceData["layers"].toList() )
const QVariantList layerInfoList = serviceData[QStringLiteral( "layers" )].toList();
for ( const QVariant &layerInfo : layerInfoList )
{
QVariantMap layerInfoMap = layerInfo.toMap();
QString id = layerInfoMap[QStringLiteral( "id" )].toString();
QgsAfsLayerItem *layer = new QgsAfsLayerItem( this, mName, mUrl + "/" + id, layerInfoMap[QStringLiteral( "name" )].toString(), authid );
const QVariantMap layerInfoMap = layerInfo.toMap();
if ( !layerInfoMap.value( QStringLiteral( "subLayerIds" ) ).toList().empty() )
{
// group layer - do not show as it is not possible to load
// TODO - show nested groups
continue;
}
const QString id = layerInfoMap.value( QStringLiteral( "id" ) ).toString();
QgsAfsLayerItem *layer = new QgsAfsLayerItem( this, mName, mUrl + "/" + id, layerInfoMap.value( QStringLiteral( "name" ) ).toString(), authid );
layers.append( layer );
}

0 comments on commit fdafd68

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