QGIS API Documentation  3.25.0-Master (dec16ba68b)
Classes | Static Public Member Functions | List of all members
QgsTemporalUtils Class Reference

Contains utility methods for working with temporal layers and projects. More...

#include <qgstemporalutils.h>

Classes

struct  AnimationExportSettings
 Contains settings relating to exporting animations. More...
 

Static Public Member Functions

static QList< QDateTime > calculateDateTimesFromISO8601 (const QString &string, bool &ok, bool &maxValuesExceeded, int maxValues=-1)
 Calculates a complete list of datetimes from a ISO8601 string containing a duration (eg "2021-03-23T00:00:00Z/2021-03-24T12:00:00Z/PT12H"). More...
 
static QList< QDateTime > calculateDateTimesUsingDuration (const QDateTime &start, const QDateTime &end, const QgsTimeDuration &duration, bool &maxValuesExceeded, int maxValues=-1)
 Calculates a complete list of datetimes between start and end, using the specified ISO8601 duration string (eg "PT12H"). More...
 
static QList< QDateTime > calculateDateTimesUsingDuration (const QDateTime &start, const QDateTime &end, const QString &duration, bool &ok, bool &maxValuesExceeded, int maxValues=-1)
 Calculates a complete list of datetimes between start and end, using the specified ISO8601 duration string (eg "PT12H"). More...
 
static QDateTime calculateFrameTime (const QDateTime &start, const long long frame, const QgsInterval &interval)
 Calculates the frame time for an animation. More...
 
static QgsDateTimeRange calculateTemporalRangeForProject (QgsProject *project)
 Calculates the temporal range for a project. More...
 
static bool exportAnimation (const QgsMapSettings &mapSettings, const AnimationExportSettings &settings, QString &error, QgsFeedback *feedback=nullptr)
 Exports animation frames by rendering the map to multiple destination images. More...
 
static QList< QgsDateTimeRange > usedTemporalRangesForProject (QgsProject *project)
 Calculates all temporal ranges which are in use for a project. More...
 

Detailed Description

Contains utility methods for working with temporal layers and projects.

Since
QGIS 3.14

Definition at line 121 of file qgstemporalutils.h.

Member Function Documentation

◆ calculateDateTimesFromISO8601()

QList< QDateTime > QgsTemporalUtils::calculateDateTimesFromISO8601 ( const QString &  string,
bool &  ok,
bool &  maxValuesExceeded,
int  maxValues = -1 
)
static

Calculates a complete list of datetimes from a ISO8601 string containing a duration (eg "2021-03-23T00:00:00Z/2021-03-24T12:00:00Z/PT12H").

Parameters
stringISO8601 compatible string
okwill be set to true if string was successfully parsed and date times could be calculated
maxValuesExceededwill be set to true if the maximum number of values to return was exceeded
maxValuesmaximum number of values to return, or -1 to return all values
Returns
calculated list of date times
Since
QGIS 3.20

Definition at line 256 of file qgstemporalutils.cpp.

◆ calculateDateTimesUsingDuration() [1/2]

QList< QDateTime > QgsTemporalUtils::calculateDateTimesUsingDuration ( const QDateTime &  start,
const QDateTime &  end,
const QgsTimeDuration duration,
bool &  maxValuesExceeded,
int  maxValues = -1 
)
static

Calculates a complete list of datetimes between start and end, using the specified ISO8601 duration string (eg "PT12H").

Parameters
startstart date time
endend date time
durationISO8601 duration
maxValuesExceededwill be set to true if the maximum number of values to return was exceeded
maxValuesmaximum number of values to return, or -1 to return all values
Returns
calculated list of date times
Note
Not available in Python bindings
Since
QGIS 3.20

Definition at line 229 of file qgstemporalutils.cpp.

◆ calculateDateTimesUsingDuration() [2/2]

QList< QDateTime > QgsTemporalUtils::calculateDateTimesUsingDuration ( const QDateTime &  start,
const QDateTime &  end,
const QString &  duration,
bool &  ok,
bool &  maxValuesExceeded,
int  maxValues = -1 
)
static

Calculates a complete list of datetimes between start and end, using the specified ISO8601 duration string (eg "PT12H").

Parameters
startstart date time
endend date time
durationISO8601 duration string
okwill be set to true if duration was successfully parsed and date times could be calculated
maxValuesExceededwill be set to true if the maximum number of values to return was exceeded
maxValuesmaximum number of values to return, or -1 to return all values
Returns
calculated list of date times
Since
QGIS 3.20

Definition at line 213 of file qgstemporalutils.cpp.

◆ calculateFrameTime()

QDateTime QgsTemporalUtils::calculateFrameTime ( const QDateTime &  start,
const long long  frame,
const QgsInterval interval 
)
static

Calculates the frame time for an animation.

If the interval original duration is fractional or interval original unit is unknown (QgsUnitTypes::TemporalUnit::TemporalUnknownUnit), then QgsInterval is used to determine the duration of the frame. This uses average durations for months and years.

Otherwise, we use QDateTime to advance by the exact duration of the current month or year. So a time step of 1.5 months will result in a duration of 45 days, but a time step of 1 month will result in a duration that depends upon the number of days in the current month.

Parameters
starttime of the animation
framenumber
intervalduration of the animation
Returns
The calculated datetime for the frame.
Since
QGIS 3.18

Definition at line 167 of file qgstemporalutils.cpp.

◆ calculateTemporalRangeForProject()

QgsDateTimeRange QgsTemporalUtils::calculateTemporalRangeForProject ( QgsProject project)
static

Calculates the temporal range for a project.

This method considers the temporal range available from layers contained within the project and returns the maximal combined temporal extent of these layers.

Definition at line 33 of file qgstemporalutils.cpp.

◆ exportAnimation()

bool QgsTemporalUtils::exportAnimation ( const QgsMapSettings mapSettings,
const AnimationExportSettings settings,
QString &  error,
QgsFeedback feedback = nullptr 
)
static

Exports animation frames by rendering the map to multiple destination images.

The mapSettings argument dictates the overall map settings such as extent and size, while animation and export specific settings are specified via the settings argument.

An optional feedback argument can be used to provide progress reports and cancellation support.

Parameters
mapSettingssettings controlling the map render
settingsanimation and export settings
errorwill be set to a descriptive error message if the export fails
feedbackoptional feedback object for progress reports and cancellation checks
Returns
true if the export was successful.

Definition at line 74 of file qgstemporalutils.cpp.

◆ usedTemporalRangesForProject()

QList< QgsDateTimeRange > QgsTemporalUtils::usedTemporalRangesForProject ( QgsProject project)
static

Calculates all temporal ranges which are in use for a project.

This method considers the temporal range available from layers contained within the project and returns a list of ranges which cover only the temporal ranges which are actually in use by layers in the project.

The returned list may be non-contiguous and have gaps in the ranges. The ranges are sorted in ascending order.

Since
QGIS 3.20

Definition at line 56 of file qgstemporalutils.cpp.


The documentation for this class was generated from the following files: