Rev 671 | Rev 779 | Go to most recent revision | 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 | |
25 | class Model; |
||
187 | iland | 26 | class ResourceUnit; |
290 | werner | 27 | class RandomCustomPDF; |
28 | class Species; |
||
603 | werner | 29 | class MapGrid; |
732 | werner | 30 | class Expression; |
603 | werner | 31 | |
106 | Werner | 32 | class StandLoader |
33 | { |
||
34 | public: |
||
732 | werner | 35 | StandLoader(Model *model): mModel(model), mRandom(0), mCurrentMap(0), mInitHeightGrid(0), mHeightGridResponse(0) {} |
290 | werner | 36 | ~StandLoader(); |
732 | werner | 37 | /// define a stand grid externally |
603 | werner | 38 | void setMap(const MapGrid *map) { mCurrentMap = map; } |
732 | werner | 39 | /// set a constraining height grid (10m resolution) |
40 | void setInitHeightGrid(const MapGrid *height_grid) { mInitHeightGrid = height_grid; } |
||
41 | |||
42 | /// main function of stand initialization |
||
43 | /// 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 | 44 | void processInit(); |
732 | werner | 45 | |
393 | werner | 46 | /// load a single tree file (picus or iland style). return number of trees loaded. |
47 | int loadPicusFile(const QString &fileName, ResourceUnit *ru=NULL); |
||
48 | /// load a tree distribution based on dbh classes. return number of trees loaded. |
||
549 | werner | 49 | int loadiLandFile(const QString &fileName, ResourceUnit *ru=NULL, int stand_id=0); |
732 | werner | 50 | |
51 | /// worker function to load a file containing single trees |
||
389 | werner | 52 | int loadSingleTreeList(const QString &content, ResourceUnit*ru = NULL, const QString &fileName=""); |
732 | werner | 53 | /// worker function to load a file containing rows with dbhclasses |
549 | werner | 54 | int loadDistributionList(const QString &content, ResourceUnit *ru = NULL, int stand_id=0, const QString &fileName=""); |
600 | werner | 55 | // load regeneration in stands |
56 | int loadSaplings(const QString &content, int stand_id, const QString &fileName=QString()); |
||
106 | Werner | 57 | private: |
290 | werner | 58 | struct InitFileItem |
59 | { |
||
60 | Species *species; |
||
61 | int count; |
||
62 | double dbh_from, dbh_to; |
||
63 | double hd; |
||
64 | int age; |
||
311 | werner | 65 | double density; |
290 | werner | 66 | }; |
393 | werner | 67 | /// load tree initialization from a file. return number of trees loaded. |
549 | werner | 68 | int loadInitFile(const QString &fileName, const QString &type, int stand_id=0, ResourceUnit *ru=NULL); |
393 | werner | 69 | void executeiLandInit(ResourceUnit *ru); ///< shuffle tree positions |
549 | werner | 70 | void executeiLandInitStand(int stand_id); ///< shuffle tree positions |
393 | werner | 71 | void copyTrees(); ///< helper function to quickly fill up the landscape by copying trees |
72 | void evaluateDebugTrees(); ///< set debug-flag for trees by evaluating the param-value expression "debug_tree" |
||
106 | Werner | 73 | Model *mModel; |
290 | werner | 74 | RandomCustomPDF *mRandom; |
600 | werner | 75 | QVector<InitFileItem> mInitItems; |
603 | werner | 76 | const MapGrid *mCurrentMap; |
732 | werner | 77 | const MapGrid *mInitHeightGrid; ///< grid with tree heights |
78 | Expression *mHeightGridResponse; ///< response function to calculate fitting of pixels with pre-determined height |
||
79 | int mHeightGridTries; ///< maximum number of tries to land at pixel with fitting height |
||
106 | Werner | 80 | }; |
81 | |||
82 | #endif // STANDLOADER_H |