34 case Qgis::RasterTemporalMode::FixedTemporalRange:
35 return range.isInfinite() || mFixedRange.isInfinite() || mFixedRange.overlaps( range );
37 case Qgis::RasterTemporalMode::TemporalRangeFromDataProvider:
38 case Qgis::RasterTemporalMode::RedrawLayerOnly:
46 QgsRasterLayer *rasterLayer = qobject_cast< QgsRasterLayer *>( layer );
48 return QgsDateTimeRange();
52 case Qgis::RasterTemporalMode::FixedTemporalRange:
55 case Qgis::RasterTemporalMode::TemporalRangeFromDataProvider:
58 case Qgis::RasterTemporalMode::RedrawLayerOnly:
62 return QgsDateTimeRange();
67 QgsRasterLayer *rasterLayer = qobject_cast< QgsRasterLayer *>( layer );
73 case Qgis::RasterTemporalMode::FixedTemporalRange:
74 return { mFixedRange };
76 case Qgis::RasterTemporalMode::TemporalRangeFromDataProvider:
82 case Qgis::RasterTemporalMode::RedrawLayerOnly:
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 );
148 const QgsDateTimeRange range = QgsDateTimeRange( beginDate, endDate );
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() )
193 setMode( Qgis::RasterTemporalMode::TemporalRangeFromDataProvider );
196 mIntervalHandlingMethod = rasterCaps->intervalHandlingMethod();