All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
Utils.cpp
Go to the documentation of this file.
1 /* Copyright (C) 2008 National Institute For Space Research (INPE) - Brazil.
2 
3  This file is part of the TerraLib - a Framework for building GIS enabled applications.
4 
5  TerraLib is free software: you can redistribute it and/or modify
6  it under the terms of the GNU Lesser General Public License as published by
7  the Free Software Foundation, either version 3 of the License,
8  or (at your option) any later version.
9 
10  TerraLib is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  GNU Lesser General Public License for more details.
14 
15  You should have received a copy of the GNU Lesser General Public License
16  along with TerraLib. See COPYING. If not, write to
17  TerraLib Team at <terralib-team@terralib.org>.
18  */
19 
20 /*!
21  \file Utils.cpp
22 
23  \brief This file contains a set of utility chart functions
24 */
25 
26 // TerraLib
27 #include "../../../color/RGBAColor.h"
28 #include "../../../common/progress/TaskProgress.h"
29 #include "../../../dataaccess/dataset/DataSet.h"
30 #include "../../../dataaccess/dataset/DataSetType.h"
31 #include "../../../dataaccess/dataset/ObjectIdSet.h"
32 #include "../../../dataaccess/utils/Utils.h"
33 #include "../../../datatype.h"
34 #include "../../../raster.h"
35 #include "../../../maptools/ExternalGraphicRendererManager.h"
36 #include "../../../maptools/MarkRendererManager.h"
37 #include "../../../qt/widgets/Utils.h"
38 #include "../../../se/Utils.h"
39 #include "../../../se.h"
40 #include "../../../statistics/core/Enums.h"
41 #include "../../../statistics/core/NumericStatisticalSummary.h"
42 #include "../../../statistics/core/StringStatisticalSummary.h"
43 #include "../../../statistics/core/SummaryFunctions.h"
44 #include "../../../statistics/core/Utils.h"
45 #include "ChartDisplay.h"
46 #include "ChartDisplayWidget.h"
47 #include "ChartStyle.h"
48 #include "Histogram.h"
49 #include "HistogramChart.h"
50 #include "Scatter.h"
51 #include "ScatterChart.h"
52 #include "Utils.h"
53 
54 //Boost
55 #include <boost/lexical_cast.hpp>
56 #include <boost/ptr_container/ptr_vector.hpp>
57 
58 //QT
59 #include <QPen>
60 
61 //STL
62 #include <memory>
63 
64 float gammln( float xx )
65 {
66  double x, tmp, ser;
67  static double cof[6]= {76.18009173, -86.50532033, 24.01409822,
68  -1.231739516, 0.120858003e-2, -0.536382e-5};
69  int j;
70 
71  x = xx - 1.0;
72  tmp = x + 5.5;
73  tmp -= (x+0.5)*log(tmp);
74  ser = 1.0;
75 
76  for (j=0; j<=5; j++)
77  {
78  x += 1.0;
79  ser += cof[j]/x;
80  }
81  return (float)(-tmp + log(2.50662827465*ser));
82 }
83 
84 void gser( float * gamser, float a, float x, float * gln )
85 {
86  double ITMAX = 100;
87  double EPS = 3.0e-7;
88 
89  int n;
90  float sum, del,ap;
91 
92  *gln = gammln(a);
93 
94  if (x <= 0.0)
95  {
96  if ( x < 0.0)
97  printf ("x less than 0 in the GSER routine");
98 
99  *gamser = 0.0;
100  return;
101  }
102 
103  else
104  {
105  ap = a;
106  del= sum = (float)(1.0/a);
107  for (n=1; n <= ITMAX; n++)
108  {
109  ap += 1.0;
110  del *= x/ap;
111  sum += del;
112  if (fabs (del) < fabs (sum)*EPS)
113  {
114  *gamser = (float)(sum*exp(-x+a*log(x)-(*gln)));
115  return;
116  }
117  }
118  return;
119  }
120 }
121 
122 void gcf( float * gammcf, float a, float x, float * gln )
123 {
124  double ITMAX = 100;
125  double EPS = 3.0e-7;
126 
127  int n;
128  float gold=0.0, g, fac=1.0, b1=1.0;
129  float b0=0.0, anf, ana, an, a1, a0=1.0;
130 
131  *gln=gammln(a);
132 
133  a1=x;
134 
135  for(n=1; n<= ITMAX; n++)
136  {
137  an = (float) n;
138  ana = an - a;
139  a0 = (a1+a0*ana)*fac;
140  b0 = (b1+b0*ana)*fac;
141  anf = an*fac;
142  a1 = x*a0+anf*a1;
143  b1 = x*b0+anf*b1;
144  if (a1)
145  {
146  fac = (float)(1.0/a1);
147  g = b1*fac;
148  if (fabs((g-gold)/g) < EPS)
149  {
150  *gammcf = (float)(exp (-x+a*log(x)-(*gln))*g);
151  return;
152  }
153  gold = g;
154  }
155  }
156 }
157 
158 float gammp( float a, float x )
159 {
160  float gamser, gammcf, gln;
161 
162  if (x < (a+1.0))
163  {
164  gser (&gamser, a, x, &gln);
165  return gamser;
166  }
167  else
168  {
169  gcf (&gammcf, a, x, &gln);
170  return (float)(1.0 - gammcf);
171  }
172 }
173 
174 float errFunction( float x )
175 {
176  return x < 0.0 ? -gammp(0.5, x*x) : gammp(0.5,x*x);
177 }
178 
179 double getDouble(const std::string& value, std::vector<std::string>& sVector)
180 {
181  //verify if it exists
182  for(std::size_t i=0;i<sVector.size();++i)
183  {
184  if(value==sVector[i])
185  return (double)i;
186  }
187 
188  sVector.push_back(value);
189  return (double)sVector.size()-1;
190 }
191 
192 double getDouble(te::dt::DateTime* dateTime)
193 {
194  if(dateTime->getDateTimeType() == te::dt::TIME_INSTANT)
195  {
196  std::auto_ptr<te::dt::TimeInstant> ti ((te::dt::TimeInstant*)dateTime);
197  boost::gregorian::date basedate(1400, 01, 01);
198  boost::gregorian::date_duration days = ti->getDate().getDate() - basedate;
199  long long int seconds = ti->getTime().getTimeDuration().total_seconds();
200  long long int dias = days.days();
201  double v = (double) dias * 86400 + seconds;
202  return v;
203  }
204  else if(dateTime->getDateTimeType() == te::dt::DATE)
205  {
206  std::auto_ptr<te::dt::Date> d ((te::dt::Date*)dateTime);
207  boost::gregorian::date basedate(1400, 01, 01);
208  boost::gregorian::date_duration days = d->getDate() - basedate;
209  double v = days.days();
210  return v;
211  }
212  return 0.;
213 }
214 
215 /*
216  Auxiliary function used to acquire the current value of the dataset as a double regardless of it's (numeric) type
217 
218  param dataset The dataset being used, must be given at the position of interest
219  param propId The id of the property of interest;
220  note Will return 0 if the type of the property was not numeric.
221 */
222 double getDouble(te::da::DataSet* dataset, int propId)
223 {
224  double res = 0.;
225 
226  int propType = dataset->getPropertyDataType(propId);
227  switch (propType)
228  {
229  case(te::dt::INT16_TYPE):
230  res = dataset->getInt16(propId);
231  break;
232  case(te::dt::UINT16_TYPE):
233  res = dataset->getInt16(propId);
234  break;
235  case(te::dt::INT32_TYPE):
236  res = dataset->getInt32(propId);
237  break;
238  case(te::dt::UINT32_TYPE):
239  res = dataset->getInt32(propId);
240  break;
241  case(te::dt::INT64_TYPE):
242  res = dataset->getInt64(propId);
243  break;
244  case(te::dt::UINT64_TYPE):
245  res = dataset->getInt64(propId);
246  break;
247  case(te::dt::FLOAT_TYPE):
248  res = dataset->getFloat(propId);
249  break;
250  case(te::dt::NUMERIC_TYPE):
251  res = boost::lexical_cast<double>(dataset->getNumeric(propId));
252  break;
253  default:
254  res = dataset->getDouble(propId);
255  break;
256  }
257 
258  return res;
259 }
260 
261 /*
262  Auxiliary function used to acquire the summarized string value of the dataset using the selected statistical function
263 
264  param stat The selected satistical function, pass -1 if no function is to be used;
265  param sss The StringStatisticalSummary that will make the relevant calculations and return the result
266 */
268 {
269  std::string res;
270 
271  switch (stat)
272  {
273  case(te::stat::MIN_VALUE):
274  res = sss.m_minVal;
275  break;
276  case(te::stat::MAX_VALUE):
277  res = sss.m_maxVal;
278  break;
279  //case(te::stat::COUNT):
280  // res = dataset->size();
281  // break;
282  //case(te::stat::VALID_COUNT):
283  // break;
284  default:
285  break;
286  }
287  return res;
288 }
289 
290 /*
291  Auxiliary function used to acquire the summarized double value of the dataset using the selected statistical function
292 
293  param stat The selected satistical function, pass -1 if no function is to be used;
294  param sss The NumericStatisticalSummary that will make the relevant calculations and return the result
295 */
297 {
298  double res;
299 
300  switch (stat)
301  {
302  case(te::stat::MIN_VALUE):
303  res = nss.m_minVal;
304  break;
305  case(te::stat::MAX_VALUE):
306  res = nss.m_maxVal;
307  break;
308  //case(te::stat::COUNT):
309  // res = dataset->size();
310  // break;
311  //case(te::stat::VALID_COUNT):
312  // res = getDouble(dataset, propId);
313  // break;
314  case(te::stat::MEAN):
315  res = nss.m_mean;
316  break;
317  case(te::stat::SUM):
318  res = nss.m_sum;
319  break;
321  res = nss.m_stdDeviation;
322  break;
323  case(te::stat::VARIANCE):
324  res = nss.m_variance;
325  break;
326  case(te::stat::SKEWNESS):
327  res = nss.m_skewness;
328  break;
329  case(te::stat::KURTOSIS):
330  res = nss.m_kurtosis;
331  break;
332  case(te::stat::AMPLITUDE):
333  res = nss.m_amplitude;
334  break;
335  case(te::stat::MEDIAN):
336  res = nss.m_median;
337  break;
338  case(te::stat::VAR_COEFF):
339  res = nss.m_varCoeff;
340  break;
341  //case(te::stat::MODE):
342  // res = nss.m_mode[0];
343  break;
344  default:
345  res = 0.0;
346  break;
347  }
348  return res;
349 }
350 
351 /*
352  Auxiliary function used to a scatter with summarized values
353 
354  param stat The selected satistical function, pass -1 if no function is to be used;
355  param oidsToSummarize A map containing all the objectIds mapped by the oid of the base dataset.
356  param valuesToSummarize A map containing all the values9points) mapped by the oid of the base dataset.
357  param scatter Output parameter, the scatter to be populated.
358 
359  note This function is only going to populate the sacatter's data if it a statistical funcion has been selected,
360  otherwise it will return the scatter as it received it.
361 */
362 void buildSummarizedScatter(int stat, std::map<std::string, std::vector<te::da::ObjectId*> > oidsToSummarize,
363  std::map<std::string, std::vector<std::pair<double, double> > > valuesToSummarize,
364  te::qt::widgets::Scatter* scatter)
365 {
366  //Containers used to hold informations temporarily, used to organize them prior to inserting them on the histogram.
367  std::map<std::string, std::vector<te::da::ObjectId*> >::iterator oidsIt;
368  std::map<std::string, std::vector<std::pair<double, double> > > ::iterator valuesIt;
370 
371  //Acquiring the summarized values
372  for(valuesIt = valuesToSummarize.begin(); valuesIt != valuesToSummarize.end(); ++valuesIt)
373  {
374  if((*valuesIt).second.size() > 1 && (stat != -1))
375  {
376  std::vector<double> xValues;
377  std::vector<double> yValues;
378  std::vector<te::da::ObjectId*> oids;
379 
380  for(size_t i = 0; i < (*valuesIt).second.size(); ++i)
381  {
382  xValues.push_back((*valuesIt).second[i].first);
383  yValues.push_back((*valuesIt).second[i].second);
384  oids = oidsToSummarize[(*valuesIt).first];
385  }
386 
387  double summarizedXValue, summarizedYValue;
388 
390  summarizedXValue = getStatisticalValue(stat, ss);
391 
393  summarizedYValue = getStatisticalValue(stat, ss);
394 
395  for(size_t j = 0; j < oids.size(); ++j)
396  scatter->addData(summarizedXValue, summarizedYValue, oids[j]);
397  }
398  else
399  {
400  //A summary was requested, but it was not needed due to the fact the there is only one value for each base oid
401 
402  double xValue = (*valuesIt).second[0].first;
403  double yValue = (*valuesIt).second[0].second;
404 
405  std::vector<te::da::ObjectId*> oids;
406  oids = oidsToSummarize[(*valuesIt).first];
407 
408  scatter->addData(xValue, yValue, oids[0]);
409  }
410  }
411 }
412 
413 /*
414  Auxiliary function used to populate the frequencies, interval and their respective objectIds based on a statistical function
415 
416  param slices The number of slices for the histogram, used to calculate the number of intervals;
417  param stat The selected satistical function, pass -1 if no function is to be used;
418  param valuestoSummarize a map containing all the values and their objectIds mapped by the oid of the base dataset,
419  defaults to a one-to-one relationship between value and objectId unless the histogram is based on a linked layer;
420  param intervals Output parameter, the vector containing the intervals.
421  param intervalToOIds Output parameter, the map that associates every interval to their objectIds.
422  param frequencies Output parameter, the vector containing the frequencies.
423  param minValue Output parameter, the minimum value of the histogram.
424  param interval Output parameter, the interval of the histogram.
425 */
426 void buildNumericFrequencies(int slices, int stat, std::map<std::string, std::vector<std::pair<double, te::da::ObjectId*> > > valuestoSummarize,
427  std::vector<double>& intervals, std::map<double, std::vector<te::da::ObjectId*> >& intervalToOIds,
428  std::vector< unsigned int>& frequencies, double& minValue, double& interval)
429 {
430  //Containers used to hold informations temporarily, used to organize them prior to inserting them on the histogram.
431  std::map<std::string, std::vector<std::pair<double, te::da::ObjectId*> > >::iterator valuesIt;
432  std::vector<std::pair<double, std::vector<te::da::ObjectId*> > > summarizedValuesToOId;
434 
435  //Acquiring the summarized values
436  for(valuesIt = valuestoSummarize.begin(); valuesIt != valuestoSummarize.end(); ++valuesIt)
437  {
438  if((*valuesIt).second.size() > 1 && stat != -1)
439  {
440  std::vector<double> values;
441  std::vector<te::da::ObjectId*> oids;
442  for(size_t i = 0; i < (*valuesIt).second.size(); ++i)
443  {
444  values.push_back((*valuesIt).second[i].first);
445  oids.push_back((*valuesIt).second[i].second);
446  }
447 
448  double summarizedValue;
450  summarizedValue = getStatisticalValue(stat, ss);
451  summarizedValuesToOId.push_back(std::make_pair(summarizedValue, oids));
452  }
453  else
454  {
455  for(size_t i = 0; i < (*valuesIt).second.size(); ++i)
456  {
457  std::vector<te::da::ObjectId*> oids;
458  oids.push_back((*valuesIt).second[i].second);
459  summarizedValuesToOId.push_back(std::make_pair((*valuesIt).second[i].first, oids));
460  }
461  }
462  }
463 
464  double maxValue = -std::numeric_limits<double>::max();
465 
466  for(size_t i = 0; i < summarizedValuesToOId.size(); ++i)
467  {
468  double currentValue = summarizedValuesToOId[i].first;
469 
470  //calculate range
471  if(minValue > currentValue)
472  minValue = currentValue;
473  if(maxValue < currentValue)
474  maxValue = currentValue;
475  }
476 
477  //Adjusting the interval to the user-defined number of slices.
478  interval = ((maxValue - minValue)/slices);
479 
480  //Adjusting the histogram's intervals
481  for (double i = minValue; i <(maxValue+interval); i+=interval)
482  {
483  intervals.push_back(i);
484  std::vector<te::da::ObjectId*> valuesOIds;
485  intervalToOIds.insert(std::make_pair(i, valuesOIds));
486  }
487 
488  frequencies.resize(intervals.size(), 0);
489 
490  //Adjusting the frequencies on each interval
491  for(size_t i = 0; i < summarizedValuesToOId.size(); ++i)
492  {
493  double currentValue = summarizedValuesToOId[i].first;
494  for (size_t j = 0; j<intervals.size(); ++j)
495  {
496  if((currentValue >= intervals[j]) && (currentValue <= intervals[j+1]))
497  {
498  for(size_t k= 0; k < summarizedValuesToOId[i].second.size(); ++k)
499  intervalToOIds.at(intervals[j]).push_back(summarizedValuesToOId[i].second[k]);
500 
501  frequencies[j] = frequencies[j]++;
502  break;
503  }
504  }
505  }
506 }
507 
508 /*
509  Auxiliary function used to populate the frequencies, interval and their respective objectIds based on a statistical function
510 
511  param stat The selected satistical function, pass -1 if no function is to be used;
512  param valuestoSummarize a map containing all the values and their objectIds mapped by the oid of the base dataset,
513  defaults to a one-to-one relationship between value and objectId unless the histogram is based on a linked layer;
514  param intervalToOIds Output parameter, the map that associates every interval to their objectIds.
515  param frequencies Output parameter, the vector containing the frequencies.
516 
517 */
518 void buildStringFrequencies(int stat, std::map<std::string, std::vector<std::pair<std::string, te::da::ObjectId*> > > valuestoSummarize,
519  std::map<std::string, std::vector<te::da::ObjectId*> >& intervalToOIds,
520  std::vector< unsigned int>& frequencies)
521 {
522  //Containers and iterators used to hold informations temporarily, used to organize them prior to inserting them on the histogram.
523  std::map<std::string, std::vector<std::pair<std::string, te::da::ObjectId*> > >::iterator valuesIt;
524  std::map<std::string, std::vector<te::da::ObjectId*> >::iterator intervalsIt;
525  std::vector<std::pair<std::string, std::vector<te::da::ObjectId*> > > summarizedValuesToOId;
527 
528  //Acquiring the summarized values
529  for(valuesIt = valuestoSummarize.begin(); valuesIt != valuestoSummarize.end(); ++valuesIt)
530  {
531  if((*valuesIt).second.size() > 1 && (stat != -1))
532  {
533  std::vector<std::string> values;
534  std::vector<te::da::ObjectId*> oids;
535  for(size_t i = 0; i < (*valuesIt).second.size(); ++i)
536  {
537  values.push_back((*valuesIt).second[i].first);
538  oids.push_back((*valuesIt).second[i].second);
539  }
540 
541  std::string summarizedValue;
543  summarizedValue = getStatisticalValue(stat, ss);
544  summarizedValuesToOId.push_back(std::make_pair(summarizedValue, oids));
545  }
546  else
547  {
548  for(size_t i = 0; i < (*valuesIt).second.size(); ++i)
549  {
550  std::vector<te::da::ObjectId*> oids;
551  oids.push_back((*valuesIt).second[i].second);
552  summarizedValuesToOId.push_back(std::make_pair((*valuesIt).second[i].first, oids));
553  }
554  }
555  }
556 
557  //Adjusting the frequencies on each interval
558  for(size_t i = 0; i < summarizedValuesToOId.size(); ++i)
559  {
560  int j;
561  std::string currentValue = summarizedValuesToOId[i].first;
562  for ( j= 0, intervalsIt = intervalToOIds.begin(); intervalsIt != intervalToOIds.end(); ++intervalsIt,++j)
563  {
564  if(currentValue == (*intervalsIt).first)
565  {
566  for(size_t k= 0; k < summarizedValuesToOId[i].second.size(); ++k)
567  intervalToOIds.at(currentValue).push_back(summarizedValuesToOId[i].second[k]);
568 
569  frequencies[j] = frequencies[j]++;
570  break;
571  }
572  }
573  }
574 }
575 
576 /*
577  Auxiliary function used to acquire the current objectId of the dataset
578 
579  param dataset The dataset being used, must be given at the position of interest;
580  param pkeys A vector containing all the properties that form the primaryKey of the given dataset
581 */
582 te::da::ObjectId* getObjectId(te::da::DataSet* dataset, std::vector<std::size_t> pkeys)
583 {
584  std::vector<size_t>::iterator it;
585  std::vector<std::string> propNames;
586 
587  for(it=pkeys.begin(); it!=pkeys.end(); ++it)
588  propNames.push_back(dataset->getPropertyName(*it));
589 
590  //The caller will take ownership of the generated pointer.
591  te::da::ObjectId* oid = te::da::GenerateOID(dataset, propNames);
592  return oid;
593 }
594 
595 void getObjectIds (te::da::DataSet* dataset, std::vector<std::size_t> pkeys, std::vector<te::da::ObjectId*>& valuesOIDs)
596 {
597  te::da::ObjectId* oid = getObjectId(dataset,pkeys);
598  valuesOIDs.push_back(oid);
599 }
600 
601 te::qt::widgets::Scatter* te::qt::widgets::createScatter(te::da::DataSet* dataset, te::da::DataSetType* dataType, int propX, int propY, int stat, bool readall)
602 {
604 
605  std::vector<std::size_t> objIdIdx;
606  te::da::GetOIDPropertyPos(dataType, objIdIdx);
607 
608  std::map<double, std::vector<te::da::ObjectId*> > valuesIdsByinterval;
609  std::vector<te::da::ObjectId*> valuesOIds;
610 
611  std::size_t rpos = te::da::GetFirstPropertyPos(dataset, te::dt::RASTER_TYPE);
612  if(rpos != std::string::npos)
613  {
614  std::auto_ptr<te::rst::Raster> raster(dataset->getRaster(rpos));
615 
616  unsigned int nCol = raster->getNumberOfColumns();
617  unsigned int nLin = raster->getNumberOfRows();
618 
620  task.setTotalSteps(nCol);
621  task.setMessage("Scatter creation");
622 
623  if (!readall)
624  {
625  unsigned int maxInputPoints = (nCol * nLin) * 0.10;
626  std::vector<te::gm::Point*> randomPoints = te::rst::GetRandomPointsInRaster(*raster, maxInputPoints);
629 
630  while (pit != pitend)
631  {
632  if(!task.isActive())
633  {
634  break;
635  }
636  double val1, val2;
637 
638  raster->getValue(pit.getColumn(), pit.getRow(), val1, propX);
639  raster->getValue(pit.getColumn(), pit.getRow(), val2, propY);
640 
641  newScatter->addX(val1);
642  newScatter->addY(val2);
643  ++pit;
644  task.pulse();
645  }
646  }
647  else
648  {
649  for (unsigned int c=0; c < nCol; ++c)
650  {
651  if(!task.isActive())
652  {
653  break;
654  }
655  for (unsigned int r=0; r <nLin; ++r)
656  {
657  double val1, val2;
658  raster->getValue(c, r, val1, propX);
659  raster->getValue(c, r, val2, propY);
660 
661  newScatter->addX(val1);
662  newScatter->addY(val2);
663  }
664 
665  task.pulse();
666  }
667  }
668  }
669  else
670  {
671  int xType = dataset->getPropertyDataType(propX);
672  int yType = dataset->getPropertyDataType(propY);
673 
674  //Acquiring the name of the base dataset and how many properties are included in it's primary key
675  std::pair<std::string, int> dsProps;
676  te::da::GetOIDDatasetProps(dataType, dsProps);
677 
678  //A map containg the summarized values used to buil d the histogram
679  std::map<std::string, std::vector<te::da::ObjectId*> > oidsToSummarize;
680  std::map<std::string, std::vector<std::pair<double, double> > > valuesToSummarize;
681 
683  task.setTotalSteps(dataset->getNumProperties());
684  task.setMessage("Scatter creation");
685 
686  while(dataset->moveNext())
687  {
688 
689  if(!task.isActive())
690  {
691  break;
692  }
693 
694  double x_doubleValue = 0.;
695  double y_doubleValue = 0.;
696 
697  if(xType >= te::dt::INT16_TYPE && xType <= te::dt::NUMERIC_TYPE)
698  {
699  if(dataset->isNull(propX))
700  continue;
701 
702  x_doubleValue = getDouble(dataset, propX);
703  }
704  else if(xType == te::dt::DATETIME_TYPE)
705  {
706  if(dataset->isNull(propX))
707  continue;
708 
709  std::auto_ptr<te::dt::DateTime> dateTime = dataset->getDateTime(propX);
710  x_doubleValue = getDouble(dateTime.release());
711  }
712 
713  //======treat the Y value
714  if(yType >= te::dt::INT16_TYPE && yType <= te::dt::NUMERIC_TYPE)
715  {
716  if(dataset->isNull(propY))
717  continue;
718  y_doubleValue = getDouble(dataset, propY);
719  }
720  else if(yType == te::dt::DATETIME_TYPE)
721  {
722  if(dataset->isNull(propY))
723  continue;
724 
725  std::auto_ptr<te::dt::DateTime> dateTime = dataset->getDateTime(propY);
726  y_doubleValue = getDouble(dateTime.release());
727  }
728 
729  //insert values into the vectors
730  te::da::ObjectId* currentOid = getObjectId(dataset, objIdIdx);
731 
732  if(stat == -1)
733  {
734  newScatter->addData(x_doubleValue, y_doubleValue, currentOid);
735  }
736  else
737  {
738  oidsToSummarize[te::da::getBasePkey(currentOid, dsProps)].push_back(currentOid);
739  valuesToSummarize[te::da::getBasePkey(currentOid, dsProps)].push_back(std::make_pair(x_doubleValue, y_doubleValue));
740  }
741  task.pulse();
742  } //end of the data set
743  if(stat != -1)
744  buildSummarizedScatter(stat, oidsToSummarize, valuesToSummarize, newScatter);
745  }
746  newScatter->calculateMinMaxValues();
747  return newScatter;
748 }
749 
751 {
752  //Creating the scatter and it's chart with the given dataset
753  te::qt::widgets::ScatterChart* chart = new te::qt::widgets::ScatterChart(te::qt::widgets::createScatter(dataset, dataType, propX, propY, stat));
754 
755  //Creating and adjusting the chart Display's style.
757  chartStyle->setTitle(QString::fromStdString("Scatter"));
758  chartStyle->setAxisX(QString::fromStdString(dataset->getPropertyName(propX)));
759  chartStyle->setAxisY(QString::fromStdString(dataset->getPropertyName(propY)));
760 
761  //Creating and adjusting the chart Display
762  te::qt::widgets::ChartDisplay* chartDisplay = new te::qt::widgets::ChartDisplay(0, QString::fromStdString("Scatter"), chartStyle);
763  chartDisplay->adjustDisplay();
764  chart->attach(chartDisplay);
765 
766  //Adjusting the chart widget
768  displayWidget->show();
769  displayWidget->setWindowTitle("Scatter");
770  return displayWidget;
771 }
772 
774 {
776 
777  std::size_t rpos = te::da::GetFirstPropertyPos(dataset, te::dt::RASTER_TYPE);
778  std::vector<std::size_t> objIdIdx;
779  te::da::GetOIDPropertyPos(dataType, objIdIdx);
780 
781  if(rpos != std::string::npos)
782  {
783  std::auto_ptr<te::rst::Raster> rstptr = dataset->getRaster(rpos);
784  std::map<double, unsigned int> values = rstptr->getBand(propId)->getHistogramR(0, 0, 0, 0, slices);
785 
786  for(std::map<double, unsigned int>::iterator it = values.begin(); it != values.end(); ++it)
787  {
788  newHistogram->insert(std::make_pair(new te::dt::Double(it->first), it->second));
789  }
790  newHistogram->setMinValue(rstptr->getBand(propId)->getMinValue(true).real());
791  }
792  else
793  {
794 
795  if(slices <=1)
796  slices = 2;
797 
798  int propType = dataset->getPropertyDataType(propId);
799  newHistogram->setType(propType);
800 
801  if((propType >= te::dt::INT16_TYPE && propType <= te::dt::UINT64_TYPE) ||
802  (propType >= te::dt::FLOAT_TYPE && propType <= te::dt::NUMERIC_TYPE))
803  {
804  //Acquiring the name of the base dataset and how many of it's properties are included in it's primary key
805  std::pair<std::string, int> dsProps;
806  te::da::GetOIDDatasetProps(dataType, dsProps);
807 
808  //A map containg the summarized values used to buil d the histogram
809  std::map<std::string, std::vector<std::pair<double, te::da::ObjectId*> > > valuesToSummarize;
810 
812  task.setMessage("Histogram creation");
813  task.setTotalSteps((dataset->getNumProperties()) * 2);
814 
815  dataset->moveBeforeFirst();
816 
817  //Adjusting the Histogram's values
818  while(dataset->moveNext())
819  {
820 
821  if(dataset->isNull(propId))
822  continue;
823 
824  if(!task.isActive())
825  {
826  break;
827  }
828 
829  double currentValue = getDouble(dataset, propId);
830  te::da::ObjectId* currentOid = getObjectId(dataset, objIdIdx);
831  valuesToSummarize[te::da::getBasePkey(currentOid, dsProps)].push_back(std::make_pair(currentValue, currentOid));
832 
833  task.pulse();
834  }
835 
836  //The minimum value
837  double minValue = std::numeric_limits<double>::max();
838 
839  //The interval (testing)
840  double interval = std::numeric_limits<double>::max();
841 
842  //A vector containing the intervals
843  std::vector<double> intervals;
844 
845  //The vector containing the frequency of each interval, will be used to every property type
846  std::vector< unsigned int> frequencies;
847 
848  //A map containing the intervals and their objecIds
849  std::map<double, std::vector<te::da::ObjectId*> > intervalToOIds;
850 
851  //Populating the frequencies, intervals and their respective objectIds with the results of the chosen summary function
852  buildNumericFrequencies(slices, stat, valuesToSummarize, intervals, intervalToOIds, frequencies, minValue, interval);
853 
854  //With both the intervals and frequencies ready, the map can be populated
855  for (unsigned int i= 0; i<intervals.size(); ++i)
856  {
857  te::dt::Double* data = new te::dt::Double(intervals[i]);
858  newHistogram->insert(std::make_pair(data, frequencies[i]), intervalToOIds.at(intervals[i]));
859  }
860 
861  newHistogram->setMinValue(minValue);
862  newHistogram->setInterval(interval);
863  newHistogram->setSummarized(stat != -1);
864  dataset->moveBeforeFirst();
865  }
866  }
867  return newHistogram;
868 }
869 
871 {
873 
874  std::size_t rpos = te::da::GetFirstPropertyPos(dataset, te::dt::RASTER_TYPE);
875  std::vector<std::size_t> objIdIdx;
876  te::da::GetOIDPropertyPos(dataType, objIdIdx);
877 
879  task.setMessage("Histogram creation");
880 
881  if(rpos != std::string::npos)
882  {
883  std::auto_ptr<te::rst::Raster> rstptr = dataset->getRaster(rpos);
884  std::map<double, unsigned int> values = rstptr->getBand(propId)->getHistogramR();
885 
886  for(std::map<double, unsigned int>::iterator it = values.begin(); it != values.end(); ++it)
887  {
888  task.pulse();
889  newHistogram->insert(std::make_pair(new te::dt::Double(it->first), it->second));
890  }
891  newHistogram->setMinValue(rstptr->getBand(propId)->getMinValue(true).real());
892  }
893  else
894  {
895  int propType = dataset->getPropertyDataType(propId);
896  newHistogram->setType(propType);
897 
898  //The vector containing the frequency of each interval, will be used to every property type
899  std::vector< unsigned int> frequencies;
900 
901  if(propType == te::dt::DATETIME_TYPE || propType == te::dt::STRING_TYPE)
902  {
903  std::set <std::string> intervals;
904  std::set <std::string>::iterator intervalsIt;
905  std::map<std::string, std::vector<te::da::ObjectId*> > valuesIdsByinterval;
906  std::vector<te::da::ObjectId*> valuesOIds;
907 
908  //Acquiring the name of the base dataset and how many properties are included in it's primary key
909  std::pair<std::string, int> dsProps;
910  te::da::GetOIDDatasetProps(dataType, dsProps);
911 
912  //A map containg the summarized values used to build the histogram
913  std::map<std::string, std::vector<std::pair<std::string, te::da::ObjectId*> > > valuesToSummarize;
914 
915  //Adjusting the histogram's intervals
916  dataset->moveBeforeFirst();
917  while(dataset->moveNext())
918  {
919 
920  if(dataset->isNull(propId))
921  continue;
922 
923  if(!task.isActive())
924  {
925  break;
926  }
927 
928  std::string interval = dataset->getString(propId);
929 
930  //Every unique string will be an interval
931  intervals.insert(interval);
932  task.pulse();
933  }
934 
935  for (intervalsIt = intervals.begin(); intervalsIt != intervals.end(); ++intervalsIt)
936  {
937  valuesIdsByinterval.insert(make_pair((*intervalsIt), valuesOIds));
938  }
939 
940  frequencies.resize(intervals.size(), 0);
941  dataset->moveBeforeFirst();
942  newHistogram->setStringInterval(intervals);
943 
944  //Adjusting the Histogram's values
945  while(dataset->moveNext())
946  {
947 
948  if(dataset->isNull(propId))
949  continue;
950 
951  if(!task.isActive())
952  {
953  break;
954  }
955 
956  std::string currentValue = dataset->getString(propId);
957  te::da::ObjectId* currentOid = getObjectId(dataset, objIdIdx);
958  valuesToSummarize[te::da::getBasePkey(currentOid, dsProps)].push_back(std::make_pair(currentValue, currentOid));
959 
960  task.pulse();
961  }
962 
963  buildStringFrequencies(stat, valuesToSummarize, valuesIdsByinterval, frequencies);
964 
965  //With both the intervals and values ready, the map can be populated
966  int i;
967  for (i= 0, intervalsIt = intervals.begin(); intervalsIt != intervals.end(); ++intervalsIt,++i)
968  {
969  te::dt::String* data = new te::dt::String(*intervalsIt);
970  newHistogram->insert(std::make_pair(data, frequencies[i]), valuesIdsByinterval.at(*intervalsIt));
971  }
972 
973  dataset->moveBeforeFirst();
974  }
975  }
976  newHistogram->setSummarized(stat != -1);
977  return newHistogram;
978 }
979 
981 {
983  int propType = dataset->getPropertyDataType(propId);
984 
985  if(slices <=1)
986  slices = 2;
987 
988  //Creating the histogram and it's chart with the given dataset
989  if(propType == te::dt::DATETIME_TYPE || propType == te::dt::STRING_TYPE)
990  chart = new te::qt::widgets::HistogramChart(te::qt::widgets::createHistogram(dataset, dataType, propId, stat));
991  else
992  chart = new te::qt::widgets::HistogramChart(te::qt::widgets::createHistogram(dataset, dataType, propId, slices, stat));
993 
994  //Creating and adjusting the chart Display's style.
996  chartStyle->setTitle(QString::fromStdString("Histogram"));
997  chartStyle->setAxisX(QString::fromStdString(dataset->getPropertyName(propId)));
998  chartStyle->setAxisY(QString::fromStdString("Frequency"));
999 
1000  //Creating and adjusting the chart Display
1001  te::qt::widgets::ChartDisplay* chartDisplay = new te::qt::widgets::ChartDisplay(0, QString::fromStdString("Histogram"), chartStyle);
1002  chartDisplay->adjustDisplay();
1003  chart->attach(chartDisplay);
1004 
1005  //Adjusting the chart widget
1007  displayWidget->show();
1008  displayWidget->setWindowTitle("Histogram");
1009  return displayWidget;
1010 }
1011 
1013 {
1015  chart = new te::qt::widgets::HistogramChart(histogram);
1016 
1017  //Creating and adjusting the chart Display's style.
1019  chartStyle->setTitle(QString::fromStdString("Histogram"));
1020  chartStyle->setAxisX(QString::fromStdString(dataset->getPropertyName(propId)));
1021  chartStyle->setAxisY(QString::fromStdString("Frequency"));
1022 
1023  //Creating and adjusting the chart Display
1024  te::qt::widgets::ChartDisplay* chartDisplay = new te::qt::widgets::ChartDisplay(0, QString::fromStdString("Histogram"), chartStyle);
1025  chartDisplay->adjustDisplay();
1026  chart->attach(chartDisplay);
1027 
1028  //Adjusting the chart widget
1030  displayWidget->show();
1031  displayWidget->setWindowTitle("Histogram");
1032  return displayWidget;
1033 }
1034 
1035 QwtText* te::qt::widgets::Terralib2Qwt(const std::string& text)
1036 {
1037  QwtText* result = new QwtText(text.c_str());
1038  result->setBackgroundBrush(QBrush(QColor(0, 255, 0)));
1039  result->setBorderPen(QPen(Qt::red, 3, Qt::SolidLine));
1040  return result;
1041 }
1042 
1043 QwtText* te::qt::widgets::Terralib2Qwt(const std::string& text, te::color::RGBAColor* color,
1044  te::se::Font* font, te::se::Fill* backFill,
1045  te::se::Stroke* backStroke)
1046 {
1047  QwtText* result = new QwtText(QString(text.c_str()));
1048 
1049  return result;
1050 }
1051 
1053 {
1054  //Default symbol used in case the Graphic is not completely populated.
1055  QwtSymbol* symbol = new QwtSymbol( QwtSymbol::Ellipse, QBrush( Qt::yellow ), QPen( Qt::red, 2 ), QSize( 8, 8 ));
1056 
1057  //Default size and width for the symbols
1058  size_t height = 8, width = 8;
1059 
1060  //Adjusting the size if the user changed it
1061  if(graphic->getSize())
1062  {
1063  height = te::se::GetInt(graphic->getSize());
1064  width = height;
1065  }
1066 
1067  /*Image that will be used to generate the symbol's pixmap,
1068  it can be either from a mark or from an external graphic, whichever is valid.
1069  */
1070  te::color::RGBAColor** image;
1071 
1072  if(!graphic->getMarks().empty())
1073  {
1074  image = te::map::MarkRendererManager::getInstance().render(graphic->getMarks()[0], height);
1075  }
1076  else
1077  {
1078  image = te::map::ExternalGraphicRendererManager::getInstance().render(graphic->getExternalGraphics()[0], height, width);
1079  }
1080 
1081  QImage* qimg = te::qt::widgets::GetImage(image, height, width);
1082  QPixmap pixmap;
1083  pixmap = QPixmap::fromImage(*qimg);
1084 
1085  //Adjusting the symbol
1086  symbol->setPixmap(pixmap);
1087  symbol->setSize(width, height);
1088 
1089  delete image;
1090  delete qimg;
1091 
1092  return symbol;
1093 }
1094 
1096 {
1098  task.setMessage("Histogram creation");
1099  task.setTotalSteps(dataset->getNumProperties());
1100 
1101  QwtPlotCurve *baseCurve = new QwtPlotCurve("Base Values");
1102  baseCurve->setOrientation( Qt::Horizontal );
1103 
1104  QwtPlotCurve *normalCurve = new QwtPlotCurve("Normalizeed Values");
1105  normalCurve->setOrientation( Qt::Horizontal );
1106 
1107  int propType = dataset->getPropertyDataType(propId);
1108  if(propType >= te::dt::INT16_TYPE && propType <= te::dt::NUMERIC_TYPE)
1109  {
1111  std::vector<double> xValues = te::stat::GetNumericData(dataset, dataset->getPropertyName(propId));
1112  std::vector<double> yValues;
1114 
1115  // Normalize the selected variable
1116  for(int i = 0; i < nss.m_count; ++i)
1117  {
1118  double curXValue = xValues[i];
1119  curXValue = (curXValue - nss.m_mean) / nss.m_stdDeviation;
1120  xValues[i] = curXValue;
1121  }
1122  std::sort(xValues.begin(), xValues.end());
1123 
1124  //// Fill the vector of the probability
1125  for(int i = 0; i < nss.m_count; ++i)
1126  {
1127  double curYValue = xValues[i];
1128  if (curYValue > 0.)
1129  curYValue = 0.5 + (errFunction ((float)(curYValue/std::sqrt(2.)))/2.);
1130  else
1131  {
1132  curYValue = -curYValue;
1133  curYValue = 0.5 - (errFunction ((float)(curYValue/std::sqrt(2.)))/2.);
1134  }
1135  yValues.push_back(curYValue);
1136  }
1137 
1138  QVector<QPointF> samples, normalSamples;
1139  for (int i = 0; i < nss.m_count; ++i)
1140  {
1141  double val = ((double)i+(double)1.0)/(double)nss.m_count;
1142  normalSamples += QPointF( val, val);
1143  samples += QPointF( val, yValues[i]);
1144  }
1145 
1146  baseCurve->setSamples(samples);
1147  normalCurve->setSamples(normalSamples);
1148  }
1149 
1150  QPen normalCurvePen;
1151  normalCurvePen.setColor(QColor(Qt::green));
1152  normalCurvePen.setStyle(Qt::SolidLine);
1153  normalCurvePen.setWidth(0);
1154  baseCurve->setPen(normalCurvePen);
1155 
1156  QPen normalProbCurvePen;
1157  normalProbCurvePen.setColor(QColor(Qt::red));
1158  normalProbCurvePen.setStyle(Qt::SolidLine);
1159  normalProbCurvePen.setWidth(0);
1160  normalCurve->setPen(normalProbCurvePen);
1161 
1162  //Creating and adjusting the chart Display's style.
1164  chartStyle->setTitle(QString::fromStdString("Normal Probability: " + dataset->getPropertyName(propId)));
1165  chartStyle->setAxisX( QString::fromStdString(dataset->getPropertyName(propId)));
1166  chartStyle->setAxisY(QString::fromStdString("Probability"));
1167  chartStyle->setGridChecked(true);
1168 
1169  //Creating and adjusting the chart Display
1170  te::qt::widgets::ChartDisplay* chartDisplay = new te::qt::widgets::ChartDisplay(0, QString::fromStdString("Normal Distribution"), chartStyle);
1171  chartDisplay->adjustDisplay();
1172  baseCurve->attach(chartDisplay);
1173  normalCurve->attach(chartDisplay);
1174 
1175  //Adjusting the chart widget
1176  te::qt::widgets::ChartDisplayWidget* displayWidget = new te::qt::widgets::ChartDisplayWidget(normalCurve, normalCurve->rtti(), chartDisplay);
1177  displayWidget->setWindowTitle("Normal Distribution");
1178  return displayWidget;
1179 }
TEQTWIDGETSEXPORT ChartDisplayWidget * createNormalDistribution(te::da::DataSet *dataset, int propId)
Definition: Utils.cpp:1095
TESTATEXPORT void GetNumericStatisticalSummary(std::vector< double > &values, te::stat::NumericStatisticalSummary &ss, double nullVal)
TEQTWIDGETSEXPORT Scatter * createScatter(te::da::DataSet *dataset, te::da::DataSetType *dataType, int propX, int propY, int stat, bool readall=true)
Scatter Creator.
Definition: Utils.cpp:601
Mean.
Definition: Enums.h:43
virtual std::auto_ptr< te::dt::DateTime > getDateTime(std::size_t i) const =0
Method for retrieving a date and time attribute value.
SimpleData< std::string, STRING_TYPE > String
Definition: SimpleData.h:229
virtual boost::int16_t getInt16(std::size_t i) const =0
Method for retrieving a 16-bit integer attribute value (2 bytes long).
A structure to hold the set of statistics from a set of numerical values.
void setMessage(const std::string &message)
Set the task message.
Utility functions for the data access module.
void adjustDisplay()
Updates the general display settings according to the ChartStyle. The adjusted properties are: Title;...
virtual boost::int32_t getInt32(std::size_t i) const =0
Method for retrieving a 32-bit integer attribute value (4 bytes long).
void addY(double &yValue)
It adds a new value to the vector containing the Y axis values.
Definition: Scatter.cpp:177
TEDATAACCESSEXPORT ObjectId * GenerateOID(DataSet *dataset, const std::vector< std::string > &names)
Definition: Utils.cpp:446
Skewness.
Definition: Enums.h:49
const std::vector< ExternalGraphic * > getExternalGraphics() const
Definition: Graphic.cpp:76
TEQTWIDGETSEXPORT QwtText * Terralib2Qwt(const std::string &title)
Definition: Utils.cpp:1035
TEQTWIDGETSEXPORT Histogram * createHistogram(te::da::DataSet *dataset, te::da::DataSetType *dataType, int propId, int slices, int stat)
Histogram Creator.
Definition: Utils.cpp:773
A class that models the description of a dataset.
Definition: DataSetType.h:72
void attach(QwtPlot *plot)
It atttaches a QwtPlot to this Cahrt.
void buildSummarizedScatter(int stat, std::map< std::string, std::vector< te::da::ObjectId * > > oidsToSummarize, std::map< std::string, std::vector< std::pair< double, double > > > valuesToSummarize, te::qt::widgets::Scatter *scatter)
Definition: Utils.cpp:362
virtual boost::int64_t getInt64(std::size_t i) const =0
Method for retrieving a 64-bit integer attribute value (8 bytes long).
double getDouble(const std::string &value, std::vector< std::string > &sVector)
Definition: Utils.cpp:179
unsigned int getColumn() const
Returns the current column in iterator.
void setGridChecked(bool newGridChecked)
It sets the boolean used to decided weather to display the grid or not.
Definition: ChartStyle.cpp:155
This class can be used to inform the progress of a task.
Definition: TaskProgress.h:53
virtual std::auto_ptr< te::rst::Raster > getRaster(std::size_t i) const =0
Method for retrieving a raster attribute value.
static PointSetIterator end(const te::rst::Raster *r, const std::vector< te::gm::Point * > p)
Returns an iterator referring to after the end of the iterator.
void buildStringFrequencies(int stat, std::map< std::string, std::vector< std::pair< std::string, te::da::ObjectId * > > > valuestoSummarize, std::map< std::string, std::vector< te::da::ObjectId * > > &intervalToOIds, std::vector< unsigned int > &frequencies)
Definition: Utils.cpp:518
virtual std::string getNumeric(std::size_t i) const =0
Method for retrieving a numeric attribute value.
A Graphic is a graphic symbol with an inherent shape, color(s), and possibly size.
Definition: Graphic.h:66
float gammln(float xx)
Definition: Utils.cpp:64
A class to represent a Histogram.
Definition: Histogram.h:56
TEDATAACCESSEXPORT void GetOIDDatasetProps(const DataSetType *type, std::pair< std::string, int > &dsProps)
Definition: Utils.cpp:355
void setTitle(QString newTitle)
It sets the style's title.
Definition: ChartStyle.cpp:71
bool isActive() const
Verify if the task is active.
virtual double getDouble(std::size_t i) const =0
Method for retrieving a double attribute value.
This class implements the strategy to iterate with spatial restriction, the iteration occurs inside a...
A class to represent time instant.
Definition: TimeInstant.h:55
void setTotalSteps(int value)
Set the task total stepes.
TESTATEXPORT std::vector< double > GetNumericData(te::da::DataSet *dataSet, const std::string propName)
Returns the values of a numeric type property in a vector of values.
Definition: Utils.cpp:158
Minimum value.
Definition: Enums.h:41
A class to represent a histogram.
void setStringInterval(std::set< std::string > new_Interval)
It sets the histogram's string set of intervals.
Definition: Histogram.cpp:119
TEQTWIDGETSEXPORT ChartDisplayWidget * createScatterDisplay(te::da::DataSet *dataset, te::da::DataSetType *dataType, int propX, int propY, int stat=-1)
Scatter Creator.
Definition: Utils.cpp:750
virtual bool moveNext()=0
It moves the internal pointer to the next item of the collection.
void getObjectIds(te::da::DataSet *dataset, std::vector< std::size_t > pkeys, std::vector< te::da::ObjectId * > &valuesOIDs)
Definition: Utils.cpp:595
float errFunction(float x)
Definition: Utils.cpp:174
A class to represent a scatter.
Definition: Scatter.h:51
static MarkRendererManager & getInstance()
It returns a reference to the singleton instance.
virtual float getFloat(std::size_t i) const =0
Method for retrieving a float attribute value.
float gammp(float a, float x)
Definition: Utils.cpp:158
A base class for date data types.
Definition: Date.h:53
Median.
Definition: Enums.h:52
virtual std::string getPropertyName(std::size_t i) const =0
It returns the property name at position pos.
void setAxisY(QString newAxisY)
It sets the style's y axis label.
Definition: ChartStyle.cpp:101
virtual bool isNull(std::size_t i) const =0
It checks if the attribute value is NULL.
This class represents an unique id for a data set element.
Definition: ObjectId.h:47
void addX(double &xValue)
It adds a new value to the vector containing the X axis values.
Definition: Scatter.cpp:172
void setSummarized(bool summarized)
It sets the property that holds whether the histogram has been created from summarized values or not...
Definition: Histogram.cpp:56
Kurtosis.
Definition: Enums.h:50
A Font specifies the text font to use in a text symbolizer.
Definition: Font.h:63
TEQTWIDGETSEXPORT ChartDisplayWidget * createHistogramDisplay(te::da::DataSet *dataset, te::da::DataSetType *dataType, int propId, int slices=10, int stat=-1)
Histogram Creator.
Definition: Utils.cpp:980
void gcf(float *gammcf, float a, float x, float *gln)
Definition: Utils.cpp:122
Standard deviation.
Definition: Enums.h:47
A class to represent a chart display.
Definition: ChartDisplay.h:65
Sum of values.
Definition: Enums.h:44
void setAxisX(QString newAxisX)
It sets the style's x axis label.
Definition: ChartStyle.cpp:91
A class to represent a histogram chart.
void pulse()
Calls setCurrentStep() function using getCurrentStep() + 1.
A Fill specifies the pattern for filling an area geometry.
Definition: Fill.h:59
void setInterval(double new_Interval)
It sets the histogram's interval.
Definition: Histogram.cpp:109
A class to represent a scatter chart.
Definition: ScatterChart.h:55
virtual std::size_t getNumProperties() const =0
It returns the number of properties that composes an item of the dataset.
TESTATEXPORT void GetStringStatisticalSummary(std::vector< std::string > &values, te::stat::StringStatisticalSummary &ss)
A class to represent a scatter's chart.
A class to represent a scatter.
Coefficient variation.
Definition: Enums.h:53
A dataset is the unit of information manipulated by the data access module of TerraLib.
Definition: DataSet.h:112
A wdiget used to display a chart.
virtual DateTimeType getDateTimeType() const =0
It returns the subtype of the date and time type.
const std::vector< Mark * > getMarks() const
Definition: Graphic.cpp:98
TEDATAACCESSEXPORT void GetOIDPropertyPos(const DataSetType *type, std::vector< std::size_t > &ppos)
Definition: Utils.cpp:401
TEQTWIDGETSEXPORT QImage * GetImage(te::color::RGBAColor **img, int width, int height)
It creates a QImage from an RGBA color array.
Definition: Utils.cpp:69
A Stroke specifies the appearance of a linear geometry.
Definition: Stroke.h:67
A structure to hold the set of statistics from a set of categorical (sample) values.
virtual bool moveBeforeFirst()=0
It moves the internal pointer to a position before the first item in the collection.
void gser(float *gamser, float a, float x, float *gln)
Definition: Utils.cpp:84
SimpleData< double, DOUBLE_TYPE > Double
Definition: SimpleData.h:227
void setMinValue(double new_minValue)
It sets the histogram's minimum value.
Definition: Histogram.cpp:99
A helper class for 32-bit RGBA (Red-Green-Blue-Alpha channel) color.
Definition: RGBAColor.h:57
TESEEXPORT int GetInt(const te::se::ParameterValue *param)
It gets the parameter value as an integer.
Definition: Utils.cpp:443
void calculateMinMaxValues()
Calculates the minimum and maximum values for both the X and Y axis.
Definition: Scatter.cpp:59
TEDATAACCESSEXPORT std::string getBasePkey(te::da::ObjectId *oid, std::pair< std::string, int > &dsProps)
Definition: Utils.cpp:388
A widget used to display a set of charts.
TERASTEREXPORT std::vector< te::gm::Point * > GetRandomPointsInRaster(const te::rst::Raster &inputRaster, unsigned int numberOfPoints=1000)
Creates a vector of random positions (points) inside the raster.
Definition: Utils.cpp:485
void insert(std::pair< te::dt::AbstractData *, unsigned int > new_value, std::vector< te::da::ObjectId * > valuesOIds)
It adds a new value to the map containing the histogram values.
Definition: Histogram.cpp:124
A class used to define a chartDisplay's style.
virtual std::string getString(std::size_t i) const =0
Method for retrieving a string value attribute.
TEDATAACCESSEXPORT std::size_t GetFirstPropertyPos(const te::da::DataSet *dataset, int datatype)
Definition: Utils.cpp:481
A template for atomic data types (integers, floats, strings and others).
Definition: SimpleData.h:59
std::string getStatisticalValue(int stat, te::stat::StringStatisticalSummary &sss)
Definition: Utils.cpp:267
te::da::ObjectId * getObjectId(te::da::DataSet *dataset, std::vector< std::size_t > pkeys)
Definition: Utils.cpp:582
void buildNumericFrequencies(int slices, int stat, std::map< std::string, std::vector< std::pair< double, te::da::ObjectId * > > > valuestoSummarize, std::vector< double > &intervals, std::map< double, std::vector< te::da::ObjectId * > > &intervalToOIds, std::vector< unsigned int > &frequencies, double &minValue, double &interval)
Definition: Utils.cpp:426
virtual int getPropertyDataType(std::size_t i) const =0
It returns the underlying data type of the property at position pos.
void addData(double &xValue, double &yValue, te::da::ObjectId *oid)
It adds the x and Y axis values to the scatter's vectors and the associeted objectId to the scatter's...
Definition: Scatter.cpp:182
A class to represent a chart display.
Variance.
Definition: Enums.h:48
Maximum value.
Definition: Enums.h:42
const ParameterValue * getSize() const
Definition: Graphic.cpp:120
unsigned int getRow() const
Returns the current row in iterator.
void setType(int new_type)
It sets the histogram's type.
Definition: Histogram.cpp:46
static PointSetIterator begin(const te::rst::Raster *r, const std::vector< te::gm::Point * > p)
Returns an iterator referring to the first value of the band.
Amplitude.
Definition: Enums.h:51