Skip to content

Commit

Permalink
expose WCS in GeoNode provider via data source manager
Browse files Browse the repository at this point in the history
  • Loading branch information
Samweli authored and nyalldawson committed Apr 17, 2021
1 parent caf8126 commit 795028c
Show file tree
Hide file tree
Showing 4 changed files with 63 additions and 0 deletions.
Expand Up @@ -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
Expand Down
5 changes: 5 additions & 0 deletions src/core/geocms/geonode/qgsgeonodeconnection.cpp
Expand Up @@ -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;
Expand Down
7 changes: 7 additions & 0 deletions src/core/geocms/geonode/qgsgeonodeconnection.h
Expand Up @@ -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
Expand Down
43 changes: 43 additions & 0 deletions src/providers/geonode/qgsgeonodesourceselect.cpp
Expand Up @@ -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() )
Expand Down Expand Up @@ -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 );
Expand Down Expand Up @@ -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.
Expand Down

0 comments on commit 795028c

Please sign in to comment.