Rev 1221 | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
1 | |||
671 | werner | 2 | /******************************************************************************************** |
3 | ** iLand - an individual based forest landscape and disturbance model |
||
4 | ** http://iland.boku.ac.at |
||
5 | ** Copyright (C) 2009- Werner Rammer, Rupert Seidl |
||
6 | ** |
||
7 | ** This program is free software: you can redistribute it and/or modify |
||
8 | ** it under the terms of the GNU General Public License as published by |
||
9 | ** the Free Software Foundation, either version 3 of the License, or |
||
10 | ** (at your option) any later version. |
||
11 | ** |
||
12 | ** This program is distributed in the hope that it will be useful, |
||
13 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of |
||
14 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||
15 | ** GNU General Public License for more details. |
||
16 | ** |
||
17 | ** You should have received a copy of the GNU General Public License |
||
18 | ** along with this program. If not, see <http://www.gnu.org/licenses/>. |
||
19 | ********************************************************************************************/ |
||
20 | |||
106 | Werner | 21 | #ifndef STANDLOADER_H |
22 | #define STANDLOADER_H |
||
287 | werner | 23 | #include <QtCore/QString> |
106 | Werner | 24 | |
967 | werner | 25 | #include "csvfile.h" |
26 | |||
106 | Werner | 27 | class Model; |
187 | iland | 28 | class ResourceUnit; |
290 | werner | 29 | class RandomCustomPDF; |
30 | class Species; |
||
603 | werner | 31 | class MapGrid; |
732 | werner | 32 | class Expression; |
603 | werner | 33 | |
106 | Werner | 34 | class StandLoader |
35 | { |
||
36 | public: |
||
732 | werner | 37 | StandLoader(Model *model): mModel(model), mRandom(0), mCurrentMap(0), mInitHeightGrid(0), mHeightGridResponse(0) {} |
290 | werner | 38 | ~StandLoader(); |
732 | werner | 39 | /// define a stand grid externally |
603 | werner | 40 | void setMap(const MapGrid *map) { mCurrentMap = map; } |
732 | werner | 41 | /// set a constraining height grid (10m resolution) |
42 | void setInitHeightGrid(const MapGrid *height_grid) { mInitHeightGrid = height_grid; } |
||
43 | |||
44 | /// main function of stand initialization |
||
45 | /// the function loads - depending on the XML project file - inits for a single resource unit, for polygons or a snapshot from a database. |
||
106 | Werner | 46 | void processInit(); |
967 | werner | 47 | /// this function is called *after* the init and after initial LIF-calculations. |
48 | void processAfterInit(); |
||
732 | werner | 49 | |
393 | werner | 50 | /// load a single tree file (picus or iland style). return number of trees loaded. |
51 | int loadPicusFile(const QString &fileName, ResourceUnit *ru=NULL); |
||
52 | /// load a tree distribution based on dbh classes. return number of trees loaded. |
||
549 | werner | 53 | int loadiLandFile(const QString &fileName, ResourceUnit *ru=NULL, int stand_id=0); |
732 | werner | 54 | |
55 | /// worker function to load a file containing single trees |
||
389 | werner | 56 | int loadSingleTreeList(const QString &content, ResourceUnit*ru = NULL, const QString &fileName=""); |
732 | werner | 57 | /// worker function to load a file containing rows with dbhclasses |
549 | werner | 58 | int loadDistributionList(const QString &content, ResourceUnit *ru = NULL, int stand_id=0, const QString &fileName=""); |
600 | werner | 59 | // load regeneration in stands |
60 | int loadSaplings(const QString &content, int stand_id, const QString &fileName=QString()); |
||
966 | werner | 61 | // load regen in stand but consider also the light conditions on the ground |
967 | werner | 62 | int loadSaplingsLIF(int stand_id, const CSVFile &init, int low_index, int high_index); |
106 | Werner | 63 | private: |
290 | werner | 64 | struct InitFileItem |
65 | { |
||
66 | Species *species; |
||
968 | werner | 67 | double count; |
290 | werner | 68 | double dbh_from, dbh_to; |
69 | double hd; |
||
70 | int age; |
||
311 | werner | 71 | double density; |
290 | werner | 72 | }; |
393 | werner | 73 | /// load tree initialization from a file. return number of trees loaded. |
549 | werner | 74 | int loadInitFile(const QString &fileName, const QString &type, int stand_id=0, ResourceUnit *ru=NULL); |
393 | werner | 75 | void executeiLandInit(ResourceUnit *ru); ///< shuffle tree positions |
549 | werner | 76 | void executeiLandInitStand(int stand_id); ///< shuffle tree positions |
393 | werner | 77 | void copyTrees(); ///< helper function to quickly fill up the landscape by copying trees |
78 | void evaluateDebugTrees(); ///< set debug-flag for trees by evaluating the param-value expression "debug_tree" |
||
904 | werner | 79 | int parseInitFile(const QString &content, const QString &fileName, ResourceUnit *ru=0); ///< creates a list of InitFileItems from the init files' content |
106 | Werner | 80 | Model *mModel; |
290 | werner | 81 | RandomCustomPDF *mRandom; |
600 | werner | 82 | QVector<InitFileItem> mInitItems; |
904 | werner | 83 | QHash<int, QVector<InitFileItem> > mStandInitItems; |
603 | werner | 84 | const MapGrid *mCurrentMap; |
732 | werner | 85 | const MapGrid *mInitHeightGrid; ///< grid with tree heights |
86 | Expression *mHeightGridResponse; ///< response function to calculate fitting of pixels with pre-determined height |
||
87 | int mHeightGridTries; ///< maximum number of tries to land at pixel with fitting height |
||
106 | Werner | 88 | }; |
89 | |||
90 | #endif // STANDLOADER_H |