Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[feature] Add basic temporal handling support for vector layers
This exposes some basic temporal capabilities for vector layers: - static time range for layer (to match raster layer possibilities), this sets a single static time range which applies to the whole layer. ALL features from the layer will be shown whenever the canvas time overlaps the layer time range - "Single field with datetime": Allows selection of a single date or datetime field from the layer. Features will be shown whenever this field value is within the canvas time range - "Separate Fields for Start and End Date/Time": Allows selection of start and end date/datetime fields from the layer. Features will be shown whenever the time interval calculated from these fields overlaps the canvas time range Some known limitations/inefficiencies: - currently only date/datetime fields can be used. This was done to simplify the format handling and avoid the need to worry about string fields with different datetime formats. In future we should allow selection of string fields and allow users to enter a custom datetime format string - unlike the Time Manager plugin approach, the approach taken here is to rely completely on QGIS expressions and feature requests to do the filtering (Time Manager uses layer filter strings and attempts to set a native SQL filter syntax so that filtering is done on the backend). This is intentional, because it provides a unified filter approach regardless of the provider used (i.e. we don't need to worry about the different SQL syntaxes used natively by the different providers). The beauty of feature request expression compilation **should** mean that the QGIS expressions are magically turned into native backend queries, BUUUUUUUUUUUT... because we lack QGIS expression support for date time literals, we currently rely on the "to_datetime" expression function and coerce everything through strings. None of the expression compilers handle this function, so currently ALL filtering is done on the QGIS side. We need to add functions for optimised datetime literal creation, and then ensure that the different compilers correctly map these literals across to the backend filter syntax to allow all the filtering work to be done on the database side... So currently, performance is much worse with large layers compared to Time Manager. But, the advantage is that we can use the native temporal framework and have vector layers animated alongside mesh and raster layers!
- Loading branch information
1 parent
66760b4
commit d98defe
Showing
30 changed files
with
1,321 additions
and
61 deletions.
There are no files selected for viewing
161 changes: 161 additions & 0 deletions
161
python/core/auto_generated/qgsvectorlayertemporalproperties.sip.in
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,161 @@ | ||
/************************************************************************ | ||
* This file has been generated automatically from * | ||
* * | ||
* src/core/qgsvectorlayertemporalproperties.h * | ||
* * | ||
* Do not edit manually ! Edit header and run scripts/sipify.pl again * | ||
************************************************************************/ | ||
|
||
|
||
|
||
|
||
|
||
|
||
class QgsVectorLayerTemporalProperties : QgsMapLayerTemporalProperties | ||
{ | ||
%Docstring | ||
Implementation of map layer temporal properties for vector layers. | ||
|
||
.. versionadded:: 3.14 | ||
%End | ||
|
||
%TypeHeaderCode | ||
#include "qgsvectorlayertemporalproperties.h" | ||
%End | ||
public: | ||
|
||
QgsVectorLayerTemporalProperties( QObject *parent /TransferThis/ = 0, bool enabled = false ); | ||
%Docstring | ||
Constructor for QgsVectorLayerTemporalProperties, with the specified ``parent`` object. | ||
|
||
The ``enabled`` argument specifies whether the temporal properties are initially enabled or not (see isActive()). | ||
%End | ||
|
||
virtual bool isVisibleInTemporalRange( const QgsDateTimeRange &range ) const; | ||
|
||
|
||
enum TemporalMode | ||
{ | ||
ModeFixedTemporalRange, | ||
ModeFeatureDateTimeInstantFromField, | ||
ModeFeatureDateTimeStartAndEndFromFields, | ||
}; | ||
|
||
TemporalMode mode() const; | ||
%Docstring | ||
Returns the temporal properties mode. | ||
|
||
.. seealso:: :py:func:`setMode` | ||
%End | ||
|
||
void setMode( TemporalMode mode ); | ||
%Docstring | ||
Sets the temporal properties ``mode``. | ||
|
||
.. seealso:: :py:func:`mode` | ||
%End | ||
|
||
void setFixedTemporalRange( const QgsDateTimeRange &range ); | ||
%Docstring | ||
Sets a temporal ``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 ``range``. | ||
|
||
.. warning:: | ||
|
||
This setting is only effective when mode() is | ||
QgsVectorLayerTemporalProperties.ModeFixedTemporalRange | ||
|
||
.. seealso:: :py:func:`fixedTemporalRange` | ||
%End | ||
|
||
const QgsDateTimeRange &fixedTemporalRange() const; | ||
%Docstring | ||
Returns the fixed temporal range for the layer. | ||
|
||
.. warning:: | ||
|
||
To be used only when mode() is | ||
QgsVectorLayerTemporalProperties.ModeFixedTemporalRange | ||
|
||
.. seealso:: :py:func:`setFixedTemporalRange` | ||
%End | ||
|
||
QString startField() const; | ||
%Docstring | ||
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. | ||
|
||
.. seealso:: :py:func:`setStartField` | ||
|
||
.. seealso:: :py:func:`endField` | ||
%End | ||
|
||
void setStartField( const QString &field ); | ||
%Docstring | ||
Sets 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. | ||
|
||
.. seealso:: :py:func:`startField` | ||
|
||
.. seealso:: :py:func:`setEndField` | ||
%End | ||
|
||
QString endField() const; | ||
%Docstring | ||
Returns the name of the end datetime field, which | ||
contains the end time for the feature's time spans. | ||
|
||
.. seealso:: :py:func:`setEndField` | ||
|
||
.. seealso:: :py:func:`startField` | ||
%End | ||
|
||
void setEndField( const QString &field ); | ||
%Docstring | ||
Sets the name of the end datetime ``field``, which | ||
contains the end time for the feature's time spans. | ||
|
||
.. seealso:: :py:func:`endField` | ||
|
||
.. seealso:: :py:func:`setStartField` | ||
%End | ||
|
||
QString createFilterString( QgsVectorLayer *layer, const QgsDateTimeRange &range ) const; | ||
%Docstring | ||
Creates a QGIS expression filter string for filtering features from ``layer`` | ||
to those within the specified time ``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. | ||
%End | ||
|
||
virtual QDomElement writeXml( QDomElement &element, QDomDocument &doc, const QgsReadWriteContext &context ); | ||
|
||
virtual bool readXml( const QDomElement &element, const QgsReadWriteContext &context ); | ||
|
||
virtual void setDefaultsFromDataProviderTemporalCapabilities( const QgsDataProviderTemporalCapabilities *capabilities ); | ||
|
||
|
||
}; | ||
|
||
/************************************************************************ | ||
* This file has been generated automatically from * | ||
* * | ||
* src/core/qgsvectorlayertemporalproperties.h * | ||
* * | ||
* Do not edit manually ! Edit header and run scripts/sipify.pl again * | ||
************************************************************************/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
43 changes: 43 additions & 0 deletions
43
python/gui/auto_generated/qgsvectorlayertemporalpropertieswidget.sip.in
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
/************************************************************************ | ||
* This file has been generated automatically from * | ||
* * | ||
* src/gui/qgsvectorlayertemporalpropertieswidget.h * | ||
* * | ||
* Do not edit manually ! Edit header and run scripts/sipify.pl again * | ||
************************************************************************/ | ||
|
||
|
||
|
||
|
||
|
||
class QgsVectorLayerTemporalPropertiesWidget : QWidget | ||
{ | ||
%Docstring | ||
A widget for configuring the temporal properties for a vector layer. | ||
|
||
.. versionadded:: 3.14 | ||
%End | ||
|
||
%TypeHeaderCode | ||
#include "qgsvectorlayertemporalpropertieswidget.h" | ||
%End | ||
public: | ||
|
||
QgsVectorLayerTemporalPropertiesWidget( QWidget *parent = 0, QgsVectorLayer *layer = 0 ); | ||
%Docstring | ||
Constructor for QgsVectorLayerTemporalPropertiesWidget. | ||
%End | ||
|
||
void saveTemporalProperties(); | ||
%Docstring | ||
Save widget temporal properties inputs. | ||
%End | ||
|
||
}; | ||
/************************************************************************ | ||
* This file has been generated automatically from * | ||
* * | ||
* src/gui/qgsvectorlayertemporalpropertieswidget.h * | ||
* * | ||
* Do not edit manually ! Edit header and run scripts/sipify.pl again * | ||
************************************************************************/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.