QGIS API Documentation 3.99.0-Master (2fe06baccd8)
Loading...
Searching...
No Matches
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.h"
23#include "qgis_core.h"
24#include "qgis_sip.h"
26#include "qgsrange.h"
27
28class QgsVectorLayer;
29class QgsFields;
30
40{
41 public:
42
48 QgsVectorLayer *layer() const;
49
56
57 private:
58
59 QgsVectorLayer *mLayer = nullptr;
60};
61
70{
71 Q_OBJECT
72
73 public:
74
80 QgsVectorLayerTemporalProperties( QObject *parent SIP_TRANSFERTHIS = nullptr, bool enabled = false );
81
82 bool isVisibleInTemporalRange( const QgsDateTimeRange &range ) const override;
84
91
98
106
114
118 QgsTemporalProperty::Flags flags() const override;
119
130 void setFixedTemporalRange( const QgsDateTimeRange &range );
131
141
152 QString startField() const;
153
164 void setStartField( const QString &field );
165
173 QString endField() const;
174
182 void setEndField( const QString &field );
183
193 QString startExpression() const;
194
204 void setStartExpression( const QString &expression );
205
215 QString endExpression() const;
216
226 void setEndExpression( const QString &endExpression );
227
240 QString durationField() const;
241
254 void setDurationField( const QString &field );
255
262
269
281 double fixedDuration() const;
282
294 void setFixedDuration( double duration );
295
305 bool accumulateFeatures() const;
306
316 void setAccumulateFeatures( bool accumulate );
317
330 QString createFilterString( const QgsVectorLayerTemporalContext &context, const QgsDateTimeRange &range ) const;
331
336 void guessDefaultsFromFields( const QgsFields &fields );
337
338 QDomElement writeXml( QDomElement &element, QDomDocument &doc, const QgsReadWriteContext &context ) override;
339 bool readXml( const QDomElement &element, const QgsReadWriteContext &context ) override;
341
342 private:
343
346
349
351 QgsDateTimeRange mFixedRange;
352
353 QString mStartFieldName;
354 QString mEndFieldName;
355 QString mDurationFieldName;
357
358 double mFixedDuration = 0;
359
360 bool mAccumulateFeatures = false;
361
362 QString mStartExpression;
363 QString mEndExpression;
364
365};
366
367#endif // QGSVECTORLAYERTEMPORALPROPERTIES_H
VectorTemporalMode
Vector layer temporal feature modes.
Definition qgis.h:2580
@ FixedTemporalRange
Mode when temporal properties have fixed start and end datetimes.
Definition qgis.h:2581
TemporalUnit
Temporal units.
Definition qgis.h:5159
@ Minutes
Minutes.
Definition qgis.h:5162
VectorTemporalLimitMode
Mode for the handling of the limits of the filtering timeframe for vector features.
Definition qgis.h:2596
@ IncludeBeginExcludeEnd
Default mode: include the Begin limit, but exclude the End limit.
Definition qgis.h:2597
Base class for handling properties relating to a data provider's temporal capabilities.
Container of fields for a vector layer.
Definition qgsfields.h:46
QgsMapLayerTemporalProperties(QObject *parent, bool enabled=false)
Constructor for QgsMapLayerTemporalProperties, with the specified parent object.
Base class for all map layer types.
Definition qgsmaplayer.h:80
A container for the context for various read/write operations on objects.
Encapsulates the context in which a QgsVectorLayer's temporal capabilities will be applied.
QgsVectorLayer * layer() const
Returns the associated layer.
void setLayer(QgsVectorLayer *layer)
Sets the associated layer.
void guessDefaultsFromFields(const QgsFields &fields)
Attempts to setup the temporal properties by scanning a set of fields and looking for standard naming...
QString endExpression() const
Returns the expression for the end time for the feature's time spans.
void setDurationField(const QString &field)
Sets the name of the duration field, which contains the duration of the event.
void setMode(Qgis::VectorTemporalMode mode)
Sets the temporal properties mode.
QgsVectorLayerTemporalProperties(QObject *parent=nullptr, bool enabled=false)
Constructor for QgsVectorLayerTemporalProperties, with the specified parent object.
void setStartExpression(const QString &expression)
Sets the expression to use for the start time for the feature's time spans.
bool isVisibleInTemporalRange(const QgsDateTimeRange &range) const override
Returns true if the layer should be visible and rendered for the specified time range.
Qgis::VectorTemporalLimitMode limitMode() const
Returns the temporal limit mode (to include or exclude begin/end limits).
void setLimitMode(Qgis::VectorTemporalLimitMode mode)
Sets the temporal limit mode (to include or exclude begin/end limits).
const QgsDateTimeRange & fixedTemporalRange() const
Returns the fixed temporal range for the layer.
double fixedDuration() const
Returns the fixed duration length, which contains the duration of the event.
bool accumulateFeatures() const
Returns true if features will be accumulated over time (i.e.
QgsTemporalProperty::Flags flags() const override
Returns flags associated to the temporal property.
void setFixedTemporalRange(const QgsDateTimeRange &range)
Sets a temporal range to apply to the whole layer.
bool readXml(const QDomElement &element, const QgsReadWriteContext &context) override
Reads temporal properties from a DOM element previously written by writeXml().
void setEndExpression(const QString &endExpression)
Sets the expression to use for the end time for the feature's time spans.
QString durationField() const
Returns the name of the duration field, which contains the duration of the event.
void setDurationUnits(Qgis::TemporalUnit units)
Sets the units of the event's duration.
QString endField() const
Returns the name of the end datetime field, which contains the end time for the feature's time spans.
QString createFilterString(const QgsVectorLayerTemporalContext &context, const QgsDateTimeRange &range) const
Creates a QGIS expression filter string for filtering features within the specified context to those ...
QDomElement writeXml(QDomElement &element, QDomDocument &doc, const QgsReadWriteContext &context) override
Writes the properties to a DOM element, to be used later with readXml().
Qgis::TemporalUnit durationUnits() const
Returns the units of the event's duration.
void setAccumulateFeatures(bool accumulate)
Sets whether features will be accumulated over time (i.e.
void setFixedDuration(double duration)
Sets the fixed event duration, which contains the duration of the event.
void setEndField(const QString &field)
Sets the name of the end datetime field, which contains the end time for the feature's time spans.
QgsDateTimeRange calculateTemporalExtent(QgsMapLayer *layer) const override
Attempts to calculate the overall temporal extent for the specified layer, using the settings defined...
void setDefaultsFromDataProviderTemporalCapabilities(const QgsDataProviderTemporalCapabilities *capabilities) override
Sets the layers temporal settings to appropriate defaults based on a provider's temporal capabilities...
Qgis::VectorTemporalMode mode() const
Returns the temporal properties mode.
QString startField() const
Returns the name of the start datetime field, which contains the start time for the feature's time sp...
void setStartField(const QString &field)
Sets the name of the start datetime field, which contains the start time for the feature's time spans...
QString startExpression() const
Returns the expression for the start time for the feature's time spans.
Represents a vector layer which manages a vector based dataset.
#define SIP_TRANSFERTHIS
Definition qgis_sip.h:53
#define SIP_SKIP
Definition qgis_sip.h:134
QgsTemporalRange< QDateTime > QgsDateTimeRange
QgsRange which stores a range of date times.
Definition qgsrange.h:761