26 #ifndef __TERRALIB_MAPTOOLS_INTERNAL_GROUPINGALGORITHMS_H    27 #define __TERRALIB_MAPTOOLS_INTERNAL_GROUPINGALGORITHMS_H    31 #include "../common/StringUtils.h"    32 #include "../maptools/GroupingItem.h"    43 #define MIN(a,b) ( (a<b) ? a : b )      47 #define MAX(a,b) ( (a>b) ? a : b )      66                                             std::vector<te::map::GroupingItem*>& legend, 
int precision);
    91     template<
class iterator>
    92     void GroupingByEqualSteps(iterator begin, iterator end, 
int nSteps, std::vector<te::map::GroupingItem*>& legend,
    93                               int precision = 0, 
bool countElements = 
true)
    95       double min = std::numeric_limits<double>::max();
    96       double max = -std::numeric_limits<double>::max();
   107       double slice = (max - min)/
double(nSteps);
   109       for(
int i = 0; i < nSteps; ++i)
   114         legend.push_back(legendItem);
   123       if (countElements == 
true)
   139     template<
class iterator>
   140     void GroupingByQuantil(iterator begin, iterator end, 
int nSteps, std::vector<te::map::GroupingItem*>& legend,
   141                           int precision = 0, 
bool countElements = 
true)
   145       int size = end - begin;
   146       double steps = (double)size / (
double)nSteps;
   155         int p = (int)(steps * (
double)++n + .5);
   163         legend.push_back(legendItem);
   168         double min = (*begin);
   169         double max = (*(end-1));
   179       if (countElements == 
true)
   196     template<
class iterator>
   198                                 std::string& meanTitle, 
int precision = 0, 
bool countElements = 
true)
   201       double min = std::numeric_limits<double>::max();
   202       double max = -std::numeric_limits<double>::max();
   203       long double  sum = 0.;
   204       long double  sm2 = 0.;
   212         sm2 += ((*it) * (*it));
   216       double count = (double)(end - begin);
   217       double mean = (double)(sum/count);
   218       long double var = (sm2 / count) - (mean * mean);
   219       double stdDev = sqrt(var);
   221       double slice = stdDev * nDevs;
   223       std::vector<te::map::GroupingItem*> aux;
   228       while(val - slice > min - slice)
   232         double v = val - slice;
   236         aux.push_back(legendItem);
   240       std::vector<te::map::GroupingItem*>::reverse_iterator sit;
   241       for(sit = aux.rbegin(); sit != aux.rend(); ++sit)
   242         legend.push_back(*sit);
   244       meanTitle = 
"Mean - " + strMean;
   249       legendItemMean->
setTitle(meanTitle);
   250       legend.push_back(legendItemMean);
   253       while(val + slice < max + slice)
   257         double v = val + slice;
   261         legend.push_back(legendItem);
   278       if (countElements == 
true)
   291     template<
class iterator>
   298       for (
unsigned int i = 0; i < legend.size(); ++i)
   306         for (it = begin; it != end; ++it)
   308           if(*it >= from && *it < to)
   318 #endif   //__TERRALIB_MAPTOOLS_INTERNAL_GROUPINGALGORITHMS_H 
#define MIN(a, b)
Macro that returns min between two values. 
 
void setTitle(const std::string &title)
It sets the title of the legend item. 
 
void GroupingByEqualSteps(iterator begin, iterator end, int nSteps, std::vector< te::map::GroupingItem * > &legend, int precision=0, bool countElements=true)
It groups the values defined by a range of iterators using the equal steps algorithm. 
 
TEMAPEXPORT void GroupingByUniqueValues(std::vector< std::string > &inputValues, int dataType, std::vector< te::map::GroupingItem * > &legend, int precision)
It groups the values using the unique value algorithm. 
 
#define MAX(a, b)
Macro that returns max between two values. 
 
TEMAPEXPORT double AdjustToPrecision(double val, int precision, bool reduce=false)
It adjusts a value to the precision specified. 
 
void GroupingByStdDeviation(iterator begin, iterator end, double nDevs, std::vector< te::map::GroupingItem * > &legend, std::string &meanTitle, int precision=0, bool countElements=true)
It groups the values defined by a range of iterators using the standard deviation algorithm...
 
const std::string & getUpperLimit() const 
It gets the upper limit value of the legend item. 
 
const std::string & getLowerLimit() const 
It gets the lower limit value of the legend item. 
 
A GroupingItem contains information about a grouping item associated to a layer. 
 
void GroupingByQuantil(iterator begin, iterator end, int nSteps, std::vector< te::map::GroupingItem * > &legend, int precision=0, bool countElements=true)
It groups the values defined by a range of iterators using the quantil algorithm. ...
 
void setCount(std::size_t count)
It It sets the number of objects whose values are between the lower and upper limits. 
 
void setUpperLimit(const std::string &to)
It sets the upper limit value of the legend item. 
 
std::string Convert2String(boost::int16_t value)
It converts a short integer value to a string. 
 
void SetNumberOfElementsByLegendItem(iterator begin, iterator end, std::vector< te::map::GroupingItem * > &legend)
It sets the number of elements belonging to the range of values associated to each legend item...
 
void setLowerLimit(const std::string &from)
It sets the lower limit value of the legend item.