QGIS API Documentation  3.20.0-Odense (decaadbb31)
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 "qgsrange.h"
21 #include "qgsinterval.h"
22 
23 class QgsProject;
24 class QgsMapSettings;
25 class QgsFeedback;
26 class QgsMapDecoration;
27 
28 #ifndef SIP_RUN
29 
40 class CORE_EXPORT QgsTimeDuration
41 {
42  public:
43 
45  int years = 0;
47  int months = 0;
49  int weeks = 0;
51  int days = 0;
53  int hours = 0;
55  int minutes = 0;
57  double seconds = 0;
58 
62  bool isNull() const
63  {
64  return !years && !months && !days &&
65  !hours && !minutes && !seconds;
66  }
67 
68  bool operator==( const QgsTimeDuration &other ) const
69  {
70  return years == other.years && months == other.months &&
71  days == other.days && hours == other.hours &&
72  minutes == other.minutes && seconds == other.seconds;
73  }
74 
75  bool operator!=( const QgsTimeDuration &other ) const
76  {
77  return !( *this == other );
78  }
79 
83  QgsInterval toInterval() const;
84 
88  QString toString() const;
89 
96  long long toSeconds() const;
97 
101  QDateTime addToDateTime( const QDateTime &dateTime );
102 
106  static QgsTimeDuration fromString( const QString &string, bool &ok );
107 
108 };
109 #endif
110 
111 
120 class CORE_EXPORT QgsTemporalUtils
121 {
122  public:
123 
130  static QgsDateTimeRange calculateTemporalRangeForProject( QgsProject *project );
131 
143  static QList< QgsDateTimeRange > usedTemporalRangesForProject( QgsProject *project );
144 
147  {
149  QgsDateTimeRange animationRange;
150 
153 
156 
165 
167  QList<QgsMapDecoration *> decorations;
168 
169  };
170 
188  static bool exportAnimation( const QgsMapSettings &mapSettings, const AnimationExportSettings &settings, QString &error SIP_OUT, QgsFeedback *feedback = nullptr );
189 
211  static QDateTime calculateFrameTime( const QDateTime &start, const long long frame, const QgsInterval &interval );
212 
224  static QList< QDateTime > calculateDateTimesUsingDuration( const QDateTime &start, const QDateTime &end, const QString &duration, bool &ok SIP_OUT, bool &maxValuesExceeded SIP_OUT, int maxValues = -1 );
225 
226 #ifndef SIP_RUN
227 
239  static QList< QDateTime > calculateDateTimesUsingDuration( const QDateTime &start, const QDateTime &end, const QgsTimeDuration &duration, bool &maxValuesExceeded SIP_OUT, int maxValues = -1 );
240 #endif
241 
251  static QList< QDateTime > calculateDateTimesFromISO8601( const QString &string, bool &ok SIP_OUT, bool &maxValuesExceeded SIP_OUT, int maxValues = -1 );
252 
253 };
254 
255 
256 #endif // QGSTEMPORALUTILS_H
Base class for feedback objects to be used for cancellation of something running in a worker thread.
Definition: qgsfeedback.h:45
A representation of the interval between two datetime values.
Definition: qgsinterval.h:42
Interface for map decorations.
The QgsMapSettings class contains configuration for rendering of the map.
Encapsulates a QGIS project, including sets of map layers and their styles, layouts,...
Definition: qgsproject.h:99
Contains utility methods for working with temporal layers and projects.
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:58
Contains settings relating to exporting animations.
QgsDateTimeRange animationRange
Dictates the overall temporal range of the animation.
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.