Skip to content
Permalink
Browse files

[ArcGIS REST] Fix broken browser data items

  • Loading branch information
manisandro committed Jul 4, 2016
1 parent e4afb2f commit f861ed27021019631cfded4f104446365fbd8d5c
@@ -94,12 +94,13 @@ QVector<QgsDataItem*> QgsAfsConnectionItem::createChildren()
{
return layers;
}
QString authid = QgsArcGisRestUtils::parseSpatialReference( serviceData["spatialReference"].toMap() ).authid();

foreach ( const QVariant& layerInfo, serviceData["layers"].toList() )
{
QVariantMap layerInfoMap = layerInfo.toMap();
QString id = layerInfoMap["id"].toString();
QgsAfsLayerItem* layer = new QgsAfsLayerItem( this, mName, mUrl + "/" + id, layerInfoMap["name"].toString() );
QgsAfsLayerItem* layer = new QgsAfsLayerItem( this, mName, mUrl + "/" + id, layerInfoMap["name"].toString(), authid );
layers.append( layer );
}

@@ -146,10 +147,10 @@ void QgsAfsConnectionItem::deleteConnection()

///////////////////////////////////////////////////////////////////////////////

QgsAfsLayerItem::QgsAfsLayerItem( QgsDataItem* parent, const QString &name, const QString &url, const QString &title )
QgsAfsLayerItem::QgsAfsLayerItem( QgsDataItem* parent, const QString &name, const QString &url, const QString &title, const QString& authid )
: QgsLayerItem( parent, title, parent->path() + "/" + name, QString(), QgsLayerItem::Vector, "arcgisfeatureserver" )
{
mUri = url;
mUri = QString( "crs='%1' url='%2'" ).arg( authid ).arg( url );
setState( Populated );
mIconName = "mIconConnect.png";
}
@@ -55,7 +55,7 @@ class QgsAfsConnectionItem : public QgsDataCollectionItem
class QgsAfsLayerItem : public QgsLayerItem
{
public:
QgsAfsLayerItem( QgsDataItem* parent, const QString& name, const QString &url, const QString& title );
QgsAfsLayerItem( QgsDataItem* parent, const QString& name, const QString &url, const QString& title , const QString &authid );
};

#endif // QGSAFSDATAITEMS_H
@@ -92,11 +92,30 @@ QVector<QgsDataItem*> QgsAmsConnectionItem::createChildren()
return layers;
}

QString authid = QgsArcGisRestUtils::parseSpatialReference( serviceData["spatialReference"].toMap() ).authid();
QString format = "jpg";
bool found = false;
QList<QByteArray> supportedFormats = QImageReader::supportedImageFormats();
foreach ( const QString& encoding, serviceData["supportedImageFormatTypes"].toString().split( "," ) )
{
foreach ( const QByteArray& fmt, supportedFormats )
{
if ( encoding.startsWith( fmt, Qt::CaseInsensitive ) )
{
format = encoding;
found = true;
break;
}
}
if ( found )
break;
}

foreach ( const QVariant& layerInfo, serviceData["layers"].toList() )
{
QVariantMap layerInfoMap = layerInfo.toMap();
QString id = layerInfoMap["id"].toString();
QgsAmsLayerItem* layer = new QgsAmsLayerItem( this, mName, mUrl + "/" + id, layerInfoMap["name"].toString() );
QgsAmsLayerItem* layer = new QgsAmsLayerItem( this, mName, mUrl, id, layerInfoMap["name"].toString(), authid, format );
layers.append( layer );
}

@@ -143,10 +162,10 @@ void QgsAmsConnectionItem::deleteConnection()

///////////////////////////////////////////////////////////////////////////////

QgsAmsLayerItem::QgsAmsLayerItem( QgsDataItem* parent, const QString &name, const QString &url, const QString &title )
QgsAmsLayerItem::QgsAmsLayerItem( QgsDataItem* parent, const QString& name, const QString &url, const QString& id, const QString& title, const QString& authid, const QString& format )
: QgsLayerItem( parent, title, parent->path() + "/" + name, QString(), QgsLayerItem::Raster, "arcgismapserver" )
{
mUri = url;
mUri = QString( "crs='%1' format='%2' layer='%3' url='%4'" ).arg( authid ).arg( format ).arg( id ).arg( url );
setState( Populated );
mIconName = "mIconAms.svg";
}
@@ -57,7 +57,7 @@ class QgsAmsConnectionItem : public QgsDataCollectionItem
class QgsAmsLayerItem : public QgsLayerItem
{
public:
QgsAmsLayerItem( QgsDataItem* parent, const QString& name, const QString &url, const QString& title );
QgsAmsLayerItem( QgsDataItem* parent, const QString& name, const QString &url, const QString& id, const QString& title, const QString& authid, const QString& format );
};

#endif // QGSAMSDATAITEMS_H

0 comments on commit f861ed2

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