#include <Planting.h>
Inheritance diagram for clPlant:
Public Types | |
gridded | |
Plants are spaced on a grid. | |
enum | spaceType { gridded } |
Type of plant spacing. More... | |
Public Member Functions | |
clPlant (clSimManager *p_oSimManager) | |
Constructor. | |
~clPlant () | |
Destructor. | |
void | TimestepCleanup () |
Resets the values in the plantresults grid to 0. | |
void | Action () |
Performs the planting for a timestep. | |
Protected Member Functions | |
void | GetData (xercesc::DOMDocument *p_oDoc) |
Reads all the plant events from the parameter file. | |
void | SetupPlantGrids () |
Sets up the plant grids and gets all the return codes. | |
void | ValidatePackages () |
Makes sure that the data in the plant master packages makes sense. | |
void | PlantTrees (clPackage *p_oMasterPackage) |
Performs the tree planting for a master plant package. | |
int | AssemblePlantArea (clPackage *p_oMasterPackage, const int &iNumXCells, const int &iNumYCells, stcGridList *&p_plantArea) |
Finds the planting area for a planting event. | |
Protected Attributes | |
clTreePopulation * | mp_oPop |
Stashed pointer to tree population. | |
clGridBase * | mp_oPlantMasterGrid |
PLANTING MASTER. | |
clGridBase * | mp_oPlantEventsGrid |
PLANT EVENTS. | |
clGridBase * | mp_oPlantResultsGrid |
PLANT RESULTS. | |
float * | mp_fInitialDiam10 |
Size of seedlings to plant. | |
short int | m_iMasterTimestepCode |
timestep data member code in "planttmaster" grid | |
short int | m_iMasterIDCode |
id code in "planttmaster" grid | |
short int * | mp_iAmtPlantCodes |
amtPlant code in "planttmaster" grid. | |
short int | m_iSpaceTypeCode |
spacetype code in "planttmaster" grid | |
short int | m_iSpacingOrDensityCode |
spcorden code in "planttmaster" grid | |
short int | m_iPlantTimestepCode |
timestep code in "plantevents" grid | |
short int | m_iPlantIDCode |
id code in "plantevents" grid | |
short int * | mp_iPlantedCodes |
planted codes in "plantresults" grid. | |
Classes | |
struct | stcGridList |
Holds a linked list of grid cells. More... |
Planting events can be defined on a grid cell level for each timestep for each species. If more than one event is defined for a species for a single grid cell and timestep, the user takes a chance on what happens. Cells with common planting criteria are grouped by the user into groups which will be evaluated together.
Seedlings to be planted can be placed either randomly around the planting cells or in a gridded fashion. When random, each seedling is placed randomly within the entire chunk being planted. When gridded, each seedling is placed within a given grid cell. This means that gridded plantings are likely to be suboptimal unless they divide nicely into the length of a grid cell. I have not figured out a better way to do gridded plantings.
The size of new seedlings can be left as the standard new seedling size or it can be changed.
The relative amounts of each species are in the parameter file. When reading the file, this behavior expects values as percentages.
The planting data is stored in a grid. Each plant event, defined as the planting to be done for one species for one timestep for one grid cell, is stored in a grid package. These packages are sorted in timestep order. Each timestep, all the planting events that are defined for that timestep are executed, then those packages are removed.
A word on planting grids: It is possible for there to be grid maps for these grids in the parameter file. These will be ignored, and any grids created with these maps will be replaced.
The namestring for this behavior is "plant."
Copyright 2003 Charles D. Canham.
enum clPlant::spaceType |
clPlant::clPlant | ( | clSimManager * | p_oSimManager | ) |
Constructor.
p_oSimManager | Sim Manager object. |
void clPlant::Action | ( | ) | [virtual] |
Performs the planting for a timestep.
For a timestep, this goes through the master package lists in plantmaster and calls PlantTrees() for each one that is for this timestep.
Reimplemented from clBehaviorBase.
int clPlant::AssemblePlantArea | ( | clPackage * | p_oMasterPackage, | |
const int & | iNumXCells, | |||
const int & | iNumYCells, | |||
stcGridList *& | p_plantArea | |||
) | [protected] |
Finds the planting area for a planting event.
For a master plant package, this finds all the grid cells affected by this planting by matching ID numbers on packages in the plantevents grid. The plant area cells are assembled into a linked list. All packages which went into the linked list are then deleted.
p_oMasterPackage | The master package for which the plant area list is being assembled. (This package will NOT be deleted.) | |
iNumXCells | mp_oPlantEventsGrid's number of cells in the X direction. | |
iNumYCells | mp_oPlantEventsGrid's number of cells in the Y direction. | |
p_plantArea | Pointer in which to place the linked list of grid cells. |
void clPlant::GetData | ( | xercesc::DOMDocument * | p_oDoc | ) | [protected, virtual] |
Reads all the plant events from the parameter file.
It doesn't perform validation on them other than basic data types - more in-depth logical validation is left to ValidatePackages().
p_oDoc | DOM tree of parsed input file. |
Implements clWorkerBase.
void clPlant::PlantTrees | ( | clPackage * | p_oMasterPackage | ) | [protected] |
Performs the tree planting for a master plant package.
It starts by getting a linked list of cells to plant from the package. When planting randomly, for each tree being planted, a cell is selected at random and then a point within that cell is selected at random. For gridded plantings, each cell is evaluated separately. For a location in the cell, one of the species is picked based on a random number compared to the desired relative amounts of each species.
p_oMasterPackage | The master package to plant |
void clPlant::ValidatePackages | ( | ) | [protected] |
Makes sure that the data in the plant master packages makes sense.
For each one this checks the following:
float* clPlant::mp_fInitialDiam10 [protected] |
Size of seedlings to plant.
Actual values are randomized slightly around these values. Array size is number of species.
short int* clPlant::mp_iAmtPlantCodes [protected] |
amtPlant code in "planttmaster" grid.
Array size is number of species - array index matches species number
short int* clPlant::mp_iPlantedCodes [protected] |
planted codes in "plantresults" grid.
Array size is number of species.
clGridBase* clPlant::mp_oPlantEventsGrid [protected] |
PLANT EVENTS.
The grid called "plantevents" will have a cell resolution that matches the tree population. This is where data about planting events is stored.
The need to plant a grid cell is signaled by the presence of a package. The package has an ID number which matches a package in the "plantmaster" grid, which contains the information about how the planting is actually to be performed. Packages are in timestep order, earliest first.
Data members - all for packages:
Data member name | Data type | Description |
---|---|---|
id | int | ID number matching master package in "plantmaster" |
timestep | int | Timestep at which to apply the plant |
clGridBase* clPlant::mp_oPlantMasterGrid [protected] |
PLANTING MASTER.
The grid called "plantmaster" will have a single cell. This is where the plant events are defined.
Each plant event is one package and is applied to a list of species. It has a unique ID number. The grid cells to which it is applied are in the "plantevents" grid.
The packages are in timestep order, earliest first.
Data members - all for packages:
Data member name | Data type | Description |
---|---|---|
id | int | ID number of plant event |
timestep | int | Timestep to plant |
spacetype | int | Matches a value of the enum "spaceType" |
spcorden | float | If spacetype = gridded, spacing of trees, in m. If spacetype = random, total density/ha for all species. |
amtPlant(x) | float | One of each of these for each species (species # = x). This is the percentage, between 0 and 100, of each species desired. If a species is not to be planted, its value is 0. |
clGridBase* clPlant::mp_oPlantResultsGrid [protected] |
PLANT RESULTS.
The grid called "Planting Results" will have a grid cell resolution matching that of "plantevents". This is where data on planting results is stored. The data is stored raw - no conversion to per-hectare amounts.
Data member name | Data type | Description |
---|---|---|
planted(x) | int | Number of trees planted in the current timestep - one of these for each species (x = species number) |