Skip to content

Commit

Permalink
Update sip, fix use of old style enum
Browse files Browse the repository at this point in the history
  • Loading branch information
nyalldawson committed Nov 11, 2019
1 parent a6e8fb6 commit 5eeba90
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 17 deletions.
14 changes: 14 additions & 0 deletions python/core/auto_generated/geocms/geonode/qgsgeonoderequest.sip.in
Expand Up @@ -40,15 +40,24 @@ server instance, for instance requesting all available layers or layer styles.
%End
public:

enum class BackendServer
{
Unknown,
QgisServer,
Geoserver
};

struct ServiceLayerDetail
{
QUuid uuid;
QString id;
QString name;
QString typeName;
QString title;
QString wmsURL;
QString wfsURL;
QString xyzURL;
BackendServer server;
};

QgsGeoNodeRequest( const QString &baseUrl, bool forceRefresh, QObject *parent = 0 );
Expand Down Expand Up @@ -180,6 +189,11 @@ Returns the network protocol (e.g. 'http') used for connecting with the server.
Sets the network ``protocol`` (e.g. 'http') used for connecting with the server.

.. seealso:: :py:func:`protocol`
%End

QgsGeoNodeRequest::ServiceLayerDetail parseOwsUrl( QgsGeoNodeRequest::ServiceLayerDetail &layerStruct, const QVariantList &layerLinks );
%Docstring
Returns the updated ServiceLayerDetail struct with WMS/WFS/XYZ url.
%End

public slots:
Expand Down
41 changes: 29 additions & 12 deletions src/core/geocms/geonode/qgsgeonoderequest.cpp
Expand Up @@ -308,17 +308,24 @@ QList<QgsGeoNodeRequest::ServiceLayerDetail> QgsGeoNodeRequest::parseLayers( con

// Avoid iterating all the layers to get the service url. Instead, generate a string format once we found one service url
// for every service (wms, wfs, xyz). And then use the string format for the other layers since they are identical.
if ( tempLayerStruct.server == QgsGeoNodeRequest::QGIS_SERVER )
switch ( tempLayerStruct.server )
{
wmsURLFormat = ! tempLayerStruct.wmsURL.isEmpty() ? tempLayerStruct.wmsURL.replace( layerStruct.name, QStringLiteral( "%1" ) ) : QString();
wfsURLFormat = ! tempLayerStruct.wfsURL.isEmpty() ? tempLayerStruct.wfsURL.replace( layerStruct.name, QStringLiteral( "%1" ) ) : QString();
xyzURLFormat = ! tempLayerStruct.xyzURL.isEmpty() ? tempLayerStruct.xyzURL.replace( layerStruct.name, QStringLiteral( "%1" ) ) : QString();
}
else if ( tempLayerStruct.server == QgsGeoNodeRequest::GEOSERVER )
{
wmsURLFormat = ! tempLayerStruct.wmsURL.isEmpty() ? tempLayerStruct.wmsURL : QString();
wfsURLFormat = ! tempLayerStruct.wfsURL.isEmpty() ? tempLayerStruct.wfsURL : QString();
xyzURLFormat = ! tempLayerStruct.xyzURL.isEmpty() ? tempLayerStruct.xyzURL.replace( layerStruct.name, QStringLiteral( "%1" ) ) : "";
case QgsGeoNodeRequest::BackendServer::QgisServer:
{
wmsURLFormat = ! tempLayerStruct.wmsURL.isEmpty() ? tempLayerStruct.wmsURL.replace( layerStruct.name, QStringLiteral( "%1" ) ) : QString();
wfsURLFormat = ! tempLayerStruct.wfsURL.isEmpty() ? tempLayerStruct.wfsURL.replace( layerStruct.name, QStringLiteral( "%1" ) ) : QString();
xyzURLFormat = ! tempLayerStruct.xyzURL.isEmpty() ? tempLayerStruct.xyzURL.replace( layerStruct.name, QStringLiteral( "%1" ) ) : QString();
break;
}
case QgsGeoNodeRequest::BackendServer::Geoserver:
{
wmsURLFormat = ! tempLayerStruct.wmsURL.isEmpty() ? tempLayerStruct.wmsURL : QString();
wfsURLFormat = ! tempLayerStruct.wfsURL.isEmpty() ? tempLayerStruct.wfsURL : QString();
xyzURLFormat = ! tempLayerStruct.xyzURL.isEmpty() ? tempLayerStruct.xyzURL.replace( layerStruct.name, QStringLiteral( "%1" ) ) : QString();
break;
}
case QgsGeoNodeRequest::BackendServer::Unknown:
break;
}
}
else
Expand Down Expand Up @@ -366,8 +373,18 @@ QgsGeoNodeRequest::ServiceLayerDetail QgsGeoNodeRequest::parseOwsUrl( QgsGeoNode
}
}

if ( layerStruct.server == QgsGeoNodeRequest::UNKNOWN )
layerStruct.server = urlFound.contains( QStringLiteral( "qgis-server" ) ) ? QgsGeoNodeRequest::QGIS_SERVER : QgsGeoNodeRequest::GEOSERVER;
switch ( layerStruct.server )
{
case QgsGeoNodeRequest::BackendServer::Geoserver:
case QgsGeoNodeRequest::BackendServer::QgisServer:
break;

case QgsGeoNodeRequest::BackendServer::Unknown:
{
layerStruct.server = urlFound.contains( QStringLiteral( "qgis-server" ) ) ? QgsGeoNodeRequest::BackendServer::QgisServer : QgsGeoNodeRequest::BackendServer::Geoserver;
break;
}
}
}

return layerStruct;
Expand Down
10 changes: 5 additions & 5 deletions src/core/geocms/geonode/qgsgeonoderequest.h
Expand Up @@ -70,12 +70,12 @@ class CORE_EXPORT QgsGeoNodeRequest : public QObject
/**
* GeoNode backend server type.
*/
typedef enum
enum class BackendServer
{
UNKNOWN,
QGIS_SERVER,
GEOSERVER
} BackendServer;
Unknown, //!< Unknown backend
QgisServer, //!< QGIS server used as backend
Geoserver //!< Geoserver used as backend
};

/**
* Service layer details for an individual layer from a GeoNode connection.
Expand Down

0 comments on commit 5eeba90

Please sign in to comment.