Subversion Repositories public iLand

Rev

Rev 1221 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
671 werner 1
/********************************************************************************************
2
**    iLand - an individual based forest landscape and disturbance model
3
**    http://iland.boku.ac.at
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
 
106 Werner 20
#ifndef STANDLOADER_H
21
#define STANDLOADER_H
287 werner 22
#include <QtCore/QString>
106 Werner 23
 
967 werner 24
#include "csvfile.h"
25
 
106 Werner 26
class Model;
187 iland 27
class ResourceUnit;
290 werner 28
class RandomCustomPDF;
29
class Species;
603 werner 30
class MapGrid;
732 werner 31
class Expression;
603 werner 32
 
106 Werner 33
class StandLoader
34
{
35
public:
732 werner 36
    StandLoader(Model *model): mModel(model), mRandom(0), mCurrentMap(0), mInitHeightGrid(0), mHeightGridResponse(0) {}
290 werner 37
    ~StandLoader();
732 werner 38
    /// define a stand grid externally
603 werner 39
    void setMap(const MapGrid *map) { mCurrentMap = map; }
732 werner 40
    /// set a constraining height grid (10m resolution)
41
    void setInitHeightGrid(const MapGrid *height_grid) { mInitHeightGrid = height_grid; }
42
 
43
    /// main function of stand initialization
44
    /// 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 45
    void processInit();
967 werner 46
    /// this function is called *after* the init and after  initial LIF-calculations.
47
     void processAfterInit();
732 werner 48
 
393 werner 49
    /// load a single tree file (picus or iland style). return number of trees loaded.
50
    int loadPicusFile(const QString &fileName, ResourceUnit *ru=NULL);
51
    /// load a tree distribution based on dbh classes. return number of trees loaded.
549 werner 52
    int loadiLandFile(const QString &fileName, ResourceUnit *ru=NULL, int stand_id=0);
732 werner 53
 
54
    /// worker function to load a file containing single trees
389 werner 55
    int loadSingleTreeList(const QString &content, ResourceUnit*ru = NULL, const QString &fileName="");
732 werner 56
    /// worker function to load a file containing rows with dbhclasses
549 werner 57
    int loadDistributionList(const QString &content, ResourceUnit *ru = NULL, int stand_id=0, const QString &fileName="");
600 werner 58
    // load regeneration in stands
59
    int loadSaplings(const QString &content, int stand_id, const QString &fileName=QString());
966 werner 60
    // load regen in stand but consider also the light conditions on the ground
967 werner 61
    int loadSaplingsLIF(int stand_id, const CSVFile &init, int low_index, int high_index);
106 Werner 62
private:
290 werner 63
    struct InitFileItem
64
    {
65
        Species *species;
968 werner 66
        double count;
290 werner 67
        double dbh_from, dbh_to;
68
        double hd;
69
        int age;
311 werner 70
        double density;
290 werner 71
    };
393 werner 72
    /// load tree initialization from a file. return number of trees loaded.
549 werner 73
    int loadInitFile(const QString &fileName, const QString &type, int stand_id=0, ResourceUnit *ru=NULL);
393 werner 74
    void executeiLandInit(ResourceUnit *ru); ///< shuffle tree positions
549 werner 75
    void executeiLandInitStand(int stand_id); ///< shuffle tree positions
393 werner 76
    void copyTrees(); ///< helper function to quickly fill up the landscape by copying trees
77
    void evaluateDebugTrees(); ///< set debug-flag for trees by evaluating the param-value expression "debug_tree"
904 werner 78
    int parseInitFile(const QString &content, const QString &fileName, ResourceUnit *ru=0); ///< creates a list of InitFileItems from the init files' content
106 Werner 79
    Model *mModel;
290 werner 80
    RandomCustomPDF *mRandom;
600 werner 81
    QVector<InitFileItem> mInitItems;
904 werner 82
    QHash<int, QVector<InitFileItem> > mStandInitItems;
603 werner 83
    const MapGrid *mCurrentMap;
732 werner 84
    const MapGrid *mInitHeightGrid; ///< grid with tree heights
85
    Expression *mHeightGridResponse; ///< response function to calculate fitting of pixels with pre-determined height
86
    int mHeightGridTries; ///< maximum number of tries to land at pixel with fitting height
106 Werner 87
};
88
 
89
#endif // STANDLOADER_H