GCBM
|
#include <ageclasshelper.h>
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 |
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()
ageClassSize | int |
maximumAge | int |
|
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
ageClassSize | int |
maximumAge | int |
std::tuple< int, int > getAgeClass | ( | int | ageClass | ) |
Return value of paramter ageClass in AgeClassHelper._ageClasses
ageClass | int |
std::map< int, std::tuple< int, int > > getAgeClasses | ( | ) |
Return AgeClassHelper._ageClasses
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
ageClass | int. |
int toAgeClass | ( | int | standAge | ) |
Return value of parameter standAge in AgeClassHelper._ageClassLookup
The minimum value of standAge is 0, maximum value is AgeClassHelper._maximumAge
standAge | int |
|
private |
|
private |
|
private |
|
private |
|
private |