iLand
dbhdistribution.h
Go to the documentation of this file.
1/********************************************************************************************
2** iLand - an individual based forest landscape and disturbance model
3** http://iland-model.org
4** Copyright (C) 2009- Werner Rammer, Rupert Seidl
5**
6** This program is free software: you can redistribute it and/or modify
7** it under the terms of the GNU General Public License as published by
8** the Free Software Foundation, either version 3 of the License, or
9** (at your option) any later version.
10**
11** This program is distributed in the hope that it will be useful,
12** but WITHOUT ANY WARRANTY; without even the implied warranty of
13** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14** GNU General Public License for more details.
15**
16** You should have received a copy of the GNU General Public License
17** along with this program. If not, see <http://www.gnu.org/licenses/>.
18********************************************************************************************/
19#include <QObject>
20#include <QString>
21#include <QHash>
22#include <QVector>
23#ifndef DBHDISTRIBUTION_H
24#define DBHDISTRIBUTION_H
25
26class ResourceUnit; // forward
27class Tree; // forward
28
31class DBHDistribution: public QObject
32{
33 Q_OBJECT
34public slots:
38 void calculate();
40 void addStand(const int standId);
41
42 void saveToTextFile(QString filename);
43 void saveStandInfo(QString filename);
44
45public:
46 DBHDistribution(QObject *parent=0);
48
49
51 void addResourceUnit(const ResourceUnit *ru);
54 void addStand(const int standId, const double area, QVector<Tree *> &tree_list);
55
57 double dbhClass(const QString &speciesId, const float dbh) const;
59 double dbhClass(const QString &speciesId, const int class_index) const;
61 int nClasses() const { return mNClasses; }
63 inline int classIndex(const float dbh) const;
66 QString classLabel(const int class_index);
67
68 // getters and setters
69 void setTotalArea(const double total_area_ha) { mTotalArea = total_area_ha; }
70 double totalArea() const { return mTotalArea; }
71private:
72 struct SStandInfo {
73 SStandInfo(): standId(0), area(0.), volume(0.), basalarea(0.), stems(0) {}
74 int standId;
75 double area;
76 double volume;
77 double basalarea;
78 int stems;
79 };
80
81 double mTotalArea;
82 QVector< double* > mData;
83 QVector< QString > mSpeciesIds;
84 SStandInfo mLandscapeInfo;
85
86 QHash<int, QVector<double*> > mStands;
87 QHash<int, SStandInfo > mStandInfo;
88
89 void internalSetup();
90 void addTree(const Tree *t) {addTree(t, mData);}
91 void addTree(const Tree *t, QVector< double* > &distribution);
92 void clear(QVector< double* > &distribution);
94 void addDistribution(const QVector<double *> &source, QVector<double*> &target);
95 static int mNClasses;
96};
97
98#endif // DBHDISTRIBUTION_H
The class DBHDistribution encapsulates a DBH distribution on the landscape level.
Definition: dbhdistribution.h:32
QString classLabel(const int class_index)
return the label of the class class_index.
Definition: dbhdistribution.cpp:163
void addResourceUnit(const ResourceUnit *ru)
add the trees of the resource unit ru.
Definition: dbhdistribution.cpp:79
void addStand(const int standId)
add/replace the DBH distribution for a stand denoted by standId. Use all trees of the stand.
Definition: dbhdistribution.cpp:63
int nClasses() const
return the number of DBH classes
Definition: dbhdistribution.h:61
DBHDistribution(QObject *parent=0)
Definition: dbhdistribution.cpp:153
double dbhClass(const QString &speciesId, const int class_index) const
get trees/ha of species speciesID in class classIndex(0..nClasses()-1)
int classIndex(const float dbh) const
return the index of the class where dbh falls into (0..nClasses()-1)
Definition: dbhdistribution.cpp:158
void saveToTextFile(QString filename)
Definition: dbhdistribution.cpp:116
void calculateFromLandscape()
renew the full DBH distribution over the full landscape (by iterating over all trees)
Definition: dbhdistribution.cpp:37
void saveStandInfo(QString filename)
Definition: dbhdistribution.cpp:135
void setTotalArea(const double total_area_ha)
Definition: dbhdistribution.h:69
~DBHDistribution()
Definition: dbhdistribution.cpp:32
double dbhClass(const QString &speciesId, const float dbh) const
get trees/ha of species speciesID in class in which dbh falls into
void calculate()
calculate the total DBH distribution on the landscape (by summing up over stand wise DBH distribution...
Definition: dbhdistribution.cpp:47
double totalArea() const
Definition: dbhdistribution.h:70
ResourceUnit is the spatial unit that encapsulates a forest stand and links to several environmental ...
Definition: resourceunit.h:49
A tree is the basic simulation entity of iLand and represents a single tree.
Definition: tree.h:44