diff --git a/python/core/auto_generated/qgsmaplayertemporalproperties.sip.in b/python/core/auto_generated/qgsmaplayertemporalproperties.sip.in index 2c76a37159f..f8afb11112c 100644 --- a/python/core/auto_generated/qgsmaplayertemporalproperties.sip.in +++ b/python/core/auto_generated/qgsmaplayertemporalproperties.sip.in @@ -57,26 +57,6 @@ Writes the properties to a DOM ``element``, to be used later with readXml(). Reads temporal properties from a DOM ``element`` previously written by writeXml(). .. seealso:: :py:func:`writeXml` -%End - - enum TemporalSource - { - Layer, - Project - }; - - TemporalSource temporalSource() const; -%Docstring -Returns the temporal properties temporal range source, can be layer or project. - -.. seealso:: :py:func:`setTemporalSource` -%End - - void setTemporalSource( TemporalSource source ); -%Docstring -Sets the temporal properties temporal range ``source``. - -.. seealso:: :py:func:`temporalSource` %End virtual bool isVisibleInTemporalRange( const QgsDateTimeRange &range ) const; diff --git a/python/core/auto_generated/raster/qgsrasterdataprovidertemporalcapabilities.sip.in b/python/core/auto_generated/raster/qgsrasterdataprovidertemporalcapabilities.sip.in index cdc1967c6d7..64a9646adc4 100644 --- a/python/core/auto_generated/raster/qgsrasterdataprovidertemporalcapabilities.sip.in +++ b/python/core/auto_generated/raster/qgsrasterdataprovidertemporalcapabilities.sip.in @@ -90,24 +90,6 @@ extent of datetime values available for reference temporal ranges from the provi %Docstring Returns the requested temporal range. Intended to be used by the provider in fetching data. -%End - - void setEnableTime( bool enabled ); -%Docstring -Sets the time enabled status. -This enables whether time part in the temporal range should be -used when updated the temporal range of these capabilities. - -This is useful in some temporal layers who use dates only. - -.. seealso:: :py:func:`isTimeEnabled` -%End - - bool isTimeEnabled() const; -%Docstring -Returns the temporal property status. - -.. seealso:: :py:func:`setEnableTime` %End }; diff --git a/src/app/qgslayertreeviewtemporalindicator.cpp b/src/app/qgslayertreeviewtemporalindicator.cpp index b616de74166..8695ccabaf0 100644 --- a/src/app/qgslayertreeviewtemporalindicator.cpp +++ b/src/app/qgslayertreeviewtemporalindicator.cpp @@ -31,10 +31,10 @@ QgsLayerTreeViewTemporalIndicatorProvider::QgsLayerTreeViewTemporalIndicatorProv void QgsLayerTreeViewTemporalIndicatorProvider::connectSignals( QgsMapLayer *layer ) { - if ( !layer->temporalProperties() ) + if ( !layer ) return; - connect( layer->temporalProperties(), &QgsMapLayerTemporalProperties::changed, this, [ this, layer ]( ) { this->onLayerChanged( layer ); } ); + connect( layer, &QgsMapLayer::dataSourceChanged, this, [ this, layer ]( ) { this->onLayerChanged( layer ); } ); } void QgsLayerTreeViewTemporalIndicatorProvider::onIndicatorClicked( const QModelIndex &index ) @@ -72,28 +72,37 @@ bool QgsLayerTreeViewTemporalIndicatorProvider::acceptLayer( QgsMapLayer *layer QString QgsLayerTreeViewTemporalIndicatorProvider::iconName( QgsMapLayer *layer ) { - switch ( layer->temporalProperties()->temporalSource() ) - { - case QgsMapLayerTemporalProperties::TemporalSource::Project: - return QStringLiteral( "/mIndicatorTimeFromProject.svg" ); + QgsDataSourceUri uri; - case QgsMapLayerTemporalProperties::TemporalSource::Layer: - return QStringLiteral( "/mIndicatorTemporal.svg" ); - } + if ( layer->dataProvider() ) + uri.setEncodedUri( layer->dataProvider()->dataSourceUri() ); + + const QString temporalSource = uri.param( QStringLiteral( "temporalSource" ) ); + + if ( temporalSource == QString( "project" ) ) + return QStringLiteral( "/mIndicatorTimeFromProject.svg" ); + + if ( temporalSource == QString( "provider" ) ) + return QStringLiteral( "/mIndicatorTemporal.svg" ); return QString(); } QString QgsLayerTreeViewTemporalIndicatorProvider::tooltipText( QgsMapLayer *layer ) { - switch ( layer->temporalProperties()->temporalSource() ) - { - case QgsMapLayerTemporalProperties::TemporalSource::Project: - return tr( "Temporal layer, currently using project's time range " ); + QgsDataSourceUri uri; + + if ( layer->dataProvider() ) + uri.setEncodedUri( layer->dataProvider()->dataSourceUri() ); + + const QString temporalSource = uri.param( QStringLiteral( "temporalSource" ) ); + + if ( temporalSource == QString( "project" ) ) + return tr( "Temporal layer, currently using project's time range " ); + + if ( temporalSource == QString( "provider" ) ) + return tr( "Temporal layer " ); - case QgsMapLayerTemporalProperties::TemporalSource::Layer: - return tr( "Temporal layer " ); - } return QString(); } diff --git a/src/core/qgsmaplayertemporalproperties.cpp b/src/core/qgsmaplayertemporalproperties.cpp index 79daa6836b9..158deaae1f6 100644 --- a/src/core/qgsmaplayertemporalproperties.cpp +++ b/src/core/qgsmaplayertemporalproperties.cpp @@ -22,21 +22,7 @@ QgsMapLayerTemporalProperties::QgsMapLayerTemporalProperties( QObject *parent, b { } -void QgsMapLayerTemporalProperties::setTemporalSource( QgsMapLayerTemporalProperties::TemporalSource source ) -{ - if ( mSource != source ) - { - mSource = source; - emit changed(); - } -} - bool QgsMapLayerTemporalProperties::isVisibleInTemporalRange( const QgsDateTimeRange & ) const { return true; } - -QgsMapLayerTemporalProperties::TemporalSource QgsMapLayerTemporalProperties::temporalSource() const -{ - return mSource; -} diff --git a/src/core/qgsmaplayertemporalproperties.h b/src/core/qgsmaplayertemporalproperties.h index 63f67c0781d..5bda7f9e8d0 100644 --- a/src/core/qgsmaplayertemporalproperties.h +++ b/src/core/qgsmaplayertemporalproperties.h @@ -79,29 +79,6 @@ class CORE_EXPORT QgsMapLayerTemporalProperties : public QgsTemporalProperty */ virtual bool readXml( const QDomElement &element, const QgsReadWriteContext &context ) = 0; - /** - * Source of the temporal range of these properties. - */ - enum TemporalSource - { - Layer = 0, //!< Layer's temporal range has been manually defined - Project = 1 //!< Layer should inherit its temporal range from the project's time settings - }; - - /** - * Returns the temporal properties temporal range source, can be layer or project. - * - *\see setTemporalSource() - **/ - TemporalSource temporalSource() const; - - /** - * Sets the temporal properties temporal range \a source. - * - *\see temporalSource() - **/ - void setTemporalSource( TemporalSource source ); - /** * Returns TRUE if the layer should be visible and rendered for the specified time \a range. */ @@ -113,11 +90,6 @@ class CORE_EXPORT QgsMapLayerTemporalProperties : public QgsTemporalProperty */ virtual void setDefaultsFromDataProviderTemporalCapabilities( const QgsDataProviderTemporalCapabilities *capabilities ) = 0; - private: - - //! Source of the properties temporal range - TemporalSource mSource = Layer; - }; #endif // QGSMAPLAYERTEMPORALPROPERTIES_H diff --git a/src/core/raster/qgsrasterdataprovidertemporalcapabilities.cpp b/src/core/raster/qgsrasterdataprovidertemporalcapabilities.cpp index 1b230f261ab..96ab0c7f8d6 100644 --- a/src/core/raster/qgsrasterdataprovidertemporalcapabilities.cpp +++ b/src/core/raster/qgsrasterdataprovidertemporalcapabilities.cpp @@ -35,16 +35,6 @@ const QgsDateTimeRange &QgsRasterDataProviderTemporalCapabilities::availableTemp return mAvailableTemporalRange; } -void QgsRasterDataProviderTemporalCapabilities::setEnableTime( bool enabled ) -{ - mEnableTime = enabled; -} - -bool QgsRasterDataProviderTemporalCapabilities::isTimeEnabled() const -{ - return mEnableTime; -} - void QgsRasterDataProviderTemporalCapabilities::setAvailableReferenceTemporalRange( const QgsDateTimeRange &dateTimeRange ) { if ( !hasTemporalCapabilities() ) diff --git a/src/core/raster/qgsrasterdataprovidertemporalcapabilities.h b/src/core/raster/qgsrasterdataprovidertemporalcapabilities.h index 6adeb73a5cf..c7692940e3d 100644 --- a/src/core/raster/qgsrasterdataprovidertemporalcapabilities.h +++ b/src/core/raster/qgsrasterdataprovidertemporalcapabilities.h @@ -108,24 +108,6 @@ class CORE_EXPORT QgsRasterDataProviderTemporalCapabilities : public QgsDataProv */ const QgsDateTimeRange &requestedTemporalRange() const; - /** - * Sets the time enabled status. - * This enables whether time part in the temporal range should be - * used when updated the temporal range of these capabilities. - * - * This is useful in some temporal layers who use dates only. - * - * \see isTimeEnabled() - */ - void setEnableTime( bool enabled ); - - /** - * Returns the temporal property status. - * - * \see setEnableTime() - */ - bool isTimeEnabled() const; - private: /** @@ -150,17 +132,6 @@ class CORE_EXPORT QgsRasterDataProviderTemporalCapabilities : public QgsDataProv */ QgsDateTimeRange mAvailableTemporalRange; - /** - * If the stored time part in temporal ranges should be taked into account. - * - * This is to enable data providers that use dates only and no datetime, to - * configure their temporal properties to consider their state. - * - * eg. some WMS-T providers only require date with "YYYY-MM-DD" format with - * no time part. - */ - bool mEnableTime = true; - //! Represents the requested temporal range. QgsDateTimeRange mRequestedRange; diff --git a/src/core/raster/qgsrasterlayertemporalproperties.cpp b/src/core/raster/qgsrasterlayertemporalproperties.cpp index 3f2274fb840..4ea66208225 100644 --- a/src/core/raster/qgsrasterlayertemporalproperties.cpp +++ b/src/core/raster/qgsrasterlayertemporalproperties.cpp @@ -85,13 +85,6 @@ bool QgsRasterLayerTemporalProperties::readXml( const QDomElement &element, cons mMode = static_cast< TemporalMode >( temporalNode.attribute( QStringLiteral( "mode" ), QStringLiteral( "0" ) ). toInt() ); mIntervalHandlingMethod = static_cast< QgsRasterDataProviderTemporalCapabilities::IntervalHandlingMethod >( temporalNode.attribute( QStringLiteral( "fetchMode" ), QStringLiteral( "0" ) ). toInt() ); - int sourceIndex = temporalNode.attribute( QStringLiteral( "source" ), QStringLiteral( "0" ) ).toInt(); - - if ( sourceIndex == 0 ) - setTemporalSource( TemporalSource::Layer ); - else - setTemporalSource( TemporalSource::Project ); - QDomNode rangeElement = temporalNode.namedItem( QStringLiteral( "fixedRange" ) ); QDomNode begin = rangeElement.namedItem( QStringLiteral( "start" ) ); @@ -115,7 +108,6 @@ QDomElement QgsRasterLayerTemporalProperties::writeXml( QDomElement &element, QD QDomElement temporalElement = document.createElement( QStringLiteral( "temporal" ) ); temporalElement.setAttribute( QStringLiteral( "enabled" ), isActive() ? QStringLiteral( "1" ) : QStringLiteral( "0" ) ); temporalElement.setAttribute( QStringLiteral( "mode" ), QString::number( mMode ) ); - temporalElement.setAttribute( QStringLiteral( "source" ), QString::number( temporalSource() ) ); temporalElement.setAttribute( QStringLiteral( "fetchMode" ), QString::number( mIntervalHandlingMethod ) ); QDomElement rangeElement = document.createElement( QStringLiteral( "fixedRange" ) ); diff --git a/src/gui/raster/qgsrasterlayerproperties.cpp b/src/gui/raster/qgsrasterlayerproperties.cpp index b338b60b515..c444b4b11e3 100644 --- a/src/gui/raster/qgsrasterlayerproperties.cpp +++ b/src/gui/raster/qgsrasterlayerproperties.cpp @@ -1165,15 +1165,19 @@ void QgsRasterLayerProperties::updateSourceStaticTime() mRasterLayer->dataProvider() && mRasterLayer->dataProvider()->temporalCapabilities()->hasTemporalCapabilities() ) { - 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( QStringLiteral( "time" ) ); uri.setParam( QStringLiteral( "time" ), time ); - mRasterLayer->temporalProperties()->setTemporalSource( - QgsRasterLayerTemporalProperties::Layer ); + + uri.removeParam( QStringLiteral( "temporalSource" ) ); + uri.setParam( QStringLiteral( "temporalSource" ), QLatin1String( "provider" ) ); } if ( mProjectTemporalRange->isChecked() ) @@ -1189,8 +1193,9 @@ void QgsRasterLayerProperties::updateSourceStaticTime() uri.removeParam( QStringLiteral( "time" ) ); uri.setParam( QStringLiteral( "time" ), time ); - mRasterLayer->temporalProperties()->setTemporalSource( - QgsRasterLayerTemporalProperties::Project ); + + uri.removeParam( QStringLiteral( "temporalSource" ) ); + uri.setParam( QStringLiteral( "temporalSource" ), QLatin1String( "project" ) ); } } @@ -1200,11 +1205,14 @@ void QgsRasterLayerProperties::updateSourceStaticTime() uri.removeParam( QStringLiteral( "reference_time" ) ); uri.setParam( QStringLiteral( "reference_time" ), reference_time ); } - if ( mRasterLayer->dataProvider()->temporalCapabilities() ) - mRasterLayer->dataProvider()->temporalCapabilities()->setEnableTime( - !mDisableTime->isChecked() ); + const QLatin1String enableTime = mDisableTime->isChecked() ? QLatin1String( "no" ) : QLatin1String( "yes" ); + + uri.removeParam( QStringLiteral( "enableTime" ) ); + uri.setParam( QStringLiteral( "enableTime" ), enableTime ); mRasterLayer->dataProvider()->setDataSourceUri( uri.encodedUri() ); + mRasterLayer->setDataSource( mRasterLayer->dataProvider()->dataSourceUri(), mRasterLayer->name(), mRasterLayer->providerType(), QgsDataProvider::ProviderOptions() ); + mRasterLayer->temporalProperties()->setIntervalHandlingMethod( static_cast< QgsRasterDataProviderTemporalCapabilities::IntervalHandlingMethod >( mFetchModeComboBox->currentData().toInt() ) ); @@ -1227,7 +1235,9 @@ void QgsRasterLayerProperties::setSourceStaticTimeState() const QgsDateTimeRange availableProviderRange = mRasterLayer->dataProvider()->temporalCapabilities()->availableTemporalRange(); const QgsDateTimeRange availableReferenceRange = mRasterLayer->dataProvider()->temporalCapabilities()->availableReferenceTemporalRange(); - const QgsDataSourceUri uri( mRasterLayer->dataProvider()->dataSourceUri() ); + QgsDataSourceUri uri; + const QString uriString = mRasterLayer->dataProvider()->dataSourceUri() ; + uri.setEncodedUri( uriString ); // setup maximum extents for widgets, based on provider's capabilities if ( availableProviderRange.begin().isValid() && availableProviderRange.end().isValid() ) @@ -1271,11 +1281,15 @@ void QgsRasterLayerProperties::setSourceStaticTimeState() mFetchModeComboBox->addItem( tr( "Match to End of Range" ), QgsRasterDataProviderTemporalCapabilities::MatchExactUsingEndOfRange ); mFetchModeComboBox->setCurrentIndex( mFetchModeComboBox->findData( mRasterLayer->temporalProperties()->intervalHandlingMethod() ) ); - // TODO -- this should not be in the layer properties -- like the other settings, they need to be stored in the provider's URI - if ( mRasterLayer->temporalProperties()->temporalSource() == QgsRasterLayerTemporalProperties::Layer ) + const QString temporalSource = uri.param( QStringLiteral( "temporalSource" ) ); + const QString enableTime = uri.param( QStringLiteral( "enableTime" ) ); + + if ( temporalSource == QLatin1String( "provider" ) ) mStaticTemporalRange->setChecked( true ); - else if ( mRasterLayer->temporalProperties()->temporalSource() == QgsRasterLayerTemporalProperties::Project ) + else if ( temporalSource == QLatin1String( "project" ) ) mProjectTemporalRange->setChecked( true ); + + mDisableTime->setChecked( enableTime == QLatin1String( "no" ) ); } } diff --git a/src/providers/wms/qgswmscapabilities.cpp b/src/providers/wms/qgswmscapabilities.cpp index 8c8bfb908b1..9fb5fb3c897 100644 --- a/src/providers/wms/qgswmscapabilities.cpp +++ b/src/providers/wms/qgswmscapabilities.cpp @@ -82,10 +82,10 @@ bool QgsWmsSettings::parseUri( const QString &uriString ) return true; } - if ( !mIsTemporal && uri.param( QStringLiteral( "type" ) ) == QLatin1String( "wmst" ) ) + if ( uri.param( QStringLiteral( "type" ) ) == QLatin1String( "wmst" ) ) { mIsTemporal = true; - mTemporalExtent = uri.param( QStringLiteral( "time" ) ); + mTemporalExtent = uri.param( QStringLiteral( "timeDimensionExtent" ) ); mTimeDimensionExtent = parseTemporalExtent( mTemporalExtent ); if ( mTimeDimensionExtent.datesResolutionList.first().dates.dateTimes.size() > 0 ) @@ -100,9 +100,9 @@ bool QgsWmsSettings::parseUri( const QString &uriString ) mDateTimes = dateTimesFromExtent( mTimeDimensionExtent ); - if ( uri.param( QStringLiteral( "reference_time" ) ) != QString() ) + if ( uri.param( QStringLiteral( "referenceTimeDimensionExtent" ) ) != QString() ) { - QString referenceExtent = uri.param( QStringLiteral( "reference_time" ) ); + QString referenceExtent = uri.param( QStringLiteral( "referenceTimeDimensionExtent" ) ); mReferenceTimeDimensionExtent = parseTemporalExtent( referenceExtent ); diff --git a/src/providers/wms/qgswmsdataitems.cpp b/src/providers/wms/qgswmsdataitems.cpp index 02a3e13ec72..aa8058f5856 100644 --- a/src/providers/wms/qgswmsdataitems.cpp +++ b/src/providers/wms/qgswmsdataitems.cpp @@ -371,14 +371,20 @@ QString QgsWMSLayerItem::createUri() // 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 ( !( mDataSourceUri.param( QLatin1String( "type" ) ) == QLatin1String( "wmst" ) ) ) mDataSourceUri.setParam( QLatin1String( "type" ), QLatin1String( "wmst" ) ); - mDataSourceUri.setParam( dimension.name, dimension.extent ); + mDataSourceUri.setParam( name, dimension.extent ); } } - // Default value for temporal interval requests - // mDataSourceUri.setParam( QStringLiteral( "timeInterval" ), QLatin1String( "no" ) ); + // WMS-T defaults settings + if ( mDataSourceUri.param( QLatin1String( "type" ) ) == QLatin1String( "wmst" ) ) + { + mDataSourceUri.setParam( QLatin1String( "temporalSource" ), QLatin1String( "provider" ) ); + mDataSourceUri.setParam( QLatin1String( "enableTime" ), QLatin1String( "yes" ) ); + } QString format; // get first supported by qt and server diff --git a/src/providers/wms/qgswmsprovider.cpp b/src/providers/wms/qgswmsprovider.cpp index 60361c0da3f..7e1b48aaf0a 100644 --- a/src/providers/wms/qgswmsprovider.cpp +++ b/src/providers/wms/qgswmsprovider.cpp @@ -1116,7 +1116,7 @@ void QgsWmsProvider::addWmstParameters( QUrlQuery &query ) } } - if ( !temporalCapabilities()->isTimeEnabled() ) + if ( uri.param( QStringLiteral( "enableTime" ) ) == QLatin1String( "no" ) ) format = "yyyy-MM-dd"; if ( range.begin().isValid() && range.end().isValid() ) diff --git a/tests/src/core/testqgsrasterlayertemporalproperties.cpp b/tests/src/core/testqgsrasterlayertemporalproperties.cpp index d9f453c48b5..3ca69ed0dcd 100644 --- a/tests/src/core/testqgsrasterlayertemporalproperties.cpp +++ b/tests/src/core/testqgsrasterlayertemporalproperties.cpp @@ -40,7 +40,6 @@ class TestQgsRasterLayerTemporalProperties : public QObject void checkSettingTemporalRange(); void testReadWrite(); - void testChangedSignal(); void testVisibleInTimeRange(); }; @@ -133,21 +132,6 @@ void TestQgsRasterLayerTemporalProperties::testReadWrite() } -void TestQgsRasterLayerTemporalProperties::testChangedSignal() -{ - QgsRasterLayerTemporalProperties temporalProperties; - QCOMPARE( temporalProperties.temporalSource(), QgsMapLayerTemporalProperties::TemporalSource::Layer ); - QSignalSpy spy( &temporalProperties, &QgsRasterLayerTemporalProperties::changed ); - - temporalProperties.setTemporalSource( QgsMapLayerTemporalProperties::TemporalSource::Layer ); - QCOMPARE( spy.count(), 0 ); - temporalProperties.setTemporalSource( QgsMapLayerTemporalProperties::TemporalSource::Project ); - QCOMPARE( spy.count(), 1 ); - - temporalProperties.setIsActive( true ); - QCOMPARE( spy.count(), 2 ); -} - void TestQgsRasterLayerTemporalProperties::testVisibleInTimeRange() { QgsRasterLayerTemporalProperties props;