FFSM++
1.1.0
French Forest Sector Model ++
|
Define layer objects at the regional level. More...
#include <Layers.h>
Public Member Functions | |
Layers (ThreadManager *MTHREAD_h, string name_h, string label_h, bool isInteger_h, bool dynamicContent_h, string fullFilename_h, bool display_h=true) | |
In the constructor we set the main layer properties. More... | |
~Layers () | |
void | addLegendItem (int ID_h, string label_h, int rColor_h, int gColor_h, int bColor_h, double minValue_h, double maxValue_h) |
Add a legend item. More... | |
void | addLegendItems (vector< LegendItems > legendItems_h) |
vector< LegendItems > | getLegendItems () |
QColor | getColor (double ID_h) |
Evaluates all the legend items to find the one that match the input code, and return its color as a QColor. More... | |
string | getCategory (double ID_h) |
Evaluates all the legend items to find the one that match the input code, and return its label. More... | |
double | filterExogenousDataset (double code_h) |
Used to reclassify the land use map for "generic" categories. More... | |
void | countMyPixels (bool debug=false) |
Count the pixels going to each legend item and print them if debug==true. More... | |
void | randomShuffle () |
For some sensitivity analisys, random the values for this layer for not-empty values (only integer layers) More... | |
bool | getIsInteger () |
Return if the layer is integer or not (If integer on each legend item: minValue==maxValue==ID) More... | |
void | print () |
Print the layer content as an ASCII grid map with its companion files (classification and colors). It always print the whole region, even when subregion is actived. More... | |
void | printBinMap () |
Print a binary reppresentation of the data (a standard image, e.g. a .png file). It prints only the subregion if this is active. More... | |
string | getName () const |
string | getFilename () |
Return the filename of the associated dataset. More... | |
bool | getDynamicContent () |
Return true if the content may change during simulation period. More... | |
bool | getDisplay () |
Public Member Functions inherited from BaseClass | |
BaseClass () | |
~BaseClass () | |
void | msgOut (const int &msgCode_h, const string &msg_h, const bool &refreshGUI_h=true) const |
Overloaded function to print the output log. More... | |
void | msgOut (const int &msgCode_h, const int &msg_h, const bool &refreshGUI_h=true) const |
Overloaded function to print the output log. More... | |
void | msgOut (const int &msgCode_h, const double &msg_h, const bool &refreshGUI_h=true) const |
Overloaded function to print the output log. More... | |
int | s2i (const string &string_h) const |
string to integer conversion More... | |
double | s2d (const string &string_h) const |
string to double conversion More... | |
double | s2d (const string &string_h, const bool &replaceComma) const |
string to double conversion More... | |
bool | s2b (const string &string_h) const |
string to bool conversion More... | |
string | i2s (const int &int_h) const |
integer to string conversion More... | |
string | d2s (const double &double_h) const |
double to string conversion More... | |
string | b2s (const bool &bool_h) const |
bool to string conversion More... | |
vector< int > | s2i (const vector< string > &string_h) const |
string to integer conversion (vector) More... | |
vector< double > | s2d (const vector< string > &string_h, const bool &replaceComma=false) const |
string to double conversion (vector) More... | |
vector< bool > | s2b (const vector< string > &string_h) const |
string to bool conversion (vector) More... | |
vector< string > | i2s (const vector< int > &int_h) const |
integer to string conversion (vector) More... | |
vector< string > | d2s (const vector< double > &double_h) const |
double to string conversion (vector) More... | |
vector< string > | b2s (const vector< bool > &bool_h) const |
bool to string conversion (vector) More... | |
int | getType (const string &type_h) const |
Return a type according to enum TYPE_* from a string (eg: "string" -> TYPE_STRING (2)) More... | |
void | refreshGUI () const |
Ping to periodically return the control to the GUI. More... | |
template<typename T > | |
string | toString (const T &x) const |
template<typename T > | |
T | stringTo (const std::string &s) const |
int | vSum (const vector< int > &vector_h) const |
double | vSum (const vector< double > &vector_h) const |
int | vSum (const vector< vector< int > > &vector_h) const |
double | vSum (const vector< vector< double > > &vector_h) const |
void | tokenize (const string &str, vector< string > &tokens, const string &delimiter=" ") const |
Tokenize a string using a delimiter (default is space) More... | |
void | untokenize (string &str, vector< string > &tokens, const string &delimiter=" ") const |
template<typename K , typename V > | |
V | findMap (const map< K, V > &mymap, const K &key, const int &error_level=MSG_CRITICAL_ERROR, const V ¬FoundValue=numeric_limits< V >::min()) const |
Lookup a map for a value. Return the value starting from the key. More... | |
template<typename K , typename V > | |
void | changeMapValue (map< K, V > &mymap, const K &key, const V &value, const int &error_level=MSG_CRITICAL_ERROR) |
Change the value stored in a map given the key and the new value. More... | |
template<typename K , typename V > | |
void | incrMapValue (map< K, V > &mymap, const K &key, const V &value, const int &error_level=MSG_CRITICAL_ERROR) |
Increments a value stored in a map of the specified value, given the key. More... | |
template<typename K , typename V > | |
void | incrOrAddMapValue (map< K, V > &mymap, const K &key, const V &value) |
Increments a value stored in a map of the specified value, given the key. More... | |
template<typename K , typename V > | |
void | resetMapValues (map< K, V > &mymap, const V &value) |
Reset all values stored in a map to the specified one. More... | |
template<typename K , typename V > | |
map< K, V > | vectorToMap (const vector< K > &keys, const V &value=0.0) |
Returns a map built using the given vector and the given (scalar) value as keys/values pairs. More... | |
template<typename T > | |
vector< T > | positionsToContent (const vector< T > &vector_h, const vector< int > &positions) |
Return a vector of content from a vector and a vector of positions (int) More... | |
template<typename V > | |
void | debugMap (const map< iisskey, V > &mymap) |
Debug a map. More... | |
template<typename K , typename V > | |
void | debugMap (const map< K, V > &mymap, const K &key) |
template<typename K > | |
int | getMaxPos (const vector< K > &v) |
Returns the position of the maximum element in the vector (the last one in case of multiple equivalent maxima) More... | |
template<typename K > | |
int | getMinPos (const vector< K > &v) |
Returns the position of the minimum element in the vector (the first one in case of multiple equivalent minima) More... | |
template<typename K > | |
K | getMax (const vector< K > &v) |
Returns the value of the maximum element in the vector (the last one in case of multiple equivalent maxima) More... | |
template<typename K > | |
K | getMin (const vector< K > &v) |
Returns the value of the minimum element in the vector (the first one in case of multiple equivalent minima) More... | |
template<typename K > | |
double | getAvg (const vector< K > &v) |
Returns the average of the elements in the vector. More... | |
template<typename K > | |
double | getSd (const vector< K > &v, bool sample=true) |
template<typename K > | |
int | getPos (const K &element, const vector< K > &v, const int &msgCode_h=MSG_CRITICAL_ERROR) |
template<typename K > | |
bool | inVector (const K &element, const vector< K > &v) |
double | normSample (const double &avg, const double &stdev, const double &minval=NULL, const double &maxval=NULL) const |
Sample from a normal distribution with bounds. Slower (double time, but still you see the diff only after milion of loops). More... | |
template<typename K > | |
K | normSample (normal_distribution< K > &d, std::mt19937 &gen, const K &minval=NULL, const K &maxval=NULL) const |
Sample from a normal distribution with bounds. Faster (half time) as the normal_distribution is made only once. More... | |
template<typename T > | |
std::string | toString (const T &x) const |
Private Attributes | |
string | name |
ID of the layer (no spaces allowed) More... | |
string | label |
Label of the layer (spaces allowed) More... | |
bool | isInteger |
Type of the layer (true==integer, false==double. If true, on each legend item: minValue==maxValue==ID) More... | |
bool | dynamicContent |
True if the content may change during simulation year. More... | |
bool | display |
Normally true, but some layers used to just keep data shoudn't be normally processed. More... | |
string | fullFileName |
Filename of the associated dataset (map) More... | |
vector< LegendItems > | legendItems |
Vector of legend items. More... | |
vector< ReclassRules > | reclassRulesVector |
Vector of initial reclassification rules. More... | |
Additional Inherited Members | |
Protected Attributes inherited from BaseClass | |
ThreadManager * | MTHREAD |
Pointer to the Thread manager. More... | |
Define layer objects at the regional level.
Layer class (setting, legend...)
This class define layer objects, including:
Layers | ( | ThreadManager * | MTHREAD_h, |
string | name_h, | ||
string | label_h, | ||
bool | isInteger_h, | ||
bool | dynamicContent_h, | ||
string | fullFilename_h, | ||
bool | display_h = true |
||
) |
In the constructor we set the main layer properties.
Definition at line 32 of file Layers.cpp.
~Layers | ( | ) |
Definition at line 43 of file Layers.cpp.
void addLegendItem | ( | int | ID_h, |
string | label_h, | ||
int | rColor_h, | ||
int | gColor_h, | ||
int | bColor_h, | ||
double | minValue_h, | ||
double | maxValue_h | ||
) |
Add a legend item.
Definition at line 48 of file Layers.cpp.
void addLegendItems | ( | vector< LegendItems > | legendItems_h | ) |
Definition at line 72 of file Layers.cpp.
Referenced by Gis::applyForestReclassification().
void countMyPixels | ( | bool | debug = false | ) |
Count the pixels going to each legend item and print them if debug==true.
Definition at line 188 of file Layers.cpp.
double filterExogenousDataset | ( | double | code_h | ) |
Used to reclassify the land use map for "generic" categories.
Used in the init stage, this function take as input the real map code as just read from the map file, and filter it according to the reclassification rules.
Definition at line 97 of file Layers.cpp.
string getCategory | ( | double | ID_h | ) |
Evaluates all the legend items to find the one that match the input code, and return its label.
This function take as input the value stored in the pixel for the specific layer, loops over the legend item and find the one that match it, returning its label.
If the layer is of type integer, the match is agains legendItem IDs, otherwise we compare the legendItem ranges.
Definition at line 162 of file Layers.cpp.
QColor getColor | ( | double | ID_h | ) |
Evaluates all the legend items to find the one that match the input code, and return its color as a QColor.
This function take as input the value stored in the pixel for the specific layer, loops over the legend item and find the one that match it, returning its color.
If the layer is of type integer, the match is agains legendItem IDs, otherwise we compare the legendItem ranges.
Definition at line 132 of file Layers.cpp.
Referenced by printBinMap().
|
inline |
Definition at line 94 of file Layers.h.
|
inline |
Return true if the content may change during simulation period.
Definition at line 93 of file Layers.h.
|
inline |
Return the filename of the associated dataset.
Definition at line 91 of file Layers.h.
|
inline |
Return if the layer is integer or not (If integer on each legend item: minValue==maxValue==ID)
Definition at line 83 of file Layers.h.
|
inline |
Definition at line 70 of file Layers.h.
Referenced by Gis::applyForestReclassification().
void print | ( | ) |
Print the layer content as an ASCII grid map with its companion files (classification and colors). It always print the whole region, even when subregion is actived.
Definition at line 251 of file Layers.cpp.
void printBinMap | ( | ) |
Print a binary reppresentation of the data (a standard image, e.g. a .png file). It prints only the subregion if this is active.
Definition at line 354 of file Layers.cpp.
void randomShuffle | ( | ) |
For some sensitivity analisys, random the values for this layer for not-empty values (only integer layers)
Definition at line 224 of file Layers.cpp.
|
private |
Normally true, but some layers used to just keep data shoudn't be normally processed.
Definition at line 102 of file Layers.h.
Referenced by Layers(), and printBinMap().
|
private |
True if the content may change during simulation year.
Definition at line 101 of file Layers.h.
Referenced by Layers(), and printBinMap().
|
private |
|
private |
Type of the layer (true==integer, false==double. If true, on each legend item: minValue==maxValue==ID)
Definition at line 100 of file Layers.h.
Referenced by countMyPixels(), getCategory(), getColor(), Layers(), and print().
|
private |
Label of the layer (spaces allowed)
Definition at line 99 of file Layers.h.
Referenced by addLegendItem(), countMyPixels(), and Layers().
|
private |
Vector of legend items.
Definition at line 104 of file Layers.h.
Referenced by addLegendItem(), addLegendItems(), countMyPixels(), getCategory(), getColor(), and print().
|
private |
ID of the layer (no spaces allowed)
Definition at line 98 of file Layers.h.
Referenced by addLegendItems(), countMyPixels(), Layers(), print(), printBinMap(), and randomShuffle().
|
private |
Vector of initial reclassification rules.
Definition at line 105 of file Layers.h.
Referenced by filterExogenousDataset().