GCBM
Public Member Functions | Private Member Functions | Private Attributes | List of all members
TreeYieldTable Class Reference

ADT - Tree yield table More...

#include <treeyieldtable.h>

Collaboration diagram for TreeYieldTable:
Collaboration graph

Public Member Functions

 TreeYieldTable ()
 
virtual ~TreeYieldTable ()=default
 
int maxAge () const
 Maximum age of the yield table More...
 
double totalVolume () const
 Total volume of the speciese growth curve More...
 
std::vector< double > & yieldsAtEachAge ()
 Vector of volume (m^3/ha) at each age stop, 1 ha = 10,000 m^2 More...
 
double operator[] (int age) const
 
SpeciesType speciesType () const
 
 TreeYieldTable (const std::vector< DynamicObject > &yieldTable, SpeciesType speciesType)
 Create a yield table for a specified type with the transform result yield data More...
 

Private Member Functions

void Initialize (const std::vector< DynamicObject > &yieldTable)
 Load original yield table data[age, volume] Interpolate to get volume at each age Calculate the maximum volume More...
 
void InterpolateVolumeAtEachAge ()
 Lineraly Interpolate the tree yield table to assign the volume at each age year More...
 
void preProcessYieldData ()
 There should be a volume data at each age. The yield table is not valid if there are ZERO values after the last valid non-zero volume. For example, the volume data like[0,0,0,0,10,20,30,50,60,70,0,0,0,0]. In current CBM, all the trialling ZEROs should be replaced by the last non-zero data - 70. The volume data like[0,0,0,0,10,20,30,50,60,70,70,70,70,70]. More...
 
double linear (double x, double x0, double x1, double y0, double y1)
 http://stackoverflow.com/questions/12838007/c-sharp-linear-interpolation More...
 

Private Attributes

int _maxAge
 
int _ageInterval
 
double _totalVolume
 
SpeciesType _speciesType
 
std::vector< double > _yieldsAtEachAge
 

Detailed Description

ADT - Tree yield table

Constructor & Destructor Documentation

◆ TreeYieldTable() [1/2]

Overloaded Constructor

Initialise TreeYieldTable._maxAge to 0, TreeYieldTable._ageInterval to 0

◆ ~TreeYieldTable()

virtual ~TreeYieldTable ( )
virtualdefault

◆ TreeYieldTable() [2/2]

TreeYieldTable ( const std::vector< DynamicObject > &  yieldTable,
SpeciesType  speciesType 
)

Create a yield table for a specified type with the transform result yield data

Parameters
yieldTableIt has [Age, Volume]


Parameters
specieseTypespecies type, either softwood or hardwood


Overloaded Constructor - Create a yield table for a specified type with the transform result yield data parameter speciesType either be softwood or hardwood

Initialise TreeYieldTable._maxAge to 0, TreeYieldTable._speciesType to parameter speciesType
, If yieldTable is not empty, initialise TreeYieldTable._maxAge as the last value of "age" in parameter yieldTable,
TreeYieldTable._ageInterval as the difference between the second and first "age" values in parameter yieldTable
Invoke TreeYieldTable.Initialize() with paramter yieldTable

Parameters
yieldTableconst vector<DynamicObject>&
speciesTypeSpeciesType

Member Function Documentation

◆ Initialize()

void Initialize ( const std::vector< DynamicObject > &  yieldTable)
private

Load original yield table data[age, volume] Interpolate to get volume at each age Calculate the maximum volume

Parameters
rows

Load original yield table data, interpolate to get volume at each age and calculate the maximum volume

Resize TreeYieldTable._yieldsAtEachAge to TreeYieldTable._maxAge + 1 and initialise it to 9
Add the value of "merchantable_volume" attribute corresponding to each in parameter yieldTable to TreeYieldTable._yieldsAtEachAge
More than one value in the yield table for a given age means tha there are multiple hardwood or softwood species components - CBM3 Toolbox behaviour is to add the yields together
Invoke TreeYieldTable.preProcessYieldData() and TreeYieldTable.InterpolateVolumeAtEachAge() Assign the sum of TreeYieldTable._yieldsAtEachAge to TreeYieldTable._totalVolume

Parameters
yieldTableconst vector<DynamicObject>&
Returns
void

◆ InterpolateVolumeAtEachAge()

void InterpolateVolumeAtEachAge ( )
private

Lineraly Interpolate the tree yield table to assign the volume at each age year


Linearly Interpolate the tree yield table to assign the volume at each age year

For each value in the range 0 to TreeYieldTable._maxAge separated by TreeYieldTable._ageInterval, assign x0 as value, x1 as value + TreeYieldTable._ageInterval, y0 as value of x0 in TreeYieldTable._yieldsAtEachAge, y1 as value of x1 in TreeYieldTable._yieldsAtEachAge
For each age in the range x0 to x1, assign the result of the interpolation using TreeYieldTable.linear() with arguments age, x0, x1, y0, y1

Returns
void

◆ linear()

double linear ( double  x,
double  x0,
double  x1,
double  y0,
double  y1 
)
private

◆ maxAge()

int maxAge ( ) const

Maximum age of the yield table

◆ operator[]()

double operator[] ( int  age) const

Indexer to get the volume at each age

Return value of parameter age in TreeYieldTable._yieldsAtEachAge

Parameters
ageint
Returns
double

◆ preProcessYieldData()

void preProcessYieldData ( )
private

There should be a volume data at each age. The yield table is not valid if there are ZERO values after the last valid non-zero volume. For example, the volume data like[0,0,0,0,10,20,30,50,60,70,0,0,0,0]. In current CBM, all the trialling ZEROs should be replaced by the last non-zero data - 70. The volume data like[0,0,0,0,10,20,30,50,60,70,70,70,70,70].


Volume data at each age should exist. The yield table is not valid if there are ZERO values after the last valid non-zero volume.

If TreeYieldTable.yieldsAtEachAge is not empty, for ages in the range 0 and TreeYieldTable._maxAge, if the value of the current age in TreeYieldTable._yieldsAtEachAge is not equal to the value of age+1 in TreeYieldTable._yieldsAtEachAge and value of age+1 in TreeYieldTable._yieldsAtEachAge is 0, set the value of age+1 equal to the value of age in TreeYieldTable._yieldsAtEachAge

Example : If the volume data like[0,0,0,0,10,20,30,50,60,70,0,0,0,0], it is not valid
In current CBM, all the trialling ZEROs should be replaced by the last non-zero data - 70 The volume data should be like[0,0,0,0,10,20,30,50,60,70,70,70,70,70].

Returns
void

◆ speciesType()

SpeciesType speciesType ( ) const

◆ totalVolume()

double totalVolume ( ) const

Total volume of the speciese growth curve

◆ yieldsAtEachAge()

std::vector<double>& yieldsAtEachAge ( )

Vector of volume (m^3/ha) at each age stop, 1 ha = 10,000 m^2

Member Data Documentation

◆ _ageInterval

int _ageInterval
private

◆ _maxAge

int _maxAge
private

◆ _speciesType

SpeciesType _speciesType
private

◆ _totalVolume

double _totalVolume
private

◆ _yieldsAtEachAge

std::vector<double> _yieldsAtEachAge
private

The documentation for this class was generated from the following files: