Subversion Repositories public iLand

Rev

Rev 904 | Rev 967 | 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());
966 werner 57
    // load regen in stand but consider also the light conditions on the ground
58
    int loadSaplingsLIF(const QString &content, int stand_id, const QString &fileName=QString());
106 Werner 59
private:
290 werner 60
    struct InitFileItem
61
    {
62
        Species *species;
63
        int count;
64
        double dbh_from, dbh_to;
65
        double hd;
66
        int age;
311 werner 67
        double density;
290 werner 68
    };
393 werner 69
    /// load tree initialization from a file. return number of trees loaded.
549 werner 70
    int loadInitFile(const QString &fileName, const QString &type, int stand_id=0, ResourceUnit *ru=NULL);
393 werner 71
    void executeiLandInit(ResourceUnit *ru); ///< shuffle tree positions
549 werner 72
    void executeiLandInitStand(int stand_id); ///< shuffle tree positions
393 werner 73
    void copyTrees(); ///< helper function to quickly fill up the landscape by copying trees
74
    void evaluateDebugTrees(); ///< set debug-flag for trees by evaluating the param-value expression "debug_tree"
904 werner 75
    int parseInitFile(const QString &content, const QString &fileName, ResourceUnit *ru=0); ///< creates a list of InitFileItems from the init files' content
106 Werner 76
    Model *mModel;
290 werner 77
    RandomCustomPDF *mRandom;
600 werner 78
    QVector<InitFileItem> mInitItems;
904 werner 79
    QHash<int, QVector<InitFileItem> > mStandInitItems;
603 werner 80
    const MapGrid *mCurrentMap;
732 werner 81
    const MapGrid *mInitHeightGrid; ///< grid with tree heights
82
    Expression *mHeightGridResponse; ///< response function to calculate fitting of pixels with pre-determined height
83
    int mHeightGridTries; ///< maximum number of tries to land at pixel with fitting height
106 Werner 84
};
85
 
86
#endif // STANDLOADER_H