Skip to content
Permalink
Browse files

Don't inherit QgsTemporalProperty for QgsDataProviderTemporalCapabili…

…ties

The QgsTemporalProperty interface has members which are geared more to
user-setable temporal properties (e.g. "isActive()"/"setIsActive()". Instead, use
more explicit "hasTemporalCapabilities()" API in
QgsDataProviderTemporalCapabilities to make it immediately clear
what this flag means for data provider temporal capabilities
  • Loading branch information
nyalldawson committed Mar 5, 2020
1 parent ce06505 commit 9959a22e5447eb59f0551c09256c22ef8fc50781
@@ -11,7 +11,7 @@



class QgsDataProviderTemporalCapabilities : QgsTemporalProperty
class QgsDataProviderTemporalCapabilities
{
%Docstring
Base class for handling properties relating to a data provider's temporal capabilities.
@@ -24,14 +24,32 @@ Base class for handling properties relating to a data provider's temporal capabi
%End
public:

QgsDataProviderTemporalCapabilities( bool enabled = false );
QgsDataProviderTemporalCapabilities( bool available = false );
%Docstring
Constructor for QgsDataProviderTemporalCapabilities.

The ``enabled`` argument specifies whether the data provider has temporal capabilities.
The ``available`` argument specifies whether the data provider has temporal capabilities. Set to
``True`` to indicate that the provider has temporal capabilities available for use.
%End

virtual ~QgsDataProviderTemporalCapabilities();

bool hasTemporalCapabilities() const;
%Docstring
Returns ``True`` if the provider has temporal capabilities available.

.. seealso:: :py:func:`setHasTemporalCapabilities`
%End

void setHasTemporalCapabilities( bool available );
%Docstring
Sets whether the provider has temporal capabilities ``available``.

Set ``available`` to ``True`` to indicate that the provider has temporal capabilities available for use.

.. seealso:: :py:func:`hasTemporalCapabilities`
%End

};

/************************************************************************
@@ -17,8 +17,7 @@

#include "qgsdataprovidertemporalcapabilities.h"

QgsDataProviderTemporalCapabilities::QgsDataProviderTemporalCapabilities( bool enabled )
: QgsTemporalProperty( enabled )
QgsDataProviderTemporalCapabilities::QgsDataProviderTemporalCapabilities( bool available )
: mHasTemporalCapabilities( available )
{
}

@@ -31,18 +31,39 @@
* \since QGIS 3.14
*/

class CORE_EXPORT QgsDataProviderTemporalCapabilities : public QgsTemporalProperty
class CORE_EXPORT QgsDataProviderTemporalCapabilities
{
public:

/**
* Constructor for QgsDataProviderTemporalCapabilities.
*
* The \a enabled argument specifies whether the data provider has temporal capabilities.
* The \a available argument specifies whether the data provider has temporal capabilities. Set to
* TRUE to indicate that the provider has temporal capabilities available for use.
*/
QgsDataProviderTemporalCapabilities( bool enabled = false );
QgsDataProviderTemporalCapabilities( bool available = false );

virtual ~QgsDataProviderTemporalCapabilities() = default;

/**
* Returns TRUE if the provider has temporal capabilities available.
*
* \see setHasTemporalCapabilities()
*/
bool hasTemporalCapabilities() const { return mHasTemporalCapabilities; }

/**
* Sets whether the provider has temporal capabilities \a available.
*
* Set \a available to TRUE to indicate that the provider has temporal capabilities available for use.
*
* \see hasTemporalCapabilities()
*/
void setHasTemporalCapabilities( bool available ) { mHasTemporalCapabilities = available; }

private:

bool mHasTemporalCapabilities = false;
};

#endif // QGSDATAPROVIDERTEMPORALCAPABILITIES_H
@@ -525,11 +525,7 @@ void QgsRasterDataProvider::copyBaseSettings( const QgsRasterDataProvider &other
// copy temporal properties
if ( mTemporalCapabilities && other.mTemporalCapabilities )
{
mTemporalCapabilities->setIsActive( other.mTemporalCapabilities->isActive() );
mTemporalCapabilities->setFixedTemporalRange( other.mTemporalCapabilities->fixedTemporalRange() );
mTemporalCapabilities->setEnableTime( other.mTemporalCapabilities->isTimeEnabled() );
mTemporalCapabilities->setReferenceEnable( other.mTemporalCapabilities->isReferenceEnable() );
mTemporalCapabilities->setFixedReferenceTemporalRange( other.mTemporalCapabilities->fixedReferenceTemporalRange() );
*mTemporalCapabilities = *other.mTemporalCapabilities;
}
}

@@ -24,8 +24,8 @@ QgsRasterDataProviderTemporalCapabilities::QgsRasterDataProviderTemporalCapabili

void QgsRasterDataProviderTemporalCapabilities::setFixedTemporalRange( const QgsDateTimeRange &dateTimeRange )
{
if ( !isActive() )
setIsActive( true );
if ( !hasTemporalCapabilities() )
setHasTemporalCapabilities( true );

mFixedRange = dateTimeRange;
}
@@ -47,8 +47,8 @@ bool QgsRasterDataProviderTemporalCapabilities::isTimeEnabled() const

void QgsRasterDataProviderTemporalCapabilities::setFixedReferenceTemporalRange( const QgsDateTimeRange &dateTimeRange )
{
if ( !isActive() )
setIsActive( true );
if ( !hasTemporalCapabilities() )
setHasTemporalCapabilities( true );

mFixedReferenceRange = dateTimeRange;
}
@@ -154,13 +154,12 @@ QgsWmsProvider::QgsWmsProvider( QString const &uri, const ProviderOptions &optio
// Setup temporal properties for layers in WMS-T
if ( mSettings.mIsTemporal )
{
if ( temporalCapabilities() )
Q_ASSERT_X( temporalCapabilities(), "QgsWmsProvider::QgsWmsProvider()", "Data provider temporal capabilities object does not exist" );
temporalCapabilities()->setHasTemporalCapabilities( true );
temporalCapabilities()->setFixedTemporalRange( mSettings.mFixedRange );
if ( mSettings.mIsBiTemporal )
{
temporalCapabilities()->setFixedTemporalRange( mSettings.mFixedRange );
if ( mSettings.mIsBiTemporal )
{
temporalCapabilities()->setFixedReferenceTemporalRange( mSettings.mFixedReferenceRange );
}
temporalCapabilities()->setFixedReferenceTemporalRange( mSettings.mFixedReferenceRange );
}
}
}
@@ -1046,7 +1045,7 @@ QUrl QgsWmsProvider::createRequestUrlWMS( const QgsRectangle &viewExtent, int pi

// For WMS-T layers
if ( temporalCapabilities() &&
temporalCapabilities()->isActive() )
temporalCapabilities()->hasTemporalCapabilities() )
{
addWmstParameters( query );
}

0 comments on commit 9959a22

Please sign in to comment.
You can’t perform that action at this time.