QGIS API Documentation  3.26.3-Buenos Aires (65e4edfdad)
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.h"
24 #include "qgis_sip.h"
25 #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 
91  Qgis::VectorTemporalMode mode() const;
92 
98  void setMode( Qgis::VectorTemporalMode mode );
99 
106  Qgis::VectorTemporalLimitMode limitMode() const;
107 
114  void setLimitMode( Qgis::VectorTemporalLimitMode mode );
115 
119  QgsTemporalProperty::Flags flags() const override;
120 
131  void setFixedTemporalRange( const QgsDateTimeRange &range );
132 
141  const QgsDateTimeRange &fixedTemporalRange() const;
142 
153  QString startField() const;
154 
165  void setStartField( const QString &field );
166 
174  QString endField() const;
175 
183  void setEndField( const QString &field );
184 
194  QString startExpression() const;
195 
205  void setStartExpression( const QString &expression );
206 
216  QString endExpression() const;
217 
227  void setEndExpression( const QString &endExpression );
228 
241  QString durationField() const;
242 
255  void setDurationField( const QString &field );
256 
262  QgsUnitTypes::TemporalUnit durationUnits() const;
263 
269  void setDurationUnits( QgsUnitTypes::TemporalUnit units );
270 
282  double fixedDuration() const;
283 
295  void setFixedDuration( double duration );
296 
306  bool accumulateFeatures() const;
307 
317  void setAccumulateFeatures( bool accumulate );
318 
331  QString createFilterString( const QgsVectorLayerTemporalContext &context, const QgsDateTimeRange &range ) const;
332 
337  void guessDefaultsFromFields( const QgsFields &fields );
338 
339  QDomElement writeXml( QDomElement &element, QDomDocument &doc, const QgsReadWriteContext &context ) override;
340  bool readXml( const QDomElement &element, const QgsReadWriteContext &context ) override;
342 
343  private:
344 
346  Qgis::VectorTemporalMode mMode = Qgis::VectorTemporalMode::FixedTemporalRange;
347 
350 
352  QgsDateTimeRange mFixedRange;
353 
354  QString mStartFieldName;
355  QString mEndFieldName;
356  QString mDurationFieldName;
358 
359  double mFixedDuration = 0;
360 
361  bool mAccumulateFeatures = false;
362 
363  QString mStartExpression;
364  QString mEndExpression;
365 
366 };
367 
368 #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
The class is used as a container of context for various read/write operations on other objects.
Definition: qgsreadwritecontext.h:34
QgsFields
Container of fields for a vector layer.
Definition: qgsfields.h:44
qgis.h
qgsunittypes.h
Qgis::VectorTemporalMode
VectorTemporalMode
Vector layer temporal feature modes.
Definition: qgis.h:1166
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
field
const QgsField & field
Definition: qgsfield.h:463
QgsUnitTypes::TemporalUnit
TemporalUnit
Temporal units.
Definition: qgsunittypes.h:149
QgsMapLayerTemporalProperties::readXml
virtual bool readXml(const QDomElement &element, const QgsReadWriteContext &context)=0
Reads temporal properties from a DOM element previously written by writeXml().
QgsDataProviderTemporalCapabilities
Base class for handling properties relating to a data provider's temporal capabilities.
Definition: qgsdataprovidertemporalcapabilities.h:33
qgsmaplayertemporalproperties.h
SIP_SKIP
#define SIP_SKIP
Definition: qgis_sip.h:126
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
Implementation of map layer temporal properties for vector layers.
Definition: qgsvectorlayertemporalproperties.h:70
QgsMapLayerTemporalProperties
Base class for storage of map layer temporal properties.
Definition: qgsmaplayertemporalproperties.h:42
QgsVectorLayerTemporalContext
Encapsulates the context in which a QgsVectorLayer's temporal capabilities will be applied.
Definition: qgsvectorlayertemporalproperties.h:40
Qgis::VectorTemporalLimitMode::IncludeBeginExcludeEnd
@ IncludeBeginExcludeEnd
Default mode: include the Begin limit, but exclude the End limit.
QgsUnitTypes::TemporalMinutes
@ TemporalMinutes
Minutes.
Definition: qgsunittypes.h:153
QgsVectorLayer
Represents a vector layer which manages a vector based data sets.
Definition: qgsvectorlayer.h:391
QgsMapLayer
Base class for all map layer types. This is the base class for all map layer types (vector,...
Definition: qgsmaplayer.h:72
QgsMapLayerTemporalProperties::setDefaultsFromDataProviderTemporalCapabilities
virtual void setDefaultsFromDataProviderTemporalCapabilities(const QgsDataProviderTemporalCapabilities *capabilities)=0
Sets the layers temporal settings to appropriate defaults based on a provider's temporal capabilities...
Qgis::VectorTemporalLimitMode
VectorTemporalLimitMode
Mode for the handling of the limits of the filtering timeframe for vector features.
Definition: qgis.h:1182
SIP_TRANSFERTHIS
#define SIP_TRANSFERTHIS
Definition: qgis_sip.h:53