QGIS API Documentation  3.20.0-Odense (decaadbb31)
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( 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;
338  void setDefaultsFromDataProviderTemporalCapabilities( const QgsDataProviderTemporalCapabilities *capabilities ) 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
Base class for handling properties relating to a data provider's temporal capabilities.
Container of fields for a vector layer.
Definition: qgsfields.h:45
Base class for storage of map layer temporal properties.
Base class for all map layer types.
Definition: qgsmaplayer.h:70
The class is used as a container of context for various read/write operations on other objects.
TemporalUnit
Temporal units.
Definition: qgsunittypes.h:150
@ TemporalMinutes
Minutes.
Definition: qgsunittypes.h:153
Encapsulates the context in which a QgsVectorLayer's temporal capabilities will be applied.
Implementation of map layer temporal properties for vector layers.
TemporalMode
Mode of the vector temporal properties.
@ ModeFeatureDateTimeStartAndDurationFromFields
Mode when features have a field for start time and a field for event duration.
@ ModeFeatureDateTimeInstantFromField
Mode when features have a datetime instant taken from a single field.
@ ModeFeatureDateTimeStartAndEndFromFields
Mode when features have separate fields for start and end times.
@ ModeRedrawLayerOnly
Redraw the layer when temporal range changes, but don't apply any filtering. Useful when symbology or...
@ ModeFeatureDateTimeStartAndEndFromExpressions
Mode when features use expressions for start and end times.
Represents a vector layer which manages a vector based data sets.
#define SIP_TRANSFERTHIS
Definition: qgis_sip.h:53
#define SIP_SKIP
Definition: qgis_sip.h:126
const QgsField & field
Definition: qgsfield.h:463