QGIS API Documentation 4.0.0-Norrköping (1ddcee3d0e4)
Loading...
Searching...
No Matches
qgstemporalutils.h
Go to the documentation of this file.
1/***************************************************************************
2 qgstemporalutils.h
3 ------------------
4 Date : March 2020
5 Copyright : (C) 2020 by Nyall Dawson
6 Email : nyall dot dawson at gmail dot com
7 ***************************************************************************
8 * *
9 * This program is free software; you can redistribute it and/or modify *
10 * it under the terms of the GNU General Public License as published by *
11 * the Free Software Foundation; either version 2 of the License, or *
12 * (at your option) any later version. *
13 * *
14 ***************************************************************************/
15
16#ifndef QGSTEMPORALUTILS_H
17#define QGSTEMPORALUTILS_H
18
19#include "qgis_core.h"
20#include "qgsinterval.h"
21#include "qgsrange.h"
22
23class QgsProject;
24class QgsMapSettings;
25class QgsFeedback;
27
28#ifndef SIP_RUN
29
40class CORE_EXPORT QgsTimeDuration
41{
42 public:
44 int years = 0;
46 int months = 0;
48 int weeks = 0;
50 int days = 0;
52 int hours = 0;
54 int minutes = 0;
56 double seconds = 0;
57
61 bool isNull() const { return !years && !months && !days && !hours && !minutes && !seconds; }
62
63 // TODO c++20 - replace with = default
64 bool operator==( const QgsTimeDuration &other ) const
65 {
66 return years == other.years && months == other.months && weeks == other.weeks && days == other.days && hours == other.hours && minutes == other.minutes && seconds == other.seconds;
67 }
68
69 bool operator!=( const QgsTimeDuration &other ) const { return !( *this == other ); }
70
74 QgsInterval toInterval() const;
75
79 QString toString() const;
80
87 long long toSeconds() const;
88
92 QDateTime addToDateTime( const QDateTime &dateTime ) const;
93
97 static QgsTimeDuration fromString( const QString &string, bool &ok );
98};
99#endif
100
101
109
110class CORE_EXPORT QgsTemporalUtils
111{
112 public:
120
132 static QList< QgsDateTimeRange > usedTemporalRangesForProject( QgsProject *project );
133
136 {
139
142
149
152
161
163 QList<QgsMapDecoration *> decorations;
164
176 QList<QgsDateTimeRange> availableTemporalRanges;
177
183 double frameRate = 30;
184 };
185
203 static bool exportAnimation( const QgsMapSettings &mapSettings, const AnimationExportSettings &settings, QString &error SIP_OUT, QgsFeedback *feedback = nullptr );
204
226 static QDateTime calculateFrameTime( const QDateTime &start, const long long frame, const QgsInterval &interval );
227
239 static QList< QDateTime > calculateDateTimesUsingDuration( const QDateTime &start, const QDateTime &end, const QString &duration, bool &ok SIP_OUT, bool &maxValuesExceeded SIP_OUT, int maxValues = -1 );
240
241#ifndef SIP_RUN
242
254 static QList< QDateTime > calculateDateTimesUsingDuration( const QDateTime &start, const QDateTime &end, const QgsTimeDuration &duration, bool &maxValuesExceeded SIP_OUT, int maxValues = -1 );
255#endif
256
266 static QList< QDateTime > calculateDateTimesFromISO8601( const QString &string, bool &ok SIP_OUT, bool &maxValuesExceeded SIP_OUT, int maxValues = -1 );
267};
268
269
270#endif // QGSTEMPORALUTILS_H
Base class for feedback objects to be used for cancellation of something running in a worker thread.
Definition qgsfeedback.h:44
A representation of the interval between two datetime values.
Definition qgsinterval.h:52
Interface for map decorations.
Contains configuration for rendering maps.
Encapsulates a QGIS project, including sets of map layers and their styles, layouts,...
Definition qgsproject.h:113
Contains utility methods for working with temporal layers and projects.
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 s...
static QgsDateTimeRange calculateTemporalRangeForProject(QgsProject *project)
Calculates the temporal range for a project.
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.
static QList< QgsDateTimeRange > usedTemporalRangesForProject(QgsProject *project)
Calculates all temporal ranges which are in use for a project.
static QDateTime calculateFrameTime(const QDateTime &start, const long long frame, const QgsInterval &interval)
Calculates the frame time for an animation.
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-23T0...
Contains utility methods for working with temporal layers and projects.
bool operator!=(const QgsTimeDuration &other) const
bool operator==(const QgsTimeDuration &other) const
int minutes
Minutes.
double seconds
Seconds.
bool isNull() const
Returns true if the duration is null, i.e.
#define SIP_OUT
Definition qgis_sip.h:57
QgsTemporalRange< QDateTime > QgsDateTimeRange
QgsRange which stores a range of date times.
Definition qgsrange.h:705
Contains settings relating to exporting animations.
double frameRate
Target animation frame rate in frames per second.
bool temporalRangeCumulative
The animation temporal range cumulative settings.
QgsDateTimeRange animationRange
Dictates the overall temporal range of the animation.
QList< QgsDateTimeRange > availableTemporalRanges
Contains the list of all available temporal ranges which have data available.
QgsInterval frameDuration
Duration of individual export frames.
QString fileNameTemplate
The filename template for exporting the frames.
QString outputDirectory
Destination directory for created image files.
QList< QgsMapDecoration * > decorations
List of decorations to draw onto exported frames.