mirror of
https://github.com/qgis/QGIS.git
synced 2025-12-24 00:05:18 -05:00
removed static wmst settings in provider temporal capabilities
This commit is contained in:
parent
8b01b55fb2
commit
b399e8a60b
@ -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;
|
||||
|
||||
@ -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
|
||||
|
||||
};
|
||||
|
||||
@ -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( "<b>Temporal layer, currently using project's time range </b>" );
|
||||
QgsDataSourceUri uri;
|
||||
|
||||
if ( layer->dataProvider() )
|
||||
uri.setEncodedUri( layer->dataProvider()->dataSourceUri() );
|
||||
|
||||
const QString temporalSource = uri.param( QStringLiteral( "temporalSource" ) );
|
||||
|
||||
if ( temporalSource == QString( "project" ) )
|
||||
return tr( "<b>Temporal layer, currently using project's time range </b>" );
|
||||
|
||||
if ( temporalSource == QString( "provider" ) )
|
||||
return tr( "<b>Temporal layer </b>" );
|
||||
|
||||
case QgsMapLayerTemporalProperties::TemporalSource::Layer:
|
||||
return tr( "<b>Temporal layer </b>" );
|
||||
}
|
||||
return QString();
|
||||
}
|
||||
|
||||
|
||||
@ -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;
|
||||
}
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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() )
|
||||
|
||||
@ -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;
|
||||
|
||||
|
||||
@ -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" ) );
|
||||
|
||||
@ -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" ) );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -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 );
|
||||
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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() )
|
||||
|
||||
@ -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;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user