QGIS API Documentation  3.14.0-Pi (9f7028fd23)
qgsvectorlayertemporalproperties.h
Go to the documentation of this file.
1 /***************************************************************************
2  qgsvectorlayertemporalproperties.h
3  ---------------
4  begin : May 2020
5  copyright : (C) 2020 by Nyall Dawson
6  email : nyall dot dawson at gmail dot com
7  ***************************************************************************/
8 
9 /***************************************************************************
10  * *
11  * This program is free software; you can redistribute it and/or modify *
12  * it under the terms of the GNU General Public License as published by *
13  * the Free Software Foundation; either version 2 of the License, or *
14  * (at your option) any later version. *
15  * *
16  ***************************************************************************/
17 
18 
19 #ifndef QGSVECTORLAYERTEMPORALPROPERTIES_H
20 #define QGSVECTORLAYERTEMPORALPROPERTIES_H
21 
22 #include "qgis_core.h"
23 #include "qgis_sip.h"
24 #include "qgsrange.h"
27 #include "qgsunittypes.h"
28 
29 class QgsVectorLayer;
30 class QgsFields;
31 
41 {
42  public:
43 
49  QgsVectorLayer *layer() const;
50 
56  void setLayer( QgsVectorLayer *layer );
57 
58  private:
59 
60  QgsVectorLayer *mLayer = nullptr;
61 };
62 
71 {
72  Q_OBJECT
73 
74  public:
75 
81  QgsVectorLayerTemporalProperties( QObject *parent SIP_TRANSFERTHIS = nullptr, bool enabled = false );
82 
83  bool isVisibleInTemporalRange( const QgsDateTimeRange &range ) const override;
84  QgsDateTimeRange calculateTemporalExtent( QgsMapLayer *layer ) const override SIP_SKIP;
85 
90  {
91  ModeFixedTemporalRange = 0,
97  };
98 
104  TemporalMode mode() const;
105 
111  void setMode( TemporalMode mode );
112 
116  QgsTemporalProperty::Flags flags() const override;
117 
128  void setFixedTemporalRange( const QgsDateTimeRange &range );
129 
138  const QgsDateTimeRange &fixedTemporalRange() const;
139 
150  QString startField() const;
151 
162  void setStartField( const QString &field );
163 
171  QString endField() const;
172 
180  void setEndField( const QString &field );
181 
191  QString startExpression() const;
192 
202  void setStartExpression( const QString &expression );
203 
213  QString endExpression() const;
214 
224  void setEndExpression( const QString &endExpression );
225 
238  QString durationField() const;
239 
252  void setDurationField( const QString &field );
253 
259  QgsUnitTypes::TemporalUnit durationUnits() const;
260 
266  void setDurationUnits( QgsUnitTypes::TemporalUnit units );
267 
279  double fixedDuration() const;
280 
292  void setFixedDuration( double duration );
293 
303  bool accumulateFeatures() const;
304 
314  void setAccumulateFeatures( bool accumulate );
315 
328  QString createFilterString( const QgsVectorLayerTemporalContext &context, const QgsDateTimeRange &range ) const;
329 
334  void guessDefaultsFromFields( const QgsFields &fields );
335 
336  QDomElement writeXml( QDomElement &element, QDomDocument &doc, const QgsReadWriteContext &context ) override;
337  bool readXml( const QDomElement &element, const QgsReadWriteContext &context ) override;
339 
340  private:
341 
343  TemporalMode mMode = ModeFixedTemporalRange;
344 
346  QgsDateTimeRange mFixedRange;
347 
348  QString mStartFieldName;
349  QString mEndFieldName;
350  QString mDurationFieldName;
352 
353  double mFixedDuration = 0;
354 
355  bool mAccumulateFeatures = false;
356 
357  QString mStartExpression;
358  QString mEndExpression;
359 
360 };
361 
362 #endif // QGSVECTORLAYERTEMPORALPROPERTIES_H
QgsTemporalProperty::flags
virtual QgsTemporalProperty::Flags flags() const
Returns flags associated to the temporal property.
Definition: qgstemporalproperty.h:74
QgsMapLayerTemporalProperties::writeXml
virtual QDomElement writeXml(QDomElement &element, QDomDocument &doc, const QgsReadWriteContext &context)=0
Writes the properties to a DOM element, to be used later with readXml().
QgsReadWriteContext
Definition: qgsreadwritecontext.h:34
QgsFields
Definition: qgsfields.h:44
qgsunittypes.h
QgsMapLayerTemporalProperties::calculateTemporalExtent
virtual QgsDateTimeRange calculateTemporalExtent(QgsMapLayer *layer) const
Attempts to calculate the overall temporal extent for the specified layer, using the settings defined...
Definition: qgsmaplayertemporalproperties.cpp:30
qgsrange.h
QgsVectorLayerTemporalProperties::ModeFeatureDateTimeStartAndEndFromExpressions
@ ModeFeatureDateTimeStartAndEndFromExpressions
Mode when features use expressions for start and end times.
Definition: qgsvectorlayertemporalproperties.h:95
QgsUnitTypes::TemporalUnit
TemporalUnit
Temporal units.
Definition: qgsunittypes.h:149
QgsVectorLayerTemporalProperties::ModeFeatureDateTimeStartAndEndFromFields
@ ModeFeatureDateTimeStartAndEndFromFields
Mode when features have separate fields for start and end times.
Definition: qgsvectorlayertemporalproperties.h:93
qgsrasterdataprovidertemporalcapabilities.h
QgsMapLayerTemporalProperties::readXml
virtual bool readXml(const QDomElement &element, const QgsReadWriteContext &context)=0
Reads temporal properties from a DOM element previously written by writeXml().
QgsDataProviderTemporalCapabilities
Definition: qgsdataprovidertemporalcapabilities.h:33
qgsmaplayertemporalproperties.h
SIP_SKIP
#define SIP_SKIP
Definition: qgis_sip.h:126
QgsVectorLayerTemporalProperties::ModeFeatureDateTimeInstantFromField
@ ModeFeatureDateTimeInstantFromField
Mode when features have a datetime instant taken from a single field.
Definition: qgsvectorlayertemporalproperties.h:92
qgis_sip.h
QgsMapLayerTemporalProperties::isVisibleInTemporalRange
virtual bool isVisibleInTemporalRange(const QgsDateTimeRange &range) const
Returns true if the layer should be visible and rendered for the specified time range.
Definition: qgsmaplayertemporalproperties.cpp:25
QgsVectorLayerTemporalProperties
Definition: qgsvectorlayertemporalproperties.h:70
QgsMapLayerTemporalProperties
Definition: qgsmaplayertemporalproperties.h:42
QgsVectorLayerTemporalContext
Definition: qgsvectorlayertemporalproperties.h:40
QgsVectorLayerTemporalProperties::ModeFeatureDateTimeStartAndDurationFromFields
@ ModeFeatureDateTimeStartAndDurationFromFields
Mode when features have a field for start time and a field for event duration.
Definition: qgsvectorlayertemporalproperties.h:94
QgsUnitTypes::TemporalMinutes
@ TemporalMinutes
Minutes.
Definition: qgsunittypes.h:153
QgsVectorLayer
Definition: qgsvectorlayer.h:385
QgsMapLayer
Definition: qgsmaplayer.h:81
QgsVectorLayerTemporalProperties::ModeRedrawLayerOnly
@ ModeRedrawLayerOnly
Redraw the layer when temporal range changes, but don't apply any filtering. Useful when symbology or...
Definition: qgsvectorlayertemporalproperties.h:96
QgsMapLayerTemporalProperties::setDefaultsFromDataProviderTemporalCapabilities
virtual void setDefaultsFromDataProviderTemporalCapabilities(const QgsDataProviderTemporalCapabilities *capabilities)=0
Sets the layers temporal settings to appropriate defaults based on a provider's temporal capabilities...
QgsVectorLayerTemporalProperties::TemporalMode
TemporalMode
Mode of the vector temporal properties.
Definition: qgsvectorlayertemporalproperties.h:89
SIP_TRANSFERTHIS
#define SIP_TRANSFERTHIS
Definition: qgis_sip.h:53