35 return range.isInfinite() || mFixedRange.isInfinite() || mFixedRange.overlaps( range );
45 QgsRasterLayer *rasterLayer = qobject_cast< QgsRasterLayer *>( layer );
47 return QgsDateTimeRange();
58 return QgsDateTimeRange();
80 return mIntervalHandlingMethod;
85 if ( mIntervalHandlingMethod == method )
87 mIntervalHandlingMethod = method;
105 QDomElement temporalNode = element.firstChildElement( QStringLiteral(
"temporal" ) );
107 setIsActive( temporalNode.attribute( QStringLiteral(
"enabled" ), QStringLiteral(
"0" ) ).toInt() );
109 mMode =
static_cast< TemporalMode >( temporalNode.attribute( QStringLiteral(
"mode" ), QStringLiteral(
"0" ) ). toInt() );
112 QDomNode rangeElement = temporalNode.namedItem( QStringLiteral(
"fixedRange" ) );
114 QDomNode begin = rangeElement.namedItem( QStringLiteral(
"start" ) );
115 QDomNode end = rangeElement.namedItem( QStringLiteral(
"end" ) );
117 QDateTime beginDate = QDateTime::fromString( begin.toElement().text(), Qt::ISODate );
118 QDateTime endDate = QDateTime::fromString( end.toElement().text(), Qt::ISODate );
120 QgsDateTimeRange range = QgsDateTimeRange( beginDate, endDate );
129 if ( element.isNull() )
130 return QDomElement();
132 QDomElement temporalElement = document.createElement( QStringLiteral(
"temporal" ) );
133 temporalElement.setAttribute( QStringLiteral(
"enabled" ),
isActive() ? QStringLiteral(
"1" ) : QStringLiteral(
"0" ) );
134 temporalElement.setAttribute( QStringLiteral(
"mode" ), QString::number( mMode ) );
135 temporalElement.setAttribute( QStringLiteral(
"fetchMode" ), QString::number( mIntervalHandlingMethod ) );
137 QDomElement rangeElement = document.createElement( QStringLiteral(
"fixedRange" ) );
139 QDomElement startElement = document.createElement( QStringLiteral(
"start" ) );
140 QDomElement endElement = document.createElement( QStringLiteral(
"end" ) );
142 QDomText startText = document.createTextNode( mFixedRange.begin().toTimeSpec( Qt::OffsetFromUTC ).toString( Qt::ISODate ) );
143 QDomText endText = document.createTextNode( mFixedRange.end().toTimeSpec( Qt::OffsetFromUTC ).toString( Qt::ISODate ) );
144 startElement.appendChild( startText );
145 endElement.appendChild( endText );
146 rangeElement.appendChild( startElement );
147 rangeElement.appendChild( endElement );
149 temporalElement.appendChild( rangeElement );
151 element.appendChild( temporalElement );
160 setIsActive( rasterCaps->hasTemporalCapabilities() );
163 if ( rasterCaps->hasTemporalCapabilities() )
168 mIntervalHandlingMethod = rasterCaps->intervalHandlingMethod();
Base class for handling properties relating to a data provider's temporal capabilities.
Base class for storage of map layer temporal properties.
Base class for all map layer types.
Implementation of data provider temporal properties for QgsRasterDataProviders.
IntervalHandlingMethod
Method to use when resolving a temporal range to a data provider layer or band.
const QgsDateTimeRange & availableTemporalRange() const
Returns the datetime range extent from which temporal data is available from the provider.
QgsRasterDataProviderTemporalCapabilities * temporalCapabilities() override
Returns the provider's temporal capabilities.
QDomElement writeXml(QDomElement &element, QDomDocument &doc, const QgsReadWriteContext &context) override
Writes the properties to a DOM element, to be used later with readXml().
void setMode(TemporalMode mode)
Sets the temporal properties mode.
void setDefaultsFromDataProviderTemporalCapabilities(const QgsDataProviderTemporalCapabilities *capabilities) override
Sets the layers temporal settings to appropriate defaults based on a provider's temporal capabilities...
bool isVisibleInTemporalRange(const QgsDateTimeRange &range) const override
Returns true if the layer should be visible and rendered for the specified time range.
QgsTemporalProperty::Flags flags() const override
Returns flags associated to the temporal property.
void setIntervalHandlingMethod(QgsRasterDataProviderTemporalCapabilities::IntervalHandlingMethod method)
Sets the desired method to use when resolving a temporal interval to matching layers or bands in the ...
TemporalMode
Mode of the raster temporal properties.
@ ModeFixedTemporalRange
Mode when temporal properties have fixed start and end datetimes.
@ ModeTemporalRangeFromDataProvider
Mode when raster layer delegates temporal range handling to the dataprovider.
TemporalMode mode() const
Returns the temporal properties mode.
QgsRasterLayerTemporalProperties(QObject *parent=nullptr, bool enabled=false)
Constructor for QgsRasterLayerTemporalProperties, with the specified parent object.
void setFixedTemporalRange(const QgsDateTimeRange &range)
Sets a temporal range to apply to the whole layer.
bool readXml(const QDomElement &element, const QgsReadWriteContext &context) override
Reads temporal properties from a DOM element previously written by writeXml().
QgsRasterDataProviderTemporalCapabilities::IntervalHandlingMethod intervalHandlingMethod() const
Returns the desired method to use when resolving a temporal interval to matching layers or bands in t...
const QgsDateTimeRange & fixedTemporalRange() const
Returns the fixed temporal range for the layer.
QgsDateTimeRange calculateTemporalExtent(QgsMapLayer *layer) const override
Attempts to calculate the overall temporal extent for the specified layer, using the settings defined...
Represents a raster layer.
QgsRasterDataProvider * dataProvider() override
Returns the source data provider.
The class is used as a container of context for various read/write operations on other objects.
bool isActive() const
Returns true if the temporal property is active.
void setIsActive(bool active)
Sets whether the temporal property is active.
@ FlagDontInvalidateCachedRendersWhenRangeChanges
Any cached rendering will not be invalidated when temporal range context is modified.