GCBM
treeyieldtable.h
Go to the documentation of this file.
1 #ifndef MOJA_MODULES_CBM_YIELDTABLE_H_
2 #define MOJA_MODULES_CBM_YIELDTABLE_H_
3 
4 #include "moja/modules/cbm/_modules.cbm_exports.h"
5 #include "moja/flint/modulebase.h"
6 
8 
9 namespace moja {
10 namespace modules {
11 namespace cbm {
12 
16  class CBM_API TreeYieldTable {
17  public:
19  virtual ~TreeYieldTable() = default;
20 
24  int maxAge() const { return _maxAge; };
25 
29  double totalVolume() const { return _totalVolume; };
30 
34  std::vector<double>& yieldsAtEachAge() { return _yieldsAtEachAge; };
35 
36  /*
37  Indexer to get the volume at each age
38  */
39  double operator[](int age) const;
40 
41  /*
42  *Get the species type for this yield table
43  */
44  SpeciesType speciesType() const { return _speciesType; }
45 
51  TreeYieldTable(const std::vector<DynamicObject>& yieldTable,
52  SpeciesType speciesType);
53  private:
60  void Initialize(const std::vector<DynamicObject>& yieldTable);
61 
65  void InterpolateVolumeAtEachAge();
66 
74  void preProcessYieldData();
75 
79  double linear(double x, double x0, double x1, double y0, double y1);
80 
81  int _maxAge;
83  double _totalVolume;
85  std::vector<double> _yieldsAtEachAge;
86  };
87 
88  inline double TreeYieldTable::linear(double x, double x0, double x1, double y0, double y1) {
89  if ((x1 - x0) == 0) {
90  return (y0 + y1) / 2;
91  } else {
92  return y0 + (x - x0) * (y1 - y0) / (x1 - x0);
93  }
94  }
95 
96 }}}
97 #endif
moja::modules::cbm::TreeYieldTable::_totalVolume
double _totalVolume
Definition: treeyieldtable.h:83
moja::modules::cbm::TreeYieldTable::yieldsAtEachAge
std::vector< double > & yieldsAtEachAge()
Vector of volume (m^3/ha) at each age stop, 1 ha = 10,000 m^2
Definition: treeyieldtable.h:34
moja::modules::cbm
Definition: ageclasshelper.cpp:12
moja::modules::cbm::SpeciesType
SpeciesType
Enumeration of tree species type, softwood or hardwood.
Definition: treespecies.h:14
moja::modules::cbm::TreeYieldTable::_maxAge
int _maxAge
Definition: treeyieldtable.h:81
moja::modules::cbm::TreeYieldTable
ADT - Tree yield table
Definition: treeyieldtable.h:16
moja::modules::cbm::TreeYieldTable::totalVolume
double totalVolume() const
Total volume of the speciese growth curve
Definition: treeyieldtable.h:29
moja::modules::cbm::TreeYieldTable::linear
double linear(double x, double x0, double x1, double y0, double y1)
http://stackoverflow.com/questions/12838007/c-sharp-linear-interpolation
Definition: treeyieldtable.h:88
moja::modules::cbm::TreeYieldTable::_yieldsAtEachAge
std::vector< double > _yieldsAtEachAge
Definition: treeyieldtable.h:85
moja::modules::cbm::TreeYieldTable::maxAge
int maxAge() const
Maximum age of the yield table
Definition: treeyieldtable.h:24
moja::modules::cbm::TreeYieldTable::_speciesType
SpeciesType _speciesType
Definition: treeyieldtable.h:84
moja::modules::cbm::TreeYieldTable::_ageInterval
int _ageInterval
Definition: treeyieldtable.h:82
moja::modules::cbm::TreeYieldTable::speciesType
SpeciesType speciesType() const
Definition: treeyieldtable.h:44
moja
Definition: ageclasshelper.cpp:10
treespecies.h