-
-
Notifications
You must be signed in to change notification settings - Fork 3k
/
qgsvectorlayertemporalproperties.h
173 lines (147 loc) · 6.11 KB
/
qgsvectorlayertemporalproperties.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
/***************************************************************************
qgsvectorlayertemporalproperties.h
---------------
begin : May 2020
copyright : (C) 2020 by Nyall Dawson
email : nyall dot dawson at gmail dot com
***************************************************************************/
/***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
#ifndef QGSVECTORLAYERTEMPORALPROPERTIES_H
#define QGSVECTORLAYERTEMPORALPROPERTIES_H
#include "qgis_core.h"
#include "qgis_sip.h"
#include "qgsrange.h"
#include "qgsmaplayertemporalproperties.h"
#include "qgsrasterdataprovidertemporalcapabilities.h"
class QgsVectorLayer;
/**
* \class QgsVectorLayerTemporalProperties
* \ingroup core
* Implementation of map layer temporal properties for vector layers.
*
* \since QGIS 3.14
*/
class CORE_EXPORT QgsVectorLayerTemporalProperties : public QgsMapLayerTemporalProperties
{
Q_OBJECT
public:
/**
* Constructor for QgsVectorLayerTemporalProperties, with the specified \a parent object.
*
* The \a enabled argument specifies whether the temporal properties are initially enabled or not (see isActive()).
*/
QgsVectorLayerTemporalProperties( QObject *parent SIP_TRANSFERTHIS = nullptr, bool enabled = false );
bool isVisibleInTemporalRange( const QgsDateTimeRange &range ) const override;
QgsDateTimeRange calculateTemporalExtent( QgsMapLayer *layer ) const override SIP_SKIP;
/**
* Mode of the vector temporal properties
**/
enum TemporalMode
{
ModeFixedTemporalRange = 0, //!< Mode when temporal properties have fixed start and end datetimes.
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 rule based renderer expressions depend on the time range.
};
/**
* Returns the temporal properties mode.
*
*\see setMode()
**/
TemporalMode mode() const;
/**
* Sets the temporal properties \a mode.
*
*\see mode()
**/
void setMode( TemporalMode mode );
/**
* Sets a temporal \a range to apply to the whole layer. All features from
* the layer will be rendered whenever the current datetime range of
* a render context intersects the specified \a range.
*
* \warning This setting is only effective when mode() is
* QgsVectorLayerTemporalProperties::ModeFixedTemporalRange
*
* \see fixedTemporalRange()
*/
void setFixedTemporalRange( const QgsDateTimeRange &range );
/**
* Returns the fixed temporal range for the layer.
*
* \warning To be used only when mode() is
* QgsVectorLayerTemporalProperties::ModeFixedTemporalRange
*
* \see setFixedTemporalRange()
**/
const QgsDateTimeRange &fixedTemporalRange() const;
/**
* Returns the name of the start datetime field, which
* contains the start time for the feature's time spans.
*
* If mode() is ModeFeatureDateTimeInstantFromField, then this field
* represents both the start AND end times.
*
* \see setStartField()
* \see endField()
*/
QString startField() const;
/**
* Sets the name of the start datetime \a field, which
* contains the start time for the feature's time spans.
*
* If mode() is ModeFeatureDateTimeInstantFromField, then this field
* represents both the start AND end times.
*
* \see startField()
* \see setEndField()
*/
void setStartField( const QString &field );
/**
* Returns the name of the end datetime field, which
* contains the end time for the feature's time spans.
*
* \see setEndField()
* \see startField()
*/
QString endField() const;
/**
* Sets the name of the end datetime \a field, which
* contains the end time for the feature's time spans.
*
* \see endField()
* \see setStartField()
*/
void setEndField( const QString &field );
/**
* Creates a QGIS expression filter string for filtering features from \a layer
* to those within the specified time \a range.
*
* The returned expression string considers the mode() and other related
* settings (such as startField()) when building the filter string.
*
* \warning Note that ModeFixedTemporalRange is intentional NOT handled by this method
* and if mode() is ModeFixedTemporalRange then an empty string will be returned. Use
* isVisibleInTemporalRange() when testing whether features from a layer set to the
* ModeFixedTemporalRange should ALL be filtered out.
*/
QString createFilterString( QgsVectorLayer *layer, const QgsDateTimeRange &range ) const;
QDomElement writeXml( QDomElement &element, QDomDocument &doc, const QgsReadWriteContext &context ) override;
bool readXml( const QDomElement &element, const QgsReadWriteContext &context ) override;
void setDefaultsFromDataProviderTemporalCapabilities( const QgsDataProviderTemporalCapabilities *capabilities ) override;
private:
//! Temporal layer mode.
TemporalMode mMode = ModeFixedTemporalRange;
//! Represents fixed temporal range.
QgsDateTimeRange mFixedRange;
QString mStartFieldName;
QString mEndFieldName;
};
#endif // QGSVECTORLAYERTEMPORALPROPERTIES_H