Skip to content
Permalink
Browse files

[needs-docs] Remove seperation between ArcGis Feature Service

and ArcGIS Map Service items in browser

and replace them with a single, unified "ArcGIS Rest Servers" item
which shows a definitive view of the server exposing both
service types.
  • Loading branch information
nyalldawson committed Dec 23, 2020
1 parent 590f8d1 commit 48b8e7448a38ac996daa83f353972cbc16090c47
@@ -285,7 +285,7 @@ void QgsArcGisRestQueryUtils::visitFolderItems( const std::function< void( const
}
}

void QgsArcGisRestQueryUtils::visitServiceItems( const std::function< void( const QString &, const QString & ) > &visitor, const QVariantMap &serviceData, const QString &baseUrl, const ServiceTypeFilter filter )
void QgsArcGisRestQueryUtils::visitServiceItems( const std::function<void ( const QString &, const QString &, const ServiceTypeFilter )> &visitor, const QVariantMap &serviceData, const QString &baseUrl, const ServiceTypeFilter filter )
{
QString base( baseUrl );
bool baseChecked = false;
@@ -301,7 +301,8 @@ void QgsArcGisRestQueryUtils::visitServiceItems( const std::function< void( cons
continue;

// If the requested service type is raster, do not show vector-only services
if ( serviceType == QLatin1String( "FeatureServer" ) && filter == Raster )
const ServiceTypeFilter type = serviceType == QLatin1String( "FeatureServer" ) ? Vector : Raster;
if ( type == Raster && ( filter != Raster && filter != AllTypes ) )
continue;

const QString serviceName = serviceMap.value( QStringLiteral( "name" ) ).toString();
@@ -312,11 +313,11 @@ void QgsArcGisRestQueryUtils::visitServiceItems( const std::function< void( cons
baseChecked = true;
}

visitor( displayName, base + serviceName + '/' + serviceType );
visitor( displayName, base + serviceName + '/' + serviceType, type );
}
}

void QgsArcGisRestQueryUtils::addLayerItems( const std::function< void( const QString &, const QString &, const QString &, const QString &, const QString &, bool, const QString &, const QString & )> &visitor, const QVariantMap &serviceData, const QString &parentUrl, const ServiceTypeFilter filter )
void QgsArcGisRestQueryUtils::addLayerItems( const std::function<void ( const QString &, ServiceTypeFilter, QgsWkbTypes::GeometryType, const QString &, const QString &, const QString &, const QString &, bool, const QString &, const QString & )> &visitor, const QVariantMap &serviceData, const QString &parentUrl, const ServiceTypeFilter filter )
{
const QString authid = QgsArcGisRestUtils::convertSpatialReference( serviceData.value( QStringLiteral( "spatialReference" ) ).toMap() ).authid();

@@ -343,8 +344,9 @@ void QgsArcGisRestQueryUtils::addLayerItems( const std::function< void( const QS
// If the requested layer type is vector, do not show raster-only layers (i.e. non query-able layers)
const bool serviceMayHaveQueryCapability = capabilities.contains( QStringLiteral( "Query" ) ) ||
serviceData.value( QStringLiteral( "serviceDataType" ) ).toString().startsWith( QLatin1String( "esriImageService" ) );
if ( filter == Vector && !serviceMayHaveQueryCapability )
return;

const bool serviceMayRenderMaps = capabilities.contains( QStringLiteral( "Map" ) ) ||
serviceData.value( QStringLiteral( "serviceDataType" ) ).toString().startsWith( QLatin1String( "esriImageService" ) );

const QVariantList layerInfoList = serviceData.value( QStringLiteral( "layers" ) ).toList();
for ( const QVariant &layerInfo : layerInfoList )
@@ -355,13 +357,39 @@ void QgsArcGisRestQueryUtils::addLayerItems( const std::function< void( const QS
const QString name = layerInfoMap.value( QStringLiteral( "name" ) ).toString();
const QString description = layerInfoMap.value( QStringLiteral( "description" ) ).toString();

if ( !layerInfoMap.value( QStringLiteral( "subLayerIds" ) ).toList().empty() )
// Yes, potentially we may visit twice, once as as a raster (if applicable), and once as a vector (if applicable)!
if ( serviceMayRenderMaps && ( filter == Raster || filter == AllTypes ) )
{
visitor( parentLayerId, id, name, description, parentUrl + '/' + id, true, QString(), format );
if ( !layerInfoMap.value( QStringLiteral( "subLayerIds" ) ).toList().empty() )
{
visitor( parentLayerId, Raster, QgsWkbTypes::UnknownGeometry, id, name, description, parentUrl + '/' + id, true, QString(), format );
}
else
{
visitor( parentLayerId, Raster, QgsWkbTypes::UnknownGeometry, id, name, description, parentUrl + '/' + id, false, authid, format );
}
}
else

if ( serviceMayHaveQueryCapability && ( filter == Vector || filter == AllTypes ) )
{
visitor( parentLayerId, id, name, description, parentUrl + '/' + id, false, authid, format );
const QString geometryType = layerInfoMap.value( QStringLiteral( "geometryType" ) ).toString();
if ( serviceMayRenderMaps )
{
if ( geometryType.isEmpty() )
continue;
}

const QgsWkbTypes::Type wkbType = QgsArcGisRestUtils::convertGeometryType( geometryType );


if ( !layerInfoMap.value( QStringLiteral( "subLayerIds" ) ).toList().empty() )
{
visitor( parentLayerId, Vector, QgsWkbTypes::geometryType( wkbType ), id, name, description, parentUrl + '/' + id, true, QString(), format );
}
else
{
visitor( parentLayerId, Vector, QgsWkbTypes::geometryType( wkbType ), id, name, description, parentUrl + '/' + id, false, authid, format );
}
}
}

@@ -370,15 +398,15 @@ void QgsArcGisRestQueryUtils::addLayerItems( const std::function< void( const QS
{
const QString name = QStringLiteral( "(%1)" ).arg( QObject::tr( "All layers" ) );
const QString description = serviceData.value( QStringLiteral( "Comments" ) ).toString();
visitor( 0, 0, name, description, parentUrl, false, authid, format );
visitor( nullptr, Raster, QgsWkbTypes::UnknownGeometry, nullptr, name, description, parentUrl, false, authid, format );
}

// Add root ImageServer as layer
if ( serviceData.value( QStringLiteral( "serviceDataType" ) ).toString().startsWith( QLatin1String( "esriImageService" ) ) )
{
const QString name = serviceData.value( QStringLiteral( "name" ) ).toString();
const QString description = serviceData.value( QStringLiteral( "description" ) ).toString();
visitor( 0, 0, name, description, parentUrl, false, authid, format );
visitor( nullptr, Raster, QgsWkbTypes::UnknownGeometry, nullptr, name, description, parentUrl, false, authid, format );
}
}

@@ -19,6 +19,7 @@

#include "qgis_core.h"
#include "qgsrectangle.h"
#include "qgswkbtypes.h"

#include <QString>
#include <QVariantMap>
@@ -92,12 +93,12 @@ class CORE_EXPORT QgsArcGisRestQueryUtils
/**
* Calls the specified \a visitor function on all service items found within the given service data.
*/
static void visitServiceItems( const std::function<void ( const QString &serviceName, const QString &url )> &visitor, const QVariantMap &serviceData, const QString &baseUrl, const ServiceTypeFilter filter = AllTypes );
static void visitServiceItems( const std::function<void ( const QString &serviceName, const QString &url, ServiceTypeFilter serviceType )> &visitor, const QVariantMap &serviceData, const QString &baseUrl, const ServiceTypeFilter filter = AllTypes );

/**
* Calls the specified \a visitor function on all layer items found within the given service data.
*/
static void addLayerItems( const std::function<void ( const QString &parentLayerId, const QString &layerId, const QString &name, const QString &description, const QString &url, bool isParentLayer, const QString &authid, const QString &format )> &visitor, const QVariantMap &serviceData, const QString &parentUrl, const ServiceTypeFilter filter = AllTypes );
static void addLayerItems( const std::function<void ( const QString &parentLayerId, ServiceTypeFilter serviceType, QgsWkbTypes::GeometryType geometryType, const QString &layerId, const QString &name, const QString &description, const QString &url, bool isParentLayer, const QString &authid, const QString &format )> &visitor, const QVariantMap &serviceData, const QString &parentUrl, const ServiceTypeFilter filter = AllTypes );

private:

@@ -39,16 +39,16 @@ endif()
###############################################################################

set (AFS_SRCS
qgsafsdataitems.cpp
qgsafsfeatureiterator.cpp
qgsafsprovider.cpp
qgsafsshareddata.cpp
qgsarcgisrestdataitems.cpp
)
if (WITH_GUI)
set(AFS_SRCS ${AFS_SRCS}
qgsafsprovidergui.cpp
qgsafsdataitemguiprovider.cpp
qgsafssourceselect.cpp
qgsarcgisrestdataitemguiprovider.cpp
qgsarcgisservicesourceselect.cpp
qgsnewarcgisrestconnection.cpp
)
@@ -85,14 +85,12 @@ install (TARGETS arcgisfeatureserverprovider
###############################################################################

set (AMS_SRCS
qgsamsdataitems.cpp
qgsamsprovider.cpp
)

if (WITH_GUI)
set(AMS_SRCS ${AMS_SRCS}
qgsamsprovidergui.cpp
qgsamsdataitemguiprovider.cpp
qgsamssourceselect.cpp
qgsarcgisservicesourceselect.cpp
qgsnewarcgisrestconnection.cpp

This file was deleted.

@@ -20,7 +20,7 @@
#include "qgsarcgisrestquery.h"
#include "qgsafsfeatureiterator.h"
#include "qgsdatasourceuri.h"
#include "qgsafsdataitems.h"
#include "qgsarcgisrestdataitems.h"
#include "qgslogger.h"
#include "qgsdataitemprovider.h"
#include "qgsapplication.h"
@@ -396,7 +396,7 @@ QList<QgsDataItemProvider *> QgsAfsProviderMetadata::dataItemProviders() const
QList<QgsDataItemProvider *> providers;

providers
<< new QgsAfsDataItemProvider;
<< new QgsArcGisRestDataItemProvider;

return providers;
}

0 comments on commit 48b8e74

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