Subversion Repositories public iLand

Rev

Rev 193 | Rev 201 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
1
 
193 werner 2
#ifndef CLIMATE_H
3
#define CLIMATE_H
4
 
5
#include <QtSql>
6
 
7
struct ClimateDay
8
{
9
    int year; // year
10
    int month; // month
11
    int day; // day of year
12
    double temperature; // average day °C
198 werner 13
    double temp_delayed; // temperature delayed (after Maekela, 2008) for response calculations
193 werner 14
    double preciptitation; // sum of day [mm]
15
    double radiation; // sum of day (MJ/m2)
16
    double vpd; // average of day [kPa]
198 werner 17
    QString date() { return QString("%1.%2.%3").arg(day).arg(month).arg(year); }
193 werner 18
};
19
class Climate
20
{
21
public:
22
    Climate();
23
    void setup(); ///< setup routine that opens database connection
24
    // activity
25
    void nextYear();
198 werner 26
    // access to climate data
27
    const ClimateDay *dayOfYear(const int dayofyear); ///< get pointer to climate structure by day of year (0-based-index)
28
    const ClimateDay *day(const int month, const int day); ///< gets pointer to climate structure of given day (0-based indices, i.e. month=11=december!)
29
    /// returns two pointer (arguments!!!) to the begin and one after end of the given month (month: 0..11)
30
    void monthRange(const int month, ClimateDay **rBegin, ClimateDay **rEnd);
31
    int days(const int month); ///< returns number of days of given month
193 werner 32
 
33
private:
34
    void load(); ///< load mLoadYears years from database
198 werner 35
    void climateCalculations(); ///< more calculations done after loading of climate data
193 werner 36
    int mLoadYears; // count of years to load ahead
37
    int mCurrentYear; // current year (relative)
38
    int mMinYear; // lowest year in store (relative)
39
    int mMaxYear;  // highest year in store (relative)
40
    QVector<ClimateDay> mStore; ///< storage of climate data
41
    QVector<int> mDayIndices; ///< store indices for month / years within store
42
    QSqlQuery mClimateQuery; ///< sql query for db access
43
};
44
 
45
#endif // CLIMATE_H