26#ifndef __TERRALIB_MAPTOOLS_INTERNAL_GROUPINGALGORITHMS_H 
   27#define __TERRALIB_MAPTOOLS_INTERNAL_GROUPINGALGORITHMS_H 
   31#include "../core/translator/Translator.h" 
   32#include "../common/StringUtils.h" 
   33#include "../fe/Utils.h" 
   34#include "../se/Description.h" 
   35#include "../se/Rule.h" 
   46#define MIN(a,b) ( (a<b) ? a : b )   
   50#define MAX(a,b) ( (a>b) ? a : b )   
   70                                            std::vector<te::se::Rule*>& rules, 
int precision);
 
   95    template<
class iterator>
 
   96    void GroupingByEqualSteps(std::string attrName, iterator begin, iterator end, 
int nSteps, std::vector<te::se::Rule*>& rules,
 
   99      double min = std::numeric_limits<double>::max();
 
  100      double max = -std::numeric_limits<double>::max();
 
  111      double min_slice, max_slice;
 
  113      double slice = (max - min)/
double(nSteps);
 
  115      for(
int i = 0; i < nSteps; ++i)
 
  120          min_slice = min + double(i) * slice;
 
  125          max_slice = min + double(i + 1) * slice;
 
  129        std::string* ruleNamePtr = 
new std::string(ruleName);
 
  130        ruleItem->
setName(ruleNamePtr);
 
  133        rules.push_back(ruleItem);
 
  149    template<
class iterator>
 
  150    void GroupingByQuantil(std::string attrName, iterator begin, iterator end, 
int nSteps, std::vector<te::se::Rule*>& rules,
 
  155      int size = 
static_cast<int>(end - begin);
 
  156      double steps = (double)size / (
double)nSteps;
 
  158      std::vector< std::pair<std::string, std::string> > pairMinMax;
 
  165        std::string maxValue = 
"";
 
  167        int p = (int)(steps * (
double)++n + .5);
 
  175        std::pair<std::string, std::string> pair(minValue, maxValue);
 
  177        pairMinMax.push_back(pair);
 
  182        double min = (*begin);
 
  183        double max = (*(end-1));
 
  192      for (std::size_t t = 0; t < pairMinMax.size(); ++t)
 
  195        std::string ruleName = 
"[" + pairMinMax[t].first + 
", " + pairMinMax[t].second + 
"[";
 
  196        std::string* ruleNamePtr = 
new std::string(ruleName);
 
  197        ruleItem->
setName(ruleNamePtr);
 
  200        rules.push_back(ruleItem);
 
  217    template<
class iterator>
 
  218    void GroupingByStdDeviation(std::string attrName, iterator begin, iterator end, 
double nDevs, std::vector<te::se::Rule*>& rules,
 
  219      std::string& meanTitle, 
int precision = 0)
 
  222      double min = std::numeric_limits<double>::max();
 
  223      double max = -std::numeric_limits<double>::max();
 
  224      long double  sum = 0.;
 
  225      long double  sm2 = 0.;
 
  233        sm2 += ((*it) * (*it));
 
  237      double count = (double)(end - begin);
 
  238      double mean = (double)(sum / count);
 
  239      long double var = (sm2 / count) - (mean * mean);
 
  240      double stdDev = sqrt(var);
 
  242      double slice = stdDev * nDevs;
 
  244      std::vector<te::se::Rule*> aux;
 
  249      while (val - slice > min - slice)
 
  253        double v = val - slice;
 
  255        std::string* ruleNamePtr = 
new std::string(ruleName);
 
  256        ruleItem->
setName(ruleNamePtr);
 
  259        aux.push_back(ruleItem);
 
  264      std::vector<te::se::Rule*>::reverse_iterator sit;
 
  265      for (sit = aux.rbegin(); sit != aux.rend(); ++sit)
 
  266        rules.push_back(*sit);
 
  268      meanTitle = 
TE_TR(
"Mean - ") + strMean;
 
  271      std::string* ruleNamePtr = 
new std::string(meanTitle);
 
  272      ruleItemMean->
setName(ruleNamePtr);
 
  274      rules.push_back(ruleItemMean);
 
  277      while (val + slice < max + slice)
 
  281        double v = val + slice;
 
  283        std::string* ruleNamePtr = 
new std::string(ruleName);
 
  284        ruleItem->
setName(ruleNamePtr);
 
  287        aux.push_back(ruleItem);
 
#define MIN(a, b)
Macro that returns min between two values.
 
#define MAX(a, b)
Macro that returns max between two values.
 
#define TE_TR(message)
It marks a string in order to get translated.
 
A Rule is used to attach property/scale conditions to and group the individual symbols used for rende...
 
void setName(std::string *name)
 
void setFilter(te::fe::Filter *f)
 
std::string Convert2String(boost::int16_t value)
It converts a short integer value to a string.
 
TEFEEXPORT te::fe::Filter * CreateFilterByStep(const std::string &attrName, const std::string &minValue, const std::string &maxValue)
 
TEMAPEXPORT double AdjustToPrecision(double val, int precision, bool reduce=false)
It adjusts a value to the precision specified.
 
void GroupingByStdDeviation(std::string attrName, iterator begin, iterator end, double nDevs, std::vector< te::se::Rule * > &rules, std::string &meanTitle, int precision=0)
It groups the values defined by a range of iterators using the standard deviation algorithm.
 
TEMAPEXPORT void GroupingByUniqueValues(std::string attrName, std::vector< std::string > &inputValues, int dataType, std::vector< te::se::Rule * > &rules, int precision)
It groups the values using the unique value algorithm.
 
void GroupingByQuantil(std::string attrName, iterator begin, iterator end, int nSteps, std::vector< te::se::Rule * > &rules, int precision=0)
It groups the values defined by a range of iterators using the quantil algorithm.
 
void GroupingByEqualSteps(std::string attrName, iterator begin, iterator end, int nSteps, std::vector< te::se::Rule * > &rules, int precision=0)
It groups the values defined by a range of iterators using the equal steps algorithm.
 
Proxy configuration file for TerraView (see terraview_config.h).