19#include "moc_qgsrasterlayertemporalproperties.cpp" 
   26  mTemporalRepresentationScale.
setDays( 1.0 );
 
 
   42      for ( 
auto it = mRangePerBand.constBegin(); it != mRangePerBand.constEnd(); ++it )
 
   44        if ( it.value().overlaps( range ) )
 
 
   60  QgsRasterLayer *rasterLayer = qobject_cast< QgsRasterLayer *>( layer );
 
   77      bool includeBeginning = 
true;
 
   78      bool includeEnd = 
true;
 
   79      for ( 
auto it = mRangePerBand.constBegin(); it != mRangePerBand.constEnd(); ++it )
 
   81        if ( it.value().begin() < begin || !begin.isValid() )
 
   83          begin = it.value().
begin();
 
   84          includeBeginning = it.value().includeBeginning();
 
   86        else if ( !includeBeginning && it.value().begin() == begin && it.value().includeBeginning() )
 
   88          includeBeginning = 
true;
 
   90        if ( it.value().end() > end || !end.isValid() )
 
   92          end = it.value().end();
 
   93          includeEnd = it.value().includeEnd();
 
   95        else if ( !includeEnd && it.value().end() == end && it.value().includeEnd() )
 
 
  113  QgsRasterLayer *rasterLayer = qobject_cast< QgsRasterLayer *>( layer );
 
  119      return { mFixedRange };
 
  123      QList<QgsDateTimeRange> results;
 
  124      results.reserve( mRangePerBand.size() );
 
  125      for ( 
auto it = mRangePerBand.constBegin(); it != mRangePerBand.constEnd(); ++it )
 
  127        results.append( it.value() );
 
 
  180  return mIntervalHandlingMethod;
 
 
  185  if ( mIntervalHandlingMethod == method )
 
  187  mIntervalHandlingMethod = method;
 
 
  202  return mRangePerBand;
 
 
  207  if ( mRangePerBand == ranges )
 
  210  mRangePerBand = ranges;
 
 
  227      int currentMatchingBand = -1;
 
  229      for ( 
auto it = mRangePerBand.constBegin(); it != mRangePerBand.constEnd(); ++it )
 
  231        if ( it.value().overlaps( range ) )
 
  234               || ( it.value().includeEnd() && it.value().end() >= currentMatchingRange.
end() ) 
 
  235               || ( !currentMatchingRange.
includeEnd() && it.value().end() >= currentMatchingRange.
end() ) ) 
 
  237            currentMatchingBand = it.key();
 
  238            currentMatchingRange = it.value();
 
  242      return currentMatchingBand;
 
 
  260      const int bandCount = layer->
bandCount();
 
  262      res.reserve( bandCount );
 
  263      for ( 
int i = 1; i <= bandCount; ++i )
 
  271      res.reserve( mRangePerBand.size() );
 
  274      for ( 
auto it = mRangePerBand.constBegin(); it != mRangePerBand.constEnd(); ++it )
 
  276        if ( it.value().overlaps( range ) )
 
  278          res.append( it.key() );
 
  285      return QList<int>() << mBandNumber;
 
 
  297  if ( mBandNumber == number )
 
  300  mBandNumber = number;
 
 
  305  return mTemporalRepresentationOffset;
 
 
  310  if ( mTemporalRepresentationOffset == offset )
 
  313  mTemporalRepresentationOffset = offset;
 
 
  318  return mTemporalRepresentationScale;
 
 
  323  if ( mTemporalRepresentationScale == scale )
 
  326  mTemporalRepresentationScale = scale;
 
 
  334  const QDomElement temporalNode = element.firstChildElement( QStringLiteral( 
"temporal" ) );
 
  336  setIsActive( temporalNode.attribute( QStringLiteral( 
"enabled" ), QStringLiteral( 
"0" ) ).toInt() );
 
  338  mMode = 
static_cast< Qgis::RasterTemporalMode >( temporalNode.attribute( QStringLiteral( 
"mode" ), QStringLiteral( 
"0" ) ). toInt() );
 
  339  mBandNumber = temporalNode.attribute( QStringLiteral( 
"bandNumber" ), QStringLiteral( 
"1" ) ).toInt();
 
  340  mIntervalHandlingMethod = 
static_cast< Qgis::TemporalIntervalMatchMethod >( temporalNode.attribute( QStringLiteral( 
"fetchMode" ), QStringLiteral( 
"0" ) ). toInt() );
 
  346      const QDomNode instantElement = temporalNode.namedItem( QStringLiteral( 
"fixedInstant" ) );
 
  347      const QDateTime date = QDateTime::fromString( instantElement.toElement().text(), Qt::ISODate );
 
  356      const QDomNode rangeElement = temporalNode.namedItem( QStringLiteral( 
"fixedRange" ) );
 
  358      const QDomNode begin = rangeElement.namedItem( QStringLiteral( 
"start" ) );
 
  359      const QDomNode end = rangeElement.namedItem( QStringLiteral( 
"end" ) );
 
  361      const QDateTime beginDate = QDateTime::fromString( begin.toElement().text(), Qt::ISODate );
 
  362      const QDateTime endDate = QDateTime::fromString( end.toElement().text(), Qt::ISODate );
 
  371      mRangePerBand.clear();
 
  373      const QDomNodeList ranges = temporalNode.firstChildElement( QStringLiteral( 
"ranges" ) ).childNodes();
 
  374      for ( 
int i = 0; i < ranges.size(); ++i )
 
  376        const QDomElement rangeElement = ranges.at( i ).toElement();
 
  377        const int band = rangeElement.attribute( QStringLiteral( 
"band" ) ).toInt();
 
  378        const QDateTime begin = QDateTime::fromString( rangeElement.attribute( QStringLiteral( 
"begin" ) ), Qt::ISODate );
 
  379        const QDateTime end = QDateTime::fromString( rangeElement.attribute( QStringLiteral( 
"end" ) ), Qt::ISODate );
 
  380        const bool includeBeginning = rangeElement.attribute( QStringLiteral( 
"includeBeginning" ) ).toInt();
 
  381        const bool includeEnd = rangeElement.attribute( QStringLiteral( 
"includeEnd" ) ).toInt();
 
  382        mRangePerBand.insert( band, 
QgsDateTimeRange( begin, end, includeBeginning, includeEnd ) );
 
  389      mTemporalRepresentationOffset = QDateTime::fromString( temporalNode.attribute( QStringLiteral( 
"temporalRepresentationOffset" ) ), Qt::ISODate );
 
  390      mTemporalRepresentationScale = 
QgsInterval( temporalNode.attribute( QStringLiteral( 
"temporalRepresentationScale" ), QStringLiteral( 
"1" ) ).toDouble(),
 
  391                                     static_cast< Qgis::TemporalUnit >( temporalNode.attribute( QStringLiteral( 
"temporalRepresentationScaleUnit" ), QStringLiteral( 
"4" ) ).toInt() ) );
 
 
  406  if ( element.isNull() )
 
  407    return QDomElement();
 
  409  QDomElement temporalElement = document.createElement( QStringLiteral( 
"temporal" ) );
 
  410  temporalElement.setAttribute( QStringLiteral( 
"enabled" ), 
isActive() ? QStringLiteral( 
"1" ) : QStringLiteral( 
"0" ) );
 
  411  temporalElement.setAttribute( QStringLiteral( 
"mode" ), QString::number( 
static_cast< int >( mMode ) ) );
 
  412  temporalElement.setAttribute( QStringLiteral( 
"bandNumber" ), QString::number( mBandNumber ) );
 
  413  temporalElement.setAttribute( QStringLiteral( 
"fetchMode" ), QString::number( 
static_cast< int >( mIntervalHandlingMethod ) ) );
 
  419      QDomElement instantElement = document.createElement( QStringLiteral( 
"fixedInstant" ) );
 
  420      const QDomText instantText = document.createTextNode( mFixedRange.
begin().toTimeSpec( Qt::OffsetFromUTC ).toString( Qt::ISODate ) );
 
  421      instantElement.appendChild( instantText );
 
  423      temporalElement.appendChild( instantElement );
 
  430      QDomElement rangeElement = document.createElement( QStringLiteral( 
"fixedRange" ) );
 
  432      QDomElement startElement = document.createElement( QStringLiteral( 
"start" ) );
 
  433      QDomElement endElement = document.createElement( QStringLiteral( 
"end" ) );
 
  435      const QDomText startText = document.createTextNode( mFixedRange.
begin().toTimeSpec( Qt::OffsetFromUTC ).toString( Qt::ISODate ) );
 
  436      const QDomText endText = document.createTextNode( mFixedRange.
end().toTimeSpec( Qt::OffsetFromUTC ).toString( Qt::ISODate ) );
 
  437      startElement.appendChild( startText );
 
  438      endElement.appendChild( endText );
 
  439      rangeElement.appendChild( startElement );
 
  440      rangeElement.appendChild( endElement );
 
  442      temporalElement.appendChild( rangeElement );
 
  448      QDomElement ranges = document.createElement( QStringLiteral( 
"ranges" ) );
 
  449      for ( 
auto it = mRangePerBand.constBegin(); it != mRangePerBand.constEnd(); ++it )
 
  451        QDomElement range = document.createElement( QStringLiteral( 
"range" ) );
 
  452        range.setAttribute( QStringLiteral( 
"band" ), it.key() );
 
  453        range.setAttribute( QStringLiteral( 
"begin" ), it.value().begin().toString( Qt::ISODate ) );
 
  454        range.setAttribute( QStringLiteral( 
"end" ), it.value().end().toString( Qt::ISODate ) );
 
  455        range.setAttribute( QStringLiteral( 
"includeBeginning" ), it.value().includeBeginning() ? 
"1" : 
"0" );
 
  456        range.setAttribute( QStringLiteral( 
"includeEnd" ), it.value().includeEnd() ? 
"1" : 
"0" );
 
  457        ranges.appendChild( range );
 
  459      temporalElement.appendChild( ranges );
 
  465      temporalElement.setAttribute( QStringLiteral( 
"temporalRepresentationOffset" ), mTemporalRepresentationOffset.toString( Qt::ISODate ) );
 
  466      temporalElement.setAttribute( QStringLiteral( 
"temporalRepresentationScale" ), QString::number( mTemporalRepresentationScale.
originalDuration() ) );
 
  467      temporalElement.setAttribute( QStringLiteral( 
"temporalRepresentationScaleUnit" ), QString::number( 
static_cast< int >( mTemporalRepresentationScale.
originalUnit() ) ) );
 
  476  element.appendChild( temporalElement );
 
 
  485    setIsActive( rasterCaps->hasTemporalCapabilities() );
 
  488    if ( rasterCaps->hasTemporalCapabilities() )
 
  493    mIntervalHandlingMethod = rasterCaps->intervalHandlingMethod();
 
 
TemporalIntervalMatchMethod
Method to use when resolving a temporal range to a data provider layer or band.
 
TemporalUnit
Temporal units.
 
RasterTemporalMode
Raster layer temporal modes.
 
@ RepresentsTemporalValues
Pixel values represent an datetime.
 
@ RedrawLayerOnly
Redraw the layer when temporal range changes, but don't apply any filtering. Useful when raster symbo...
 
@ FixedRangePerBand
Layer has a fixed temporal range per band.
 
@ TemporalRangeFromDataProvider
Mode when raster layer delegates temporal range handling to the dataprovider.
 
@ FixedTemporalRange
Mode when temporal properties have fixed start and end datetimes.
 
@ FixedDateTime
Layer has a fixed date time instant.
 
Base class for handling properties relating to a data provider's temporal capabilities.
 
A representation of the interval between two datetime values.
 
double originalDuration() const
Returns the original interval duration.
 
Qgis::TemporalUnit originalUnit() const
Returns the original interval temporal unit.
 
void setDays(double days)
Sets the interval duration in days.
 
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().
 
QDateTime temporalRepresentationOffset() const
Returns the temporal offset, which is a fixed datetime which should be added to individual pixel valu...
 
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.
 
QList< int > filteredBandsForTemporalRange(QgsRasterLayer *layer, const QgsDateTimeRange &range) const
Returns a filtered list of bands which match the specified range.
 
void setTemporalRepresentationOffset(const QDateTime &offset)
Sets the temporal offset, which is a fixed datetime which should be added to individual pixel values ...
 
Qgis::TemporalIntervalMatchMethod intervalHandlingMethod() const
Returns the desired method to use when resolving a temporal interval to matching layers or bands in t...
 
const QgsInterval & temporalRepresentationScale() const
Returns the scale, which is an interval factor which should be applied to individual pixel values fro...
 
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.
 
void setTemporalRepresentationScale(const QgsInterval &scale)
Sets the scale, which is an interval factor which should be applied to individual pixel values from t...
 
int bandForTemporalRange(QgsRasterLayer *layer, const QgsDateTimeRange &range) const
Returns the band corresponding to the specified range.
 
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.
 
void setFixedRangePerBand(const QMap< int, QgsDateTimeRange > &ranges)
Sets the fixed temporal range for each band.
 
bool readXml(const QDomElement &element, const QgsReadWriteContext &context) override
Reads temporal properties from a DOM element previously written by writeXml().
 
QMap< int, QgsDateTimeRange > fixedRangePerBand() const
Returns the fixed temporal range for each band.
 
int bandNumber() const
Returns the band number from which temporal values should be taken.
 
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...
 
void setBandNumber(int number)
Sets the band number from which temporal values should be taken.
 
Represents a raster layer.
 
int bandCount() const
Returns the number of bands in this layer.
 
QgsRasterDataProvider * dataProvider() override
Returns the source data provider.
 
A container for the context for various read/write operations on objects.
 
void changed()
Emitted when the temporal properties have changed.
 
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 includeEnd() const
Returns true if the end is inclusive, or false if the end is exclusive.
 
bool isInfinite() const
Returns true if the range consists of all possible values.
 
#define BUILTIN_UNREACHABLE
 
QgsTemporalRange< QDateTime > QgsDateTimeRange
QgsRange which stores a range of date times.