35 return range.isInfinite() || mFixedRange.isInfinite() || mFixedRange.overlaps( range );
45 QgsRasterLayer *rasterLayer = qobject_cast< QgsRasterLayer *>( layer );
47 return QgsDateTimeRange();
58 return QgsDateTimeRange();
63 QgsRasterLayer *rasterLayer = qobject_cast< QgsRasterLayer *>( layer );
70 return { mFixedRange };
101 return mIntervalHandlingMethod;
106 if ( mIntervalHandlingMethod == method )
108 mIntervalHandlingMethod = method;
126 QDomElement temporalNode = element.firstChildElement( QStringLiteral(
"temporal" ) );
128 setIsActive( temporalNode.attribute( QStringLiteral(
"enabled" ), QStringLiteral(
"0" ) ).toInt() );
130 mMode =
static_cast< TemporalMode >( temporalNode.attribute( QStringLiteral(
"mode" ), QStringLiteral(
"0" ) ). toInt() );
133 QDomNode rangeElement = temporalNode.namedItem( QStringLiteral(
"fixedRange" ) );
135 QDomNode begin = rangeElement.namedItem( QStringLiteral(
"start" ) );
136 QDomNode end = rangeElement.namedItem( QStringLiteral(
"end" ) );
138 QDateTime beginDate = QDateTime::fromString( begin.toElement().text(), Qt::ISODate );
139 QDateTime endDate = QDateTime::fromString( end.toElement().text(), Qt::ISODate );
141 QgsDateTimeRange range = QgsDateTimeRange( beginDate, endDate );
150 if ( element.isNull() )
151 return QDomElement();
153 QDomElement temporalElement = document.createElement( QStringLiteral(
"temporal" ) );
154 temporalElement.setAttribute( QStringLiteral(
"enabled" ),
isActive() ? QStringLiteral(
"1" ) : QStringLiteral(
"0" ) );
155 temporalElement.setAttribute( QStringLiteral(
"mode" ), QString::number( mMode ) );
156 temporalElement.setAttribute( QStringLiteral(
"fetchMode" ), QString::number( mIntervalHandlingMethod ) );
158 QDomElement rangeElement = document.createElement( QStringLiteral(
"fixedRange" ) );
160 QDomElement startElement = document.createElement( QStringLiteral(
"start" ) );
161 QDomElement endElement = document.createElement( QStringLiteral(
"end" ) );
163 QDomText startText = document.createTextNode( mFixedRange.begin().toTimeSpec( Qt::OffsetFromUTC ).toString( Qt::ISODate ) );
164 QDomText endText = document.createTextNode( mFixedRange.end().toTimeSpec( Qt::OffsetFromUTC ).toString( Qt::ISODate ) );
165 startElement.appendChild( startText );
166 endElement.appendChild( endText );
167 rangeElement.appendChild( startElement );
168 rangeElement.appendChild( endElement );
170 temporalElement.appendChild( rangeElement );
172 element.appendChild( temporalElement );
181 setIsActive( rasterCaps->hasTemporalCapabilities() );
184 if ( rasterCaps->hasTemporalCapabilities() )
189 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.
QList< QgsDateTimeRange > allAvailableTemporalRanges() const
Returns a list of all valid datetime ranges for which temporal data is available from the provider.
const QgsDateTimeRange & availableTemporalRange() const
Returns the overall 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.
QList< QgsDateTimeRange > allTemporalRanges(QgsMapLayer *layer) const override
Attempts to calculate the overall list of all temporal extents which are contained in the specified l...
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.