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

#include <ageclasshelper.h>

Collaboration diagram for AgeClassHelper:
Collaboration graph

Public Member Functions

 AgeClassHelper (int ageClassSize=20, int maximumAge=300)
 
int toAgeClass (int standAge)
 
std::tuple< int, int > getAgeClass (int ageClass)
 
std::string getAgeClassString (int ageClass)
 
std::map< int, std::tuple< int, int > > getAgeClasses ()
 

Private Member Functions

void generateAgeClasses (int ageClassSize, int maximumAge)
 

Private Attributes

int _ageClassSize
 
int _maximumAge
 
int _numAgeClasses
 
std::map< int, std::tuple< int, int > > _ageClasses
 
std::map< int, int > _ageClassLookup
 

Constructor & Destructor Documentation

◆ AgeClassHelper()

AgeClassHelper ( int  ageClassSize = 20,
int  maximumAge = 300 
)

Constructor

Initialise AgeClassHelper._ageClassSize as ageClassSize,
AgeClassHelper._maximumAge as maximumAge, AgeClassHelper._numAgeClasses as 1 + ceil((float)maximumAge / (float)ageClassSize),
and invoke AgeClassHelper.generateAgeClasses()

Parameters
ageClassSizeint
maximumAgeint

Member Function Documentation

◆ generateAgeClasses()

void generateAgeClasses ( int  ageClassSize,
int  maximumAge 
)
private

Initialise AgeClassHelper._ageClasses and AgeClassHelper._ageClassLookup

_ageClasses is a map, where the keys range from 0 to AgeClassHelper._numAgeClasses
_ageClasses[0] is reserved for non-forest 1, assigned a value [-1, -1]
_ageClasses[AgeClassHelper._numAgeClasses] is assigned [maximumAge, -1]
For each ageClassNumber in the range, 1 to AgeClassHelper._numAgeClasses, _ageClasses[ageClassNumber] is assigned [startAge, endAge] where
startAge is given as (key - 1) * ageClassSize and endAge is given as key * ageClassSize - 1
endAge is bounded by the value maximumAge - 1

Assign each age in the range startAge to endAge in AgeClassHelper._ageClassLookup to ageClassNumber, i.e AgeClassHelper._ageClassLookup[age] = ageClassNumber
_ageClassLookup[maximumAge] is assigned AgeClassHelper._numAgeClasses

Parameters
ageClassSizeint
maximumAgeint
Returns
void

◆ getAgeClass()

std::tuple< int, int > getAgeClass ( int  ageClass)

Return value of paramter ageClass in AgeClassHelper._ageClasses

Parameters
ageClassint
Returns
map<int, tuple<int, int>>

◆ getAgeClasses()

std::map< int, std::tuple< int, int > > getAgeClasses ( )

Return AgeClassHelper._ageClasses

Returns
map<int, tuple<int, int>>

◆ getAgeClassString()

std::string getAgeClassString ( int  ageClass)

Compute and return the ageClass string

ageClassRange of parameter ageClass is obtained from AgeClassHelper._ageClasses, ageClassRange is a tuple containing <startAge, endAge>
If startAge is -1, return "N/A"
, If endAge is -1, return "startAge+"
, Else "startAge-endAge"
Integral values of startAge and endAge are used in the ageClass string

Parameters
ageClassint.
Returns
String

◆ toAgeClass()

int toAgeClass ( int  standAge)

Return value of parameter standAge in AgeClassHelper._ageClassLookup

The minimum value of standAge is 0, maximum value is AgeClassHelper._maximumAge

Parameters
standAgeint
Returns
int

Member Data Documentation

◆ _ageClasses

std::map<int, std::tuple<int, int> > _ageClasses
private

◆ _ageClassLookup

std::map<int, int> _ageClassLookup
private

◆ _ageClassSize

int _ageClassSize
private

◆ _maximumAge

int _maximumAge
private

◆ _numAgeClasses

int _numAgeClasses
private

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