Skip to content

Commit

Permalink
changed parameters setting in the data source uri
Browse files Browse the repository at this point in the history
  • Loading branch information
Samweli authored and nyalldawson committed Mar 29, 2020
1 parent 76fcdf1 commit 89fd8d4
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 17 deletions.
28 changes: 18 additions & 10 deletions src/gui/raster/qgsrasterlayerproperties.cpp
Expand Up @@ -1164,14 +1164,18 @@ void QgsRasterLayerProperties::updateSourceStaticTime()
mRasterLayer->dataProvider() &&
mRasterLayer->temporalProperties() )
{
QgsDataSourceUri uri( mRasterLayer->dataProvider()->dataSourceUri() );
QgsDataSourceUri uri;
QString uriString = mRasterLayer->dataProvider()->dataSourceUri();
uri.setEncodedUri( uriString );

if ( mStaticTemporalRange->isChecked() )
{
QString time = mStartStaticDateTimeEdit->dateTime().toString( Qt::ISODateWithMs ) + "/" +
mEndStaticDateTimeEdit->dateTime().toString( Qt::ISODateWithMs );
uri.removeParam( "time" );
uri.setParam( QLatin1String( "time" ), time );
mRasterLayer->temporalProperties()->setTemporalSource(
QgsRasterLayerTemporalProperties::Layer );
QgsRasterLayerTemporalProperties::Layer );
}

if ( mProjectTemporalRange->isChecked() )
Expand All @@ -1185,22 +1189,24 @@ void QgsRasterLayerProperties::updateSourceStaticTime()
QString time = range.begin().toString( Qt::ISODateWithMs ) + "/" +
range.end().toString( Qt::ISODateWithMs );

uri.removeParam( "time" );
uri.setParam( QLatin1String( "time" ), time );
mRasterLayer->temporalProperties()->setTemporalSource(
QgsRasterLayerTemporalProperties::Project );
QgsRasterLayerTemporalProperties::Project );
}
}

if ( mReferenceTime->isChecked() )
{
QString reference_time = mReferenceDateTimeEdit->dateTime().toString( Qt::ISODateWithMs );
uri.removeParam( "reference_time" );
uri.setParam( QLatin1String( "reference_time" ), reference_time );
}
if ( mRasterLayer->dataProvider()->temporalCapabilities() )
mRasterLayer->dataProvider()->temporalCapabilities()->setEnableTime(
!mDisableTime->isChecked() );

mRasterLayer->dataProvider()->setDataSourceUri( uri.uri() );
mRasterLayer->dataProvider()->setDataSourceUri( uri.encodedUri() );

mRasterLayer->temporalProperties()->setIntervalHandlingMethod( static_cast< QgsRasterDataProviderTemporalCapabilities::IntervalHandlingMethod >(
mFetchModeComboBox->currentData().toInt() ) );
Expand All @@ -1222,7 +1228,9 @@ void QgsRasterLayerProperties::setSourceStaticTimeState()
{
QgsDateTimeRange layerRange = mRasterLayer->temporalProperties()->fixedTemporalRange();
QgsDateTimeRange layerReferenceRange = mRasterLayer->temporalProperties()->fixedReferenceTemporalRange();
QgsDataSourceUri uri( mRasterLayer->dataProvider()->dataSourceUri() );
QString uriString = mRasterLayer->dataProvider()->dataSourceUri();
QgsDataSourceUri uri;
uri.setEncodedUri( uriString );

QString time = uri.param( QLatin1String( "time" ) );
QString referenceTime = uri.param( QLatin1String( "reference_time" ) );
Expand All @@ -1238,9 +1246,9 @@ void QgsRasterLayerProperties::setSourceStaticTimeState()
}
if ( layerReferenceRange.begin().isValid() && layerReferenceRange.end().isValid() )
{
mReferenceDateTimeEdit->setDateTimeRange( layerReferenceRange.begin(),
layerReferenceRange.end() );
mReferenceDateTimeEdit->setDateTime( layerReferenceRange.begin() );
mReferenceDateTimeEdit->setDateTimeRange( layerReferenceRange.begin(),
layerReferenceRange.end() );
mReferenceDateTimeEdit->setDateTime( layerReferenceRange.begin() );
}

if ( time != QLatin1String( "" ) )
Expand All @@ -1267,9 +1275,9 @@ void QgsRasterLayerProperties::setSourceStaticTimeState()
mFetchModeComboBox->setCurrentIndex( mFetchModeComboBox->findData( mRasterLayer->temporalProperties()->intervalHandlingMethod() ) );

if ( mRasterLayer->temporalProperties()->temporalSource() == QgsRasterLayerTemporalProperties::Layer )
mStaticTemporalRange->setChecked( true );
mStaticTemporalRange->setChecked( true );
else if ( mRasterLayer->temporalProperties()->temporalSource() == QgsRasterLayerTemporalProperties::Project )
mProjectTemporalRange->setChecked( true );
mProjectTemporalRange->setChecked( true );
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/providers/wms/qgswmscapabilities.cpp
Expand Up @@ -82,7 +82,7 @@ bool QgsWmsSettings::parseUri( const QString &uriString )
return true;
}

if ( uri.param( QStringLiteral( "type" ) ) == QLatin1String( "wmst" ) )
if ( !mIsTemporal && uri.param( QStringLiteral( "type" ) ) == QLatin1String( "wmst" ) )
{
mIsTemporal = true;
mTemporalExtent = uri.param( QStringLiteral( "time" ) );
Expand Down
5 changes: 4 additions & 1 deletion src/providers/wms/qgswmsdataitems.cpp
Expand Up @@ -362,7 +362,7 @@ QString QgsWMSLayerItem::createUri()

// Number of styles must match number of layers
mDataSourceUri.setParam( QStringLiteral( "layers" ), mLayerProperty.name );
QString style = !mLayerProperty.style.isEmpty() ? mLayerProperty.style.at( 0 ).name : QString();
QString style = !mLayerProperty.style.isEmpty() ? mLayerProperty.style.at( 0 ).name : QLatin1String( "" );
mDataSourceUri.setParam( QStringLiteral( "styles" ), style );

// Check for layer dimensions
Expand All @@ -377,6 +377,9 @@ QString QgsWMSLayerItem::createUri()
}
}

// Default value for temporal interval requests
// mDataSourceUri.setParam( QStringLiteral( "timeInterval" ), QLatin1String( "no" ) );

QString format;
// get first supported by qt and server
QVector<QgsWmsSupportedFormat> formats( QgsWmsProvider::supportedFormats() );
Expand Down
11 changes: 6 additions & 5 deletions src/providers/wms/qgswmsprovider.cpp
Expand Up @@ -223,7 +223,6 @@ QgsWmsProvider *QgsWmsProvider::clone() const
QgsDataProvider::ProviderOptions options;
QgsWmsProvider *provider = new QgsWmsProvider( dataSourceUri(), options, mCaps.isValid() ? &mCaps : nullptr );
provider->copyBaseSettings( *this );
provider->setDataSourceUri( dataSourceUri() );
return provider;
}

Expand Down Expand Up @@ -1084,7 +1083,8 @@ void QgsWmsProvider::addWmstParameters( QUrlQuery &query )
{
QgsDateTimeRange range = temporalCapabilities()->requestedTemporalRange();
QString format = "yyyy-MM-ddThh:mm:ssZ";
QgsDataSourceUri uri( dataSourceUri() );
QgsDataSourceUri uri;
uri.setEncodedUri( dataSourceUri() );

if ( !range.isInfinite() )
{
Expand All @@ -1111,7 +1111,8 @@ void QgsWmsProvider::addWmstParameters( QUrlQuery &query )
QDateTime start = QDateTime::fromString( timeParts.at( 0 ), Qt::ISODateWithMs );
QDateTime end = QDateTime::fromString( timeParts.at( 1 ), Qt::ISODateWithMs );

range = QgsDateTimeRange( start, end );
if ( start == end )
range = QgsDateTimeRange( start, end );
}
}

Expand Down Expand Up @@ -1143,8 +1144,8 @@ void QgsWmsProvider::addWmstParameters( QUrlQuery &query )

if ( dateTime.isValid() )
{
setQueryItem( query, QStringLiteral( "DIM_REFERENCE_TIME" ),
dateTime.toString( format ) );
setQueryItem( query, QStringLiteral( "DIM_REFERENCE_TIME" ),
dateTime.toString( format ) );
}
}
}
Expand Down

0 comments on commit 89fd8d4

Please sign in to comment.