Skip to content

Commit

Permalink
detect temporal dimensions from wmst layers added from data source ma…
Browse files Browse the repository at this point in the history
…nager
  • Loading branch information
Samweli authored and nyalldawson committed Mar 31, 2020
1 parent 507f645 commit e86faa4
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 0 deletions.
36 changes: 36 additions & 0 deletions src/providers/wms/qgswmssourceselect.cpp
Expand Up @@ -277,6 +277,7 @@ void QgsWMSSourceSelect::clear()
bool QgsWMSSourceSelect::populateLayerList( const QgsWmsCapabilities &capabilities )
{
const QVector<QgsWmsLayerProperty> layers = capabilities.supportedLayers();
mLayerProperties = layers;

bool first = true;
QSet<QString> alreadyAddedLabels;
Expand Down Expand Up @@ -515,6 +516,8 @@ void QgsWMSSourceSelect::addButtonClicked()
collectSelectedLayers( layers, styles, titles );
crs = mCRS;
format = mFormats[ mImageFormatGroup->checkedId()].format;

collectDimensions( layers, uri );
}
else
{
Expand Down Expand Up @@ -1020,6 +1023,39 @@ void QgsWMSSourceSelect::collectSelectedLayers( QStringList &layers, QStringList
}
}

void QgsWMSSourceSelect::collectDimensions( QStringList &layers, QgsDataSourceUri &uri )
{
for ( const QgsWmsLayerProperty layerProperty : mLayerProperties )
{
if ( layerProperty.name == layers.join( QStringLiteral( "," ) ) )
{
// Check for layer dimensions
for ( const QgsWmsDimensionProperty &dimension : qgis::as_const( layerProperty.dimensions ) )
{
// add temporal dimensions only
if ( dimension.name == QLatin1String( "time" ) ||
dimension.name == QLatin1String( "reference_time" ) )
{
QString name = dimension.name == QLatin1String( "time" ) ?
QString( "timeDimensionExtent" ) : QString( "referenceTimeDimensionExtent" );

if ( !( uri.param( QLatin1String( "type" ) ) == QLatin1String( "wmst" ) ) )
uri.setParam( QLatin1String( "type" ), QLatin1String( "wmst" ) );
uri.setParam( name, dimension.extent );
}
}

// WMS-T defaults settings
if ( uri.param( QLatin1String( "type" ) ) == QLatin1String( "wmst" ) )
{
uri.setParam( QLatin1String( "temporalSource" ), QLatin1String( "provider" ) );
uri.setParam( QLatin1String( "enableTime" ), QLatin1String( "yes" ) );
}

}
}
}

QString QgsWMSSourceSelect::selectedImageEncoding()
{
// TODO: Match this hard coded list to the list of formats Qt reports it can actually handle.
Expand Down
10 changes: 10 additions & 0 deletions src/providers/wms/qgswmssourceselect.h
Expand Up @@ -178,13 +178,23 @@ class QgsWMSSourceSelect : public QgsAbstractDataSourceWidget, private Ui::QgsWM
void enableLayersForCrs( QTreeWidgetItem *item );

void collectSelectedLayers( QStringList &layers, QStringList &styles, QStringList &titles );

/**
* Collects the available dimensions from the WMS layers and adds them
* to the passed \a uri.
*/
void collectDimensions( QStringList &layers, QgsDataSourceUri &uri );

QString selectedImageEncoding();

QList<QTreeWidgetItem *> mCurrentSelection;
QTableWidgetItem *mCurrentTileset = nullptr;

QList<QgsWmtsTileLayer> mTileLayers;

//! Stores all the layers properties from the service capabilities.
QVector<QgsWmsLayerProperty> mLayerProperties;

private slots:
void btnSearch_clicked();
void btnAddWMS_clicked();
Expand Down

0 comments on commit e86faa4

Please sign in to comment.