46 QgsRasterLayer *rasterLayer = qobject_cast< QgsRasterLayer *>( layer );
67 QgsRasterLayer *rasterLayer = qobject_cast< QgsRasterLayer *>( layer );
74 return { mFixedRange };
108 return mIntervalHandlingMethod;
113 if ( mIntervalHandlingMethod == method )
115 mIntervalHandlingMethod = method;
133 const QDomElement temporalNode = element.firstChildElement( QStringLiteral(
"temporal" ) );
135 setIsActive( temporalNode.attribute( QStringLiteral(
"enabled" ), QStringLiteral(
"0" ) ).toInt() );
137 mMode =
static_cast< Qgis::RasterTemporalMode >( temporalNode.attribute( QStringLiteral(
"mode" ), QStringLiteral(
"0" ) ). toInt() );
138 mIntervalHandlingMethod =
static_cast< Qgis::TemporalIntervalMatchMethod >( temporalNode.attribute( QStringLiteral(
"fetchMode" ), QStringLiteral(
"0" ) ). toInt() );
140 const QDomNode rangeElement = temporalNode.namedItem( QStringLiteral(
"fixedRange" ) );
142 const QDomNode begin = rangeElement.namedItem( QStringLiteral(
"start" ) );
143 const QDomNode end = rangeElement.namedItem( QStringLiteral(
"end" ) );
145 const QDateTime beginDate = QDateTime::fromString( begin.toElement().text(), Qt::ISODate );
146 const QDateTime endDate = QDateTime::fromString( end.toElement().text(), Qt::ISODate );
157 if ( element.isNull() )
158 return QDomElement();
160 QDomElement temporalElement = document.createElement( QStringLiteral(
"temporal" ) );
161 temporalElement.setAttribute( QStringLiteral(
"enabled" ),
isActive() ? QStringLiteral(
"1" ) : QStringLiteral(
"0" ) );
162 temporalElement.setAttribute( QStringLiteral(
"mode" ), QString::number(
static_cast< int >( mMode ) ) );
163 temporalElement.setAttribute( QStringLiteral(
"fetchMode" ), QString::number(
static_cast< int >( mIntervalHandlingMethod ) ) );
165 QDomElement rangeElement = document.createElement( QStringLiteral(
"fixedRange" ) );
167 QDomElement startElement = document.createElement( QStringLiteral(
"start" ) );
168 QDomElement endElement = document.createElement( QStringLiteral(
"end" ) );
170 const QDomText startText = document.createTextNode( mFixedRange.
begin().toTimeSpec( Qt::OffsetFromUTC ).toString( Qt::ISODate ) );
171 const QDomText endText = document.createTextNode( mFixedRange.
end().toTimeSpec( Qt::OffsetFromUTC ).toString( Qt::ISODate ) );
172 startElement.appendChild( startText );
173 endElement.appendChild( endText );
174 rangeElement.appendChild( startElement );
175 rangeElement.appendChild( endElement );
177 temporalElement.appendChild( rangeElement );
179 element.appendChild( temporalElement );
188 setIsActive( rasterCaps->hasTemporalCapabilities() );
191 if ( rasterCaps->hasTemporalCapabilities() )
196 mIntervalHandlingMethod = rasterCaps->intervalHandlingMethod();
TemporalIntervalMatchMethod
Method to use when resolving a temporal range to a data provider layer or band.
RasterTemporalMode
Raster layer temporal modes.
@ RedrawLayerOnly
Redraw the layer when temporal range changes, but don't apply any filtering. Useful when raster symbo...
@ TemporalRangeFromDataProvider
Mode when raster layer delegates temporal range handling to the dataprovider.
@ FixedTemporalRange
Mode when temporal properties have fixed start and end datetimes.
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.
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 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.
Qgis::TemporalIntervalMatchMethod intervalHandlingMethod() const
Returns the desired method to use when resolving a temporal interval to matching layers or bands in t...
void setIntervalHandlingMethod(Qgis::TemporalIntervalMatchMethod method)
Sets the desired method to use when resolving a temporal interval to matching layers or bands in the ...
Qgis::RasterTemporalMode mode() const
Returns the temporal properties mode.
QList< QgsDateTimeRange > allTemporalRanges(QgsMapLayer *layer) const override
Attempts to calculate the overall list of all temporal extents which are contained in the specified l...
void setMode(Qgis::RasterTemporalMode mode)
Sets 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().
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.
T begin() const
Returns the beginning of the range.
T end() const
Returns the upper bound of the range.
bool overlaps(const QgsTemporalRange< T > &other) const
Returns true if this range overlaps another range.
bool isInfinite() const
Returns true if the range consists of all possible values.
QgsTemporalRange< QDateTime > QgsDateTimeRange
QgsRange which stores a range of date times.