QGIS API Documentation  3.17.0-Master (a035f434f4)
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
The class is used as a container of context for various read/write operations on other objects...
Base class for all map layer types.
Definition: qgsmaplayer.h:83
#define SIP_TRANSFERTHIS
Definition: qgis_sip.h:53
Implementation of map layer temporal properties for vector layers.
Mode when features have separate fields for start and end times.
virtual QgsDateTimeRange calculateTemporalExtent(QgsMapLayer *layer) const
Attempts to calculate the overall temporal extent for the specified layer, using the settings defined...
virtual QDomElement writeXml(QDomElement &element, QDomDocument &doc, const QgsReadWriteContext &context)=0
Writes the properties to a DOM element, to be used later with readXml().
Container of fields for a vector layer.
Definition: qgsfields.h:44
Base class for handling properties relating to a data provider's temporal capabilities.
Mode when features have a datetime instant taken from a single field.
Encapsulates the context in which a QgsVectorLayer's temporal capabilities will be applied...
virtual bool readXml(const QDomElement &element, const QgsReadWriteContext &context)=0
Reads temporal properties from a DOM element previously written by writeXml().
#define SIP_SKIP
Definition: qgis_sip.h:126
Mode when features have a field for start time and a field for event duration.
virtual bool isVisibleInTemporalRange(const QgsDateTimeRange &range) const
Returns true if the layer should be visible and rendered for the specified time range.
Base class for storage of map layer temporal properties.
virtual QgsTemporalProperty::Flags flags() const
Returns flags associated to the temporal property.
Redraw the layer when temporal range changes, but don't apply any filtering. Useful when symbology or...
virtual void setDefaultsFromDataProviderTemporalCapabilities(const QgsDataProviderTemporalCapabilities *capabilities)=0
Sets the layers temporal settings to appropriate defaults based on a provider's temporal capabilities...
TemporalUnit
Temporal units.
Definition: qgsunittypes.h:149
Represents a vector layer which manages a vector based data sets.
const QgsField & field
Definition: qgsfield.h:471
TemporalMode
Mode of the vector temporal properties.