Skip to content
Permalink
Browse files
expose WCS in GeoNode provider via data source manager
  • Loading branch information
Samweli authored and nyalldawson committed Apr 17, 2021
1 parent caf8126 commit 795028c4386e29a185f7aca2348e4a888ef2111b
@@ -68,6 +68,14 @@ Adds uri parameters relating to the settings for a WFS layer on the connection t
.. seealso:: :py:func:`addWmsConnectionSettings`
%End

QgsDataSourceUri &addWcsConnectionSettings( QgsDataSourceUri &uri ) const;
%Docstring
Adds uri parameters relating to the settings for a WCS layer on the connection to a :py:class:`QgsDataSourceUri` ``uri``.

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


};

class QgsGeoNodeConnectionUtils
@@ -81,6 +81,11 @@ QgsDataSourceUri &QgsGeoNodeConnection::addWfsConnectionSettings( QgsDataSourceU
return QgsOwsConnection::addWfsConnectionSettings( uri, settingsKey() + QStringLiteral( "/wfs" ) );
}

QgsDataSourceUri &QgsGeoNodeConnection::addWcsConnectionSettings( QgsDataSourceUri &uri ) const
{
return QgsOwsConnection::addWmsWcsConnectionSettings( uri, settingsKey() + QStringLiteral( "/wcs" ) );
}

QString QgsGeoNodeConnection::settingsKey() const
{
return QgsGeoNodeConnectionUtils::pathGeoNodeConnection() + QStringLiteral( "/" ) + mConnName;
@@ -71,6 +71,13 @@ class CORE_EXPORT QgsGeoNodeConnection
*/
QgsDataSourceUri &addWfsConnectionSettings( QgsDataSourceUri &uri ) const;

/**
* Adds uri parameters relating to the settings for a WCS layer on the connection to a QgsDataSourceUri \a uri.
* \see addWmsConnectionSettings()
*/
QgsDataSourceUri &addWcsConnectionSettings( QgsDataSourceUri &uri ) const;


private:

//! The connection name
@@ -189,6 +189,7 @@ void QgsGeoNodeSourceSelect::connectToGeonodeConnection()

QString wmsURL = layer.wmsURL;
QString wfsURL = layer.wfsURL;
QString wcsURL = layer.wcsURL;
QString xyzURL = layer.xyzURL;

if ( !wmsURL.isEmpty() )
@@ -245,6 +246,36 @@ void QgsGeoNodeSourceSelect::connectToGeonodeConnection()
{
QgsDebugMsgLevel( QStringLiteral( "Layer %1 does not have WFS url." ).arg( layer.title ), 3 );
}

if ( !wcsURL.isEmpty() )
{
QStandardItem *titleItem = new QStandardItem( layer.title );
QStandardItem *nameItem = nullptr;
if ( !layer.name.isEmpty() )
{
nameItem = new QStandardItem( layer.name );
}
else
{
nameItem = new QStandardItem( layer.title );
}
QStandardItem *serviceTypeItem = new QStandardItem( tr( "Layer" ) );
QStandardItem *webServiceTypeItem = new QStandardItem( tr( "WCS" ) );

QString typeName = layer.typeName;

titleItem->setData( uuid, Qt::UserRole + 1 );
titleItem->setData( wcsURL, Qt::UserRole + 2 );
titleItem->setData( typeName, Qt::UserRole + 3 );

typedef QList< QStandardItem * > StandardItemList;
mModel->appendRow( StandardItemList() << titleItem << nameItem << serviceTypeItem << webServiceTypeItem );
}
else
{
QgsDebugMsgLevel( QStringLiteral( "Layer %1 does not have WCS url." ).arg( layer.title ), 3 );
}

if ( !xyzURL.isEmpty() )
{
QStandardItem *titleItem = new QStandardItem( layer.title );
@@ -414,6 +445,18 @@ void QgsGeoNodeSourceSelect::addButtonClicked()
QgsDebugMsg( "Add WMS from GeoNode : " + uri.encodedUri() );
emit addRasterLayer( uri.encodedUri(), layerName, QStringLiteral( "wms" ) );
}
else if ( webServiceType == QLatin1String( "WCS" ) )
{
QgsDataSourceUri uri;
QString typeName = mModel->item( row, 0 )->data( Qt::UserRole + 3 ).toString();
uri.setParam( QStringLiteral( "url" ), serviceURL );

connection.addWcsConnectionSettings( uri );
uri.setParam( QStringLiteral( "identifier" ), typeName );

QgsDebugMsg( "Add WCS from GeoNode : " + uri.encodedUri() );
emit addRasterLayer( uri.encodedUri(), layerName, QStringLiteral( "wcs" ) );
}
else if ( webServiceType == QLatin1String( "WFS" ) )
{
// Set static first, to see that it works. Need to think about the UI also.

0 comments on commit 795028c

Please sign in to comment.