QGIS API Documentation 4.1.0-Master (60fea48833c)
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:
47 QgsVectorLayer *layer() const;
48
55
56 private:
57 QgsVectorLayer *mLayer = nullptr;
58};
59
68{
69 Q_OBJECT
70
71 public:
77 QgsVectorLayerTemporalProperties( QObject *parent SIP_TRANSFERTHIS = nullptr, bool enabled = false );
78
79 bool isVisibleInTemporalRange( const QgsDateTimeRange &range ) const override;
81
88
95
103
111
115 QgsTemporalProperty::Flags flags() const override;
116
127 void setFixedTemporalRange( const QgsDateTimeRange &range );
128
138
149 QString startField() const;
150
161 void setStartField( const QString &field );
162
170 QString endField() const;
171
179 void setEndField( const QString &field );
180
190 QString startExpression() const;
191
201 void setStartExpression( const QString &expression );
202
212 QString endExpression() const;
213
223 void setEndExpression( const QString &endExpression );
224
237 QString durationField() const;
238
251 void setDurationField( const QString &field );
252
259
266
278 double fixedDuration() const;
279
291 void setFixedDuration( double duration );
292
302 bool accumulateFeatures() const;
303
313 void setAccumulateFeatures( bool accumulate );
314
327 QString createFilterString( const QgsVectorLayerTemporalContext &context, const QgsDateTimeRange &range ) const;
328
333 void guessDefaultsFromFields( const QgsFields &fields );
334
335 QDomElement writeXml( QDomElement &element, QDomDocument &doc, const QgsReadWriteContext &context ) override;
336 bool readXml( const QDomElement &element, const QgsReadWriteContext &context ) override;
338
339 private:
342
345
347 QgsDateTimeRange mFixedRange;
348
349 QString mStartFieldName;
350 QString mEndFieldName;
351 QString mDurationFieldName;
353
354 double mFixedDuration = 0;
355
356 bool mAccumulateFeatures = false;
357
358 QString mStartExpression;
359 QString mEndExpression;
360};
361
362#endif // QGSVECTORLAYERTEMPORALPROPERTIES_H
VectorTemporalMode
Vector layer temporal feature modes.
Definition qgis.h:2669
@ FixedTemporalRange
Mode when temporal properties have fixed start and end datetimes.
Definition qgis.h:2670
TemporalUnit
Temporal units.
Definition qgis.h:5316
@ Minutes
Minutes.
Definition qgis.h:5319
VectorTemporalLimitMode
Mode for the handling of the limits of the filtering timeframe for vector features.
Definition qgis.h:2687
@ IncludeBeginExcludeEnd
Default mode: include the Begin limit, but exclude the End limit.
Definition qgis.h:2688
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:83
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:52
#define SIP_SKIP
Definition qgis_sip.h:133
QgsTemporalRange< QDateTime > QgsDateTimeRange
QgsRange which stores a range of date times.
Definition qgsrange.h:705