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;
369 
370  //Acquiring the summarized values
371  for(valuesIt = valuesToSummarize.begin(); valuesIt != valuesToSummarize.end(); ++valuesIt)
372  {
375  if((*valuesIt).second.size() > 1 && (stat != -1))
376  {
377  std::vector<double> xValues;
378  std::vector<double> yValues;
379  std::vector<te::da::ObjectId*> oids;
380 
381  for(size_t i = 0; i < (*valuesIt).second.size(); ++i)
382  {
383  xValues.push_back((*valuesIt).second[i].first);
384  yValues.push_back((*valuesIt).second[i].second);
385  oids = oidsToSummarize[(*valuesIt).first];
386  }
387 
388  double summarizedXValue, summarizedYValue;
389 
391  summarizedXValue = getStatisticalValue(stat, ssx);
392 
394  summarizedYValue = getStatisticalValue(stat, ssy);
395 
396  for(size_t j = 0; j < oids.size(); ++j)
397  scatter->addData(summarizedXValue, summarizedYValue, oids[j]);
398  }
399  else
400  {
401  //A summary was requested, but it was not needed due to the fact the there is only one value for each base oid
402 
403  double xValue = (*valuesIt).second[0].first;
404  double yValue = (*valuesIt).second[0].second;
405 
406  std::vector<te::da::ObjectId*> oids;
407  oids = oidsToSummarize[(*valuesIt).first];
408 
409  scatter->addData(xValue, yValue, oids[0]);
410  }
411  }
412 }
413 
414 /*
415  Auxiliary function used to populate the frequencies, interval and their respective objectIds based on a statistical function
416 
417  param slices The number of slices for the histogram, used to calculate the number of intervals;
418  param stat The selected satistical function, pass -1 if no function is to be used;
419  param valuestoSummarize a map containing all the values and their objectIds mapped by the oid of the base dataset,
420  defaults to a one-to-one relationship between value and objectId unless the histogram is based on a linked layer;
421  param intervals Output parameter, the vector containing the intervals.
422  param intervalToOIds Output parameter, the map that associates every interval to their objectIds.
423  param frequencies Output parameter, the vector containing the frequencies.
424  param minValue Output parameter, the minimum value of the histogram.
425  param interval Output parameter, the interval of the histogram.
426 */
427 void buildNumericFrequencies(int slices, int stat, std::map<std::string, std::vector<std::pair<double, te::da::ObjectId*> > > valuestoSummarize,
428  std::vector<double>& intervals, std::map<double, std::vector<te::da::ObjectId*> >& intervalToOIds,
429  std::vector< unsigned int>& frequencies, double& minValue, double& interval)
430 {
431  //Containers used to hold informations temporarily, used to organize them prior to inserting them on the histogram.
432  std::map<std::string, std::vector<std::pair<double, te::da::ObjectId*> > >::iterator valuesIt;
433  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  {
439  if((*valuesIt).second.size() > 1 && stat != -1)
440  {
441  std::vector<double> values;
442  std::vector<te::da::ObjectId*> oids;
443  for(size_t i = 0; i < (*valuesIt).second.size(); ++i)
444  {
445  values.push_back((*valuesIt).second[i].first);
446  oids.push_back((*valuesIt).second[i].second);
447  }
448 
449  double summarizedValue;
451  summarizedValue = getStatisticalValue(stat, ss);
452  summarizedValuesToOId.push_back(std::make_pair(summarizedValue, oids));
453  }
454  else
455  {
456  for(size_t i = 0; i < (*valuesIt).second.size(); ++i)
457  {
458  std::vector<te::da::ObjectId*> oids;
459  oids.push_back((*valuesIt).second[i].second);
460  summarizedValuesToOId.push_back(std::make_pair((*valuesIt).second[i].first, oids));
461  }
462  }
463  }
464 
465  double maxValue = -std::numeric_limits<double>::max();
466 
467  for(size_t i = 0; i < summarizedValuesToOId.size(); ++i)
468  {
469  double currentValue = summarizedValuesToOId[i].first;
470 
471  //calculate range
472  if(minValue > currentValue)
473  minValue = currentValue;
474  if(maxValue < currentValue)
475  maxValue = currentValue;
476  }
477 
478  //Adjusting the interval to the user-defined number of slices.
479  interval = ((maxValue * 1.000001 - minValue) / slices);
480 
481  //Adjusting the histogram's intervals
482  for (double i = minValue; i <(maxValue+interval); i+=interval)
483  {
484  intervals.push_back(i);
485  std::vector<te::da::ObjectId*> valuesOIds;
486  intervalToOIds.insert(std::make_pair(i, valuesOIds));
487  }
488 
489  frequencies.resize(intervals.size(), 0);
490 
491  //Adjusting the frequencies on each interval
492  for(size_t i = 0; i < summarizedValuesToOId.size(); ++i)
493  {
494  double currentValue = summarizedValuesToOId[i].first;
495  for (size_t j = 0; j<intervals.size(); ++j)
496  {
497  if((currentValue >= intervals[j]) && (currentValue <= intervals[j+1]))
498  {
499  for(size_t k= 0; k < summarizedValuesToOId[i].second.size(); ++k)
500  intervalToOIds.at(intervals[j]).push_back(summarizedValuesToOId[i].second[k]);
501 
502  ++frequencies[j];
503  break;
504  }
505  }
506  }
507 }
508 
509 /*
510  Auxiliary function used to populate the frequencies, interval and their respective objectIds based on a statistical function
511 
512  param stat The selected satistical function, pass -1 if no function is to be used;
513  param valuestoSummarize a map containing all the values and their objectIds mapped by the oid of the base dataset,
514  defaults to a one-to-one relationship between value and objectId unless the histogram is based on a linked layer;
515  param intervalToOIds Output parameter, the map that associates every interval to their objectIds.
516  param frequencies Output parameter, the vector containing the frequencies.
517 
518 */
519 void buildStringFrequencies(int stat, std::map<std::string, std::vector<std::pair<std::string, te::da::ObjectId*> > > valuestoSummarize,
520  std::map<std::string, std::vector<te::da::ObjectId*> >& intervalToOIds,
521  std::vector< unsigned int>& frequencies)
522 {
523  //Containers and iterators used to hold informations temporarily, used to organize them prior to inserting them on the histogram.
524  std::map<std::string, std::vector<std::pair<std::string, te::da::ObjectId*> > >::iterator valuesIt;
525  std::map<std::string, std::vector<te::da::ObjectId*> >::iterator intervalsIt;
526  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  {
532  if((*valuesIt).second.size() > 1 && (stat != -1))
533  {
534  std::vector<std::string> values;
535  std::vector<te::da::ObjectId*> oids;
536  for(size_t i = 0; i < (*valuesIt).second.size(); ++i)
537  {
538  values.push_back((*valuesIt).second[i].first);
539  oids.push_back((*valuesIt).second[i].second);
540  }
541 
542  std::string summarizedValue;
544  summarizedValue = getStatisticalValue(stat, ss);
545  summarizedValuesToOId.push_back(std::make_pair(summarizedValue, oids));
546  }
547  else
548  {
549  for(size_t i = 0; i < (*valuesIt).second.size(); ++i)
550  {
551  std::vector<te::da::ObjectId*> oids;
552  oids.push_back((*valuesIt).second[i].second);
553  summarizedValuesToOId.push_back(std::make_pair((*valuesIt).second[i].first, oids));
554  }
555  }
556  }
557 
558  //Adjusting the frequencies on each interval
559  for(size_t i = 0; i < summarizedValuesToOId.size(); ++i)
560  {
561  int j;
562  std::string currentValue = summarizedValuesToOId[i].first;
563  for ( j= 0, intervalsIt = intervalToOIds.begin(); intervalsIt != intervalToOIds.end(); ++intervalsIt,++j)
564  {
565  if(currentValue == (*intervalsIt).first)
566  {
567  for(size_t k= 0; k < summarizedValuesToOId[i].second.size(); ++k)
568  intervalToOIds.at(currentValue).push_back(summarizedValuesToOId[i].second[k]);
569 
570  frequencies[j] = frequencies[j]++;
571  break;
572  }
573  }
574  }
575 }
576 
577 /*
578  Auxiliary function used to acquire the current objectId of the dataset
579 
580  param dataset The dataset being used, must be given at the position of interest;
581  param pkeys A vector containing all the properties that form the primaryKey of the given dataset
582 */
583 te::da::ObjectId* getObjectId(te::da::DataSet* dataset, std::vector<std::size_t> pkeys)
584 {
585  std::vector<size_t>::iterator it;
586  std::vector<std::string> propNames;
587 
588  for(it=pkeys.begin(); it!=pkeys.end(); ++it)
589  propNames.push_back(dataset->getPropertyName(*it));
590 
591  //The caller will take ownership of the generated pointer.
592  te::da::ObjectId* oid = te::da::GenerateOID(dataset, propNames);
593  return oid;
594 }
595 
596 void getObjectIds (te::da::DataSet* dataset, std::vector<std::size_t> pkeys, std::vector<te::da::ObjectId*>& valuesOIDs)
597 {
598  te::da::ObjectId* oid = getObjectId(dataset,pkeys);
599  valuesOIDs.push_back(oid);
600 }
601 
602 te::qt::widgets::Scatter* te::qt::widgets::createScatter(te::da::DataSet* dataset, te::da::DataSetType* dataType, int propX, int propY, int stat, bool readall)
603 {
605 
606  std::vector<std::size_t> objIdIdx;
607  te::da::GetOIDPropertyPos(dataType, objIdIdx);
608 
609  std::map<double, std::vector<te::da::ObjectId*> > valuesIdsByinterval;
610  std::vector<te::da::ObjectId*> valuesOIds;
611 
612  std::size_t rpos = te::da::GetFirstPropertyPos(dataset, te::dt::RASTER_TYPE);
613  if(rpos != std::string::npos)
614  {
615  std::auto_ptr<te::rst::Raster> raster(dataset->getRaster(rpos));
616  double xDummyValue = raster->getBand(propX)->getProperty()->m_noDataValue;
617  double yDummyValue = raster->getBand(propY)->getProperty()->m_noDataValue;
618 
619  unsigned int nCol = raster->getNumberOfColumns();
620  unsigned int nLin = raster->getNumberOfRows();
621 
623  task.setTotalSteps(nCol);
624  task.setMessage("Scatter creation");
625 
626  if (!readall)
627  {
628  unsigned int maxInputPoints = (nCol * nLin) * 0.10;
629  std::vector<te::gm::Point*> randomPoints = te::rst::GetRandomPointsInRaster(*raster, maxInputPoints);
632 
633  while (pit != pitend)
634  {
635  if(!task.isActive())
636  {
637  break;
638  }
639  double val1, val2;
640 
641  raster->getValue(pit.getColumn(), pit.getRow(), val1, propX);
642  raster->getValue(pit.getColumn(), pit.getRow(), val2, propY);
643 
644  if ((val1 == xDummyValue) || (val2 == yDummyValue))
645  {
646  ++pit;
647  task.pulse();
648  continue;
649  }
650 
651  newScatter->addX(val1);
652  newScatter->addY(val2);
653  ++pit;
654  task.pulse();
655  }
656  }
657  else
658  {
659  for (unsigned int c=0; c < nCol; ++c)
660  {
661  if(!task.isActive())
662  {
663  break;
664  }
665  for (unsigned int r=0; r <nLin; ++r)
666  {
667  double val1, val2;
668  raster->getValue(c, r, val1, propX);
669  raster->getValue(c, r, val2, propY);
670 
671  if ((val1 == xDummyValue) || (val2 == yDummyValue))
672  continue;
673 
674  newScatter->addX(val1);
675  newScatter->addY(val2);
676  }
677 
678  task.pulse();
679  }
680  }
681  }
682  else
683  {
684  int xType = dataset->getPropertyDataType(propX);
685  int yType = dataset->getPropertyDataType(propY);
686 
687  //Acquiring the name of the base dataset and how many properties are included in it's primary key
688  std::pair<std::string, int> dsProps;
689  te::da::GetOIDDatasetProps(dataType, dsProps);
690 
691  //A map containg the summarized values used to buil d the histogram
692  std::map<std::string, std::vector<te::da::ObjectId*> > oidsToSummarize;
693  std::map<std::string, std::vector<std::pair<double, double> > > valuesToSummarize;
694 
696  task.setTotalSteps((int)dataset->getNumProperties());
697  task.setMessage("Scatter creation");
698 
699  while(dataset->moveNext())
700  {
701 
702  if(!task.isActive())
703  {
704  break;
705  }
706 
707  double x_doubleValue = 0.;
708  double y_doubleValue = 0.;
709 
710  if(xType >= te::dt::INT16_TYPE && xType <= te::dt::NUMERIC_TYPE)
711  {
712  if(dataset->isNull(propX))
713  continue;
714 
715  x_doubleValue = getDouble(dataset, propX);
716  }
717  else if(xType == te::dt::DATETIME_TYPE)
718  {
719  if(dataset->isNull(propX))
720  continue;
721 
722  std::auto_ptr<te::dt::DateTime> dateTime = dataset->getDateTime(propX);
723  x_doubleValue = getDouble(dateTime.release());
724  }
725 
726  //======treat the Y value
727  if(yType >= te::dt::INT16_TYPE && yType <= te::dt::NUMERIC_TYPE)
728  {
729  if(dataset->isNull(propY))
730  continue;
731  y_doubleValue = getDouble(dataset, propY);
732  }
733  else if(yType == te::dt::DATETIME_TYPE)
734  {
735  if(dataset->isNull(propY))
736  continue;
737 
738  std::auto_ptr<te::dt::DateTime> dateTime = dataset->getDateTime(propY);
739  y_doubleValue = getDouble(dateTime.release());
740  }
741 
742  //insert values into the vectors
743  te::da::ObjectId* currentOid = getObjectId(dataset, objIdIdx);
744 
745  if(stat == -1)
746  {
747  newScatter->addData(x_doubleValue, y_doubleValue, currentOid);
748  }
749  else
750  {
751  oidsToSummarize[te::da::getBasePkey(currentOid, dsProps)].push_back(currentOid);
752  valuesToSummarize[te::da::getBasePkey(currentOid, dsProps)].push_back(std::make_pair(x_doubleValue, y_doubleValue));
753  }
754  task.pulse();
755  } //end of the data set
756  if(stat != -1)
757  buildSummarizedScatter(stat, oidsToSummarize, valuesToSummarize, newScatter);
758  }
759  newScatter->calculateMinMaxValues();
760  return newScatter;
761 }
762 
764 {
765  //Creating the scatter and it's chart with the given dataset
766  te::qt::widgets::ScatterChart* chart = new te::qt::widgets::ScatterChart(te::qt::widgets::createScatter(dataset, dataType, propX, propY, stat));
767 
768  //Creating and adjusting the chart Display's style.
770  chartStyle->setTitle(QString::fromStdString("Scatter"));
771  chartStyle->setAxisX(QString::fromStdString(dataset->getPropertyName(propX)));
772  chartStyle->setAxisY(QString::fromStdString(dataset->getPropertyName(propY)));
773 
774  //Creating and adjusting the chart Display
775  te::qt::widgets::ChartDisplay* chartDisplay = new te::qt::widgets::ChartDisplay(0, QString::fromStdString("Scatter"), chartStyle);
776  chartDisplay->adjustDisplay();
777  chart->attach(chartDisplay);
778 
779  //Adjusting the chart widget
781  displayWidget->show();
782  displayWidget->setWindowTitle("Scatter");
783  return displayWidget;
784 }
785 
787 {
789 
790  std::size_t rpos = te::da::GetFirstPropertyPos(dataset, te::dt::RASTER_TYPE);
791  std::vector<std::size_t> objIdIdx;
792  te::da::GetOIDPropertyPos(dataType, objIdIdx);
793 
794  if(rpos != std::string::npos)
795  {
796  std::auto_ptr<te::rst::Raster> rstptr = dataset->getRaster(rpos);
797  std::map<double, unsigned int> values = rstptr->getBand(propId)->getHistogramR(0, 0, 0, 0, slices);
798 
801 
802  const std::complex<double>* cmin = rsMin->at(0).m_minVal;
803  const std::complex<double>* cmax = rsMax->at(0).m_maxVal;
804 
805  double min = cmin->real();
806  double max = cmax->real();
807 
808  for(std::map<double, unsigned int>::iterator it = values.begin(); it != values.end(); ++it)
809  {
810  newHistogram->insert(std::make_pair(new te::dt::Double(it->first), it->second));
811  }
812 
813  newHistogram->setMinValue(rstptr->getBand(propId)->getMinValue(true).real());
814  if (slices != 0)
815  newHistogram->setInterval((max * 1.000001 - min) / slices);
816  newHistogram->setSummarized(false);
817  }
818  else
819  {
820 
821  if(slices <=1)
822  slices = 2;
823 
824  int propType = dataset->getPropertyDataType(propId);
825  newHistogram->setType(propType);
826 
827  if((propType >= te::dt::INT16_TYPE && propType <= te::dt::UINT64_TYPE) ||
828  (propType >= te::dt::FLOAT_TYPE && propType <= te::dt::NUMERIC_TYPE))
829  {
830  //Acquiring the name of the base dataset and how many of it's properties are included in it's primary key
831  std::pair<std::string, int> dsProps;
832  te::da::GetOIDDatasetProps(dataType, dsProps);
833 
834  //A map containg the summarized values used to buil d the histogram
835  std::map<std::string, std::vector<std::pair<double, te::da::ObjectId*> > > valuesToSummarize;
836 
838  task.setMessage("Histogram creation");
839  task.setTotalSteps(((int)dataset->getNumProperties()) * 2);
840 
841  dataset->moveBeforeFirst();
842 
843  //Adjusting the Histogram's values
844  while(dataset->moveNext())
845  {
846 
847  if(dataset->isNull(propId))
848  continue;
849 
850  if(!task.isActive())
851  {
852  break;
853  }
854 
855  double currentValue = getDouble(dataset, propId);
856  te::da::ObjectId* currentOid = getObjectId(dataset, objIdIdx);
857  valuesToSummarize[te::da::getBasePkey(currentOid, dsProps)].push_back(std::make_pair(currentValue, currentOid));
858 
859  task.pulse();
860  }
861 
862  //The minimum value
863  double minValue = std::numeric_limits<double>::max();
864 
865  //The interval
866  double interval = std::numeric_limits<double>::max();
867 
868  //A vector containing the intervals
869  std::vector<double> intervals;
870 
871  //The vector containing the frequency of each interval, will be used to every property type
872  std::vector< unsigned int> frequencies;
873 
874  //A map containing the intervals and their objecIds
875  std::map<double, std::vector<te::da::ObjectId*> > intervalToOIds;
876 
877  //Populating the frequencies, intervals and their respective objectIds with the results of the chosen summary function
878  buildNumericFrequencies(slices, stat, valuesToSummarize, intervals, intervalToOIds, frequencies, minValue, interval);
879 
880  //With both the intervals and frequencies ready, the map can be populated
881  for (unsigned int i= 0; i<intervals.size(); ++i)
882  {
883  te::dt::Double* data = new te::dt::Double(intervals[i]);
884  newHistogram->insert(std::make_pair(data, frequencies[i]), intervalToOIds.at(intervals[i]));
885  }
886 
887  newHistogram->setMinValue(minValue);
888  newHistogram->setInterval(interval);
889  newHistogram->setSummarized(stat != -1);
890  dataset->moveBeforeFirst();
891  }
892  }
893  return newHistogram;
894 }
895 
897 {
899 
900  std::size_t rpos = te::da::GetFirstPropertyPos(dataset, te::dt::RASTER_TYPE);
901  std::vector<std::size_t> objIdIdx;
902  te::da::GetOIDPropertyPos(dataType, objIdIdx);
903 
905  task.setMessage("Histogram creation");
906 
907  if(rpos != std::string::npos)
908  {
909  std::auto_ptr<te::rst::Raster> rstptr = dataset->getRaster(rpos);
910  std::map<double, unsigned int> values = rstptr->getBand(propId)->getHistogramR();
911 
912  for(std::map<double, unsigned int>::iterator it = values.begin(); it != values.end(); ++it)
913  {
914  task.pulse();
915  newHistogram->insert(std::make_pair(new te::dt::Double(it->first), it->second));
916  }
917  newHistogram->setMinValue(rstptr->getBand(propId)->getMinValue(true).real());
918  newHistogram->setSummarized(false);
919  }
920  else
921  {
922  int propType = dataset->getPropertyDataType(propId);
923  newHistogram->setType(propType);
924 
925  //The vector containing the frequency of each interval, will be used to every property type
926  std::vector< unsigned int> frequencies;
927 
928  if(propType == te::dt::DATETIME_TYPE || propType == te::dt::STRING_TYPE)
929  {
930  std::set <std::string> intervals;
931  std::set <std::string>::iterator intervalsIt;
932  std::map<std::string, std::vector<te::da::ObjectId*> > valuesIdsByinterval;
933  std::vector<te::da::ObjectId*> valuesOIds;
934 
935  //Acquiring the name of the base dataset and how many properties are included in it's primary key
936  std::pair<std::string, int> dsProps;
937  te::da::GetOIDDatasetProps(dataType, dsProps);
938 
939  //A map containg the summarized values used to build the histogram
940  std::map<std::string, std::vector<std::pair<std::string, te::da::ObjectId*> > > valuesToSummarize;
941 
942  //Adjusting the histogram's intervals
943  dataset->moveBeforeFirst();
944  while(dataset->moveNext())
945  {
946 
947  if(dataset->isNull(propId))
948  continue;
949 
950  if(!task.isActive())
951  {
952  break;
953  }
954 
955  std::string interval = dataset->getString(propId);
956 
957  //Every unique string will be an interval
958  intervals.insert(interval);
959  task.pulse();
960  }
961 
962  for (intervalsIt = intervals.begin(); intervalsIt != intervals.end(); ++intervalsIt)
963  {
964  valuesIdsByinterval.insert(make_pair((*intervalsIt), valuesOIds));
965  }
966 
967  frequencies.resize(intervals.size(), 0);
968  dataset->moveBeforeFirst();
969  newHistogram->setStringInterval(intervals);
970 
971  //Adjusting the Histogram's values
972  while(dataset->moveNext())
973  {
974 
975  if(dataset->isNull(propId))
976  continue;
977 
978  if(!task.isActive())
979  {
980  break;
981  }
982 
983  std::string currentValue = dataset->getString(propId);
984  te::da::ObjectId* currentOid = getObjectId(dataset, objIdIdx);
985  valuesToSummarize[te::da::getBasePkey(currentOid, dsProps)].push_back(std::make_pair(currentValue, currentOid));
986 
987  task.pulse();
988  }
989 
990  buildStringFrequencies(stat, valuesToSummarize, valuesIdsByinterval, frequencies);
991 
992  //With both the intervals and values ready, the map can be populated
993  int i;
994  for (i= 0, intervalsIt = intervals.begin(); intervalsIt != intervals.end(); ++intervalsIt,++i)
995  {
996  te::dt::String* data = new te::dt::String(*intervalsIt);
997  newHistogram->insert(std::make_pair(data, frequencies[i]), valuesIdsByinterval.at(*intervalsIt));
998  }
999 
1000  dataset->moveBeforeFirst();
1001  }
1002  }
1003  newHistogram->setSummarized(stat != -1);
1004  return newHistogram;
1005 }
1006 
1008 {
1010  int propType = dataset->getPropertyDataType(propId);
1011 
1012  if(slices <=1)
1013  slices = 2;
1014 
1015  //Creating the histogram and it's chart with the given dataset
1016  if(propType == te::dt::DATETIME_TYPE || propType == te::dt::STRING_TYPE)
1017  chart = new te::qt::widgets::HistogramChart(te::qt::widgets::createHistogram(dataset, dataType, propId, stat));
1018  else
1019  chart = new te::qt::widgets::HistogramChart(te::qt::widgets::createHistogram(dataset, dataType, propId, slices, stat));
1020 
1021  //Creating and adjusting the chart Display's style.
1023  chartStyle->setTitle(QString::fromStdString("Histogram"));
1024  chartStyle->setAxisX(QString::fromStdString(dataset->getPropertyName(propId)));
1025  chartStyle->setAxisY(QString::fromStdString("Frequency"));
1026 
1027  //Creating and adjusting the chart Display
1028  te::qt::widgets::ChartDisplay* chartDisplay = new te::qt::widgets::ChartDisplay(0, QString::fromStdString("Histogram"), chartStyle);
1029  chartDisplay->adjustDisplay();
1030  chart->attach(chartDisplay);
1031 
1032  //Adjusting the chart widget
1034  displayWidget->show();
1035  displayWidget->setWindowTitle("Histogram");
1036  return displayWidget;
1037 }
1038 
1040 {
1042  chart = new te::qt::widgets::HistogramChart(histogram);
1043 
1044  //Creating and adjusting the chart Display's style.
1046  chartStyle->setTitle(QString::fromStdString("Histogram"));
1047  chartStyle->setAxisX(QString::fromStdString(summary + ": " + dataset->getPropertyName(propId)));
1048  chartStyle->setAxisY(QString::fromStdString("Frequency"));
1049 
1050  //Creating and adjusting the chart Display
1051  te::qt::widgets::ChartDisplay* chartDisplay = new te::qt::widgets::ChartDisplay(0, QString::fromStdString("Histogram"), chartStyle);
1052  chartDisplay->adjustDisplay();
1053  chart->attach(chartDisplay);
1054 
1055  //Adjusting the chart widget
1057  displayWidget->show();
1058  displayWidget->setWindowTitle("Histogram");
1059  return displayWidget;
1060 }
1061 
1062 QwtText* te::qt::widgets::Terralib2Qwt(const std::string& text)
1063 {
1064  QwtText* result = new QwtText(text.c_str());
1065  result->setBackgroundBrush(QBrush(QColor(0, 255, 0)));
1066  result->setBorderPen(QPen(Qt::red, 3, Qt::SolidLine));
1067  return result;
1068 }
1069 
1070 QwtText* te::qt::widgets::Terralib2Qwt(const std::string& text, te::color::RGBAColor* color,
1071  te::se::Font* font, te::se::Fill* backFill,
1072  te::se::Stroke* backStroke)
1073 {
1074  QwtText* result = new QwtText(QString(text.c_str()));
1075 
1076  return result;
1077 }
1078 
1080 {
1081  //Default symbol used in case the Graphic is not completely populated.
1082  QwtSymbol* symbol = new QwtSymbol( QwtSymbol::Ellipse, QBrush( Qt::yellow ), QPen( Qt::red, 2 ), QSize( 8, 8 ));
1083 
1084  //Default size and width for the symbols
1085  size_t height = 8, width = 8;
1086 
1087  //Adjusting the size if the user changed it
1088  if(graphic->getSize())
1089  {
1090  height = te::se::GetInt(graphic->getSize());
1091  width = height;
1092  }
1093 
1094  /*Image that will be used to generate the symbol's pixmap,
1095  it can be either from a mark or from an external graphic, whichever is valid.
1096  */
1097  te::color::RGBAColor** image;
1098 
1099  if(!graphic->getMarks().empty())
1100  {
1101  image = te::map::MarkRendererManager::getInstance().render(graphic->getMarks()[0], height);
1102  }
1103  else
1104  {
1105  image = te::map::ExternalGraphicRendererManager::getInstance().render(graphic->getExternalGraphics()[0], height, width);
1106  }
1107 
1108  QImage* qimg = te::qt::widgets::GetImage(image, (int)height, (int)width);
1109  QPixmap pixmap;
1110  pixmap = QPixmap::fromImage(*qimg);
1111 
1112  //Adjusting the symbol
1113  symbol->setPixmap(pixmap);
1114  symbol->setSize((int)width, (int)height);
1115 
1116  delete image;
1117  delete qimg;
1118 
1119  return symbol;
1120 }
1121 
1123 {
1125  task.setMessage("Histogram creation");
1126  task.setTotalSteps((int)dataset->getNumProperties());
1127 
1128  QwtPlotCurve *baseCurve = new QwtPlotCurve("Base Values");
1129  baseCurve->setOrientation( Qt::Horizontal );
1130 
1131  QwtPlotCurve *normalCurve = new QwtPlotCurve("Normalizeed Values");
1132  normalCurve->setOrientation( Qt::Horizontal );
1133 
1134  int propType = dataset->getPropertyDataType(propId);
1135  if(propType >= te::dt::INT16_TYPE && propType <= te::dt::NUMERIC_TYPE)
1136  {
1138  std::vector<double> xValues = te::stat::GetNumericData(dataset, dataset->getPropertyName(propId));
1139  std::vector<double> yValues;
1141 
1142  // Normalize the selected variable
1143  for(int i = 0; i < nss.m_count; ++i)
1144  {
1145  double curXValue = xValues[i];
1146  curXValue = (curXValue - nss.m_mean) / nss.m_stdDeviation;
1147  xValues[i] = curXValue;
1148  }
1149  std::sort(xValues.begin(), xValues.end());
1150 
1151  //// Fill the vector of the probability
1152  for(int i = 0; i < nss.m_count; ++i)
1153  {
1154  double curYValue = xValues[i];
1155  if (curYValue > 0.)
1156  curYValue = 0.5 + (errFunction ((float)(curYValue/std::sqrt(2.)))/2.);
1157  else
1158  {
1159  curYValue = -curYValue;
1160  curYValue = 0.5 - (errFunction ((float)(curYValue/std::sqrt(2.)))/2.);
1161  }
1162  yValues.push_back(curYValue);
1163  }
1164 
1165  QVector<QPointF> samples, normalSamples;
1166  for (int i = 0; i < nss.m_count; ++i)
1167  {
1168  double val = ((double)i+(double)1.0)/(double)nss.m_count;
1169  normalSamples += QPointF( val, val);
1170  samples += QPointF( val, yValues[i]);
1171  }
1172 
1173  baseCurve->setSamples(samples);
1174  normalCurve->setSamples(normalSamples);
1175  }
1176 
1177  QPen normalCurvePen;
1178  normalCurvePen.setColor(QColor(Qt::green));
1179  normalCurvePen.setStyle(Qt::SolidLine);
1180  normalCurvePen.setWidth(0);
1181  baseCurve->setPen(normalCurvePen);
1182 
1183  QPen normalProbCurvePen;
1184  normalProbCurvePen.setColor(QColor(Qt::red));
1185  normalProbCurvePen.setStyle(Qt::SolidLine);
1186  normalProbCurvePen.setWidth(0);
1187  normalCurve->setPen(normalProbCurvePen);
1188 
1189  //Creating and adjusting the chart Display's style.
1191  chartStyle->setTitle(QString::fromStdString("Normal Probability: " + dataset->getPropertyName(propId)));
1192  chartStyle->setAxisX( QString::fromStdString(dataset->getPropertyName(propId)));
1193  chartStyle->setAxisY(QString::fromStdString("Probability"));
1194  chartStyle->setGridChecked(true);
1195 
1196  //Creating and adjusting the chart Display
1197  te::qt::widgets::ChartDisplay* chartDisplay = new te::qt::widgets::ChartDisplay(0, QString::fromStdString("Normal Distribution"), chartStyle);
1198  chartDisplay->adjustDisplay();
1199  baseCurve->attach(chartDisplay);
1200  normalCurve->attach(chartDisplay);
1201 
1202  //Adjusting the chart widget
1203  te::qt::widgets::ChartDisplayWidget* displayWidget = new te::qt::widgets::ChartDisplayWidget(normalCurve, normalCurve->rtti(), chartDisplay);
1204  displayWidget->setWindowTitle("Normal Distribution");
1205  return displayWidget;
1206 }
TEQTWIDGETSEXPORT ChartDisplayWidget * createNormalDistribution(te::da::DataSet *dataset, int propId)
Definition: Utils.cpp:1122
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:602
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:1062
TEQTWIDGETSEXPORT Histogram * createHistogram(te::da::DataSet *dataset, te::da::DataSetType *dataType, int propId, int slices, int stat)
Histogram Creator.
Definition: Utils.cpp:786
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:519
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:170
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:120
TEQTWIDGETSEXPORT ChartDisplayWidget * createScatterDisplay(te::da::DataSet *dataset, te::da::DataSetType *dataType, int propX, int propY, int stat=-1)
Scatter Creator.
Definition: Utils.cpp:763
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:596
float errFunction(float x)
Definition: Utils.cpp:174
A class to represent a scatter.
Definition: Scatter.h:51
static RasterSummaryManager & 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:57
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:1007
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
boost::ptr_vector< BandSummary > RasterSummary
RasterSummary is just a typedef of a boost::ptr_vector.
Definition: RasterSummary.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:110
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:100
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:125
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:583
Calculate the min value.
Definition: Enums.h:40
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:427
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
Calculate the max value.
Definition: Enums.h:41
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:47
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