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/ObjectId.h"
32 #include "../../../dataaccess/dataset/ObjectIdSet.h"
33 #include "../../../dataaccess/utils/Utils.h"
34 #include "../../../datatype.h"
35 #include "../../../raster.h"
36 #include "../../../maptools/ExternalGraphicRendererManager.h"
37 #include "../../../maptools/MarkRendererManager.h"
38 #include "../../../qt/widgets/Utils.h"
39 #include "../../../se/Utils.h"
40 #include "../../../se.h"
51 #include <boost/lexical_cast.hpp>
59 double getDouble(
const std::string& value, std::vector<std::string>& sVector)
62 for(std::size_t i=0;i<sVector.size();++i)
68 sVector.push_back(value);
69 return (
double)sVector.size()-1;
77 boost::gregorian::date basedate(1400, 01, 01);
78 boost::gregorian::date_duration days = ti->getDate().getDate() - basedate;
79 long long int seconds = ti->getTime().getTimeDuration().total_seconds();
80 long long int dias = days.days();
81 double v = (double) dias * 86400 + seconds;
87 boost::gregorian::date basedate(1400, 01, 01);
88 boost::gregorian::date_duration days = d->getDate() - basedate;
89 double v = days.days();
124 res = boost::lexical_cast<
double>(dataset->
getNumeric(propId));
136 std::vector<size_t>::iterator it;
137 std::vector<std::string> propNames;
139 for(it=pkeys.begin(); it!=pkeys.end(); ++it)
144 valuesOIDs.push_back(oid);
149 std::vector<size_t>::iterator it;
150 std::vector<std::string> propNames;
152 for(it=pkeys.begin(); it!=pkeys.end(); ++it)
164 std::vector<std::size_t> objIdIdx;
167 std::map<double, std::vector<te::da::ObjectId*> > valuesIdsByinterval;
168 std::vector<te::da::ObjectId*> valuesOIds;
171 if(rpos != std::string::npos)
173 std::auto_ptr<te::rst::Raster> raster(dataset->
getRaster(rpos));
175 unsigned int nCol = raster->getNumberOfColumns();
176 unsigned int nLin = raster->getNumberOfRows();
182 for (
unsigned int c=0; c < nCol; ++c)
189 for (
unsigned int r=0; r <nLin; ++r)
193 raster->getValue(c, r, val1, propX);
194 raster->getValue(c, r, val2, propY);
196 newScatter->
addX(val1);
197 newScatter->
addY(val2);
220 double x_doubleValue = 0.;
221 double y_doubleValue = 0.;
227 if(dataset->
isNull(propX))
230 x_doubleValue =
getDouble(dataset, propX);
234 if(dataset->
isNull(propX))
237 std::auto_ptr<te::dt::DateTime> dateTime = dataset->
getDateTime(propX);
238 x_doubleValue =
getDouble(dateTime.get());
246 if(dataset->
isNull(propY))
248 y_doubleValue =
getDouble(dataset, propY);
252 if(dataset->
isNull(propY))
255 std::auto_ptr<te::dt::DateTime> dateTime = dataset->
getDateTime(propY);
256 y_doubleValue =
getDouble(dateTime.get());
275 chartStyle->
setTitle(QString::fromStdString(
"Scatter"));
282 chart->attach(chartDisplay);
286 displayWidget->show();
287 displayWidget->setWindowTitle(
"Scatter");
288 return displayWidget;
299 std::vector<std::size_t> objIdIdx;
302 if(rpos != std::string::npos)
304 std::auto_ptr<te::rst::Raster> rstptr = dataset->
getRaster(rpos);
305 std::map<double, unsigned int> values = rstptr->getBand(propId)->getHistogramR(0, 0, 0, 0, slices);
307 for(std::map<double, unsigned int>::iterator it = values.begin(); it != values.end(); ++it)
316 newHistogram->
setType(propType);
319 std::vector< unsigned int> values;
325 std::map<double, std::vector<te::da::ObjectId*> > intervalToOIds;
326 std::vector<te::da::ObjectId*> valuesOIds;
328 double interval, minValue, maxValue;
329 minValue = std::numeric_limits<double>::max();
330 maxValue = -std::numeric_limits<double>::max();
332 std::vector<double> intervals;
349 if(minValue >
getDouble(dataset, propId))
351 if(maxValue <
getDouble(dataset, propId))
358 interval = maxValue - minValue;
364 intervals.push_back(i);
365 intervalToOIds.insert(std::make_pair(i, valuesOIds));
368 values.resize(intervals.size(), 0);
381 double currentValue =
getDouble(dataset, propId);
383 for (
unsigned int i= 0; i<intervals.size(); ++i)
385 if((currentValue >= intervals[i]) && (currentValue <= intervals[i+1]))
387 values[i] = values[i]+1;
388 getObjectIds(dataset, objIdIdx, intervalToOIds.at(intervals[i]));
397 for (
unsigned int i= 0; i<intervals.size(); ++i)
400 newHistogram->
insert(std::make_pair(data, values[i]), intervalToOIds.at(intervals[i]));
417 std::vector<std::size_t> objIdIdx;
424 if(rpos != std::string::npos)
426 std::auto_ptr<te::rst::Raster> rstptr = dataset->
getRaster(rpos);
427 std::map<double, unsigned int> values = rstptr->getBand(propId)->getHistogramR();
429 for(std::map<double, unsigned int>::iterator it = values.begin(); it != values.end(); ++it)
439 newHistogram->
setType(propType);
442 std::vector< unsigned int> values;
447 std::set <std::string> intervals;
448 std::set <std::string>::iterator intervalsIt;
449 std::map<std::string, std::vector<te::da::ObjectId*> > valuesIdsByinterval;
450 std::vector<te::da::ObjectId*> valuesOIds;
463 std::string interval = dataset->
getString(propId);
466 intervals.insert(interval);
470 for (intervalsIt = intervals.begin(); intervalsIt != intervals.end(); ++intervalsIt)
472 valuesIdsByinterval.insert(make_pair((*intervalsIt), valuesOIds));
475 values.resize(intervals.size(), 0);
488 std::string currentValue = dataset->
getString(propId);
491 for ( i= 0, intervalsIt = intervals.begin(); intervalsIt != intervals.end(); ++intervalsIt,++i)
493 if(currentValue == *intervalsIt)
495 values[i] = values[i]+1;
496 getObjectIds(dataset, objIdIdx, valuesIdsByinterval.at(*intervalsIt));
505 for (i= 0, intervalsIt = intervals.begin(); intervalsIt != intervals.end(); ++intervalsIt,++i)
508 newHistogram->
insert(std::make_pair(data, values[i]), valuesIdsByinterval.at(*intervalsIt));
533 chartStyle->
setTitle(QString::fromStdString(
"Histogram"));
535 chartStyle->
setAxisY(QString::fromStdString(
"Frequency"));
540 chart->
attach(chartDisplay);
544 displayWidget->show();
545 displayWidget->setWindowTitle(
"Histogram");
546 return displayWidget;
551 QwtText* result =
new QwtText(text.c_str());
552 result->setBackgroundBrush(QBrush(QColor(0, 255, 0)));
561 QwtText* result =
new QwtText(QString(text.c_str()));
569 QwtSymbol* symbol =
new QwtSymbol( QwtSymbol::Ellipse, QBrush( Qt::yellow ), QPen( Qt::red, 2 ), QSize( 8, 8 ));
572 size_t height = 8, width = 8;
597 pixmap = QPixmap::fromImage(*qimg);
600 symbol->setPixmap(pixmap);
601 symbol->setSize(width, height);
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
virtual boost::int16_t getInt16(std::size_t i) const =0
Method for retrieving a 16-bit integer attribute value (2 bytes long).
void setMessage(const std::string &message)
Set the task message.
Utility functions for the data access module.
virtual boost::int32_t getInt32(std::size_t i) const =0
Method for retrieving a 32-bit integer attribute value (4 bytes long).
TEDATAACCESSEXPORT ObjectId * GenerateOID(DataSet *dataset, const std::vector< std::string > &names)
const std::vector< ExternalGraphic * > getExternalGraphics() const
A class that models the description of a dataset.
virtual boost::int64_t getInt64(std::size_t i) const =0
Method for retrieving a 64-bit integer attribute value (8 bytes long).
This class can be used to inform the progress of a task.
virtual std::auto_ptr< te::rst::Raster > getRaster(std::size_t i) const =0
Method for retrieving a raster attribute value.
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.
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.
A class to represent time instant.
void setTotalSteps(int value)
Set the task total stepes.
A class to represent a histogram.
virtual bool moveNext()=0
It moves the internal pointer to the next item of the collection.
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.
A base class for date data types.
virtual std::string getPropertyName(std::size_t i) const =0
It returns the property name at position pos.
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.
A Font specifies the text font to use in a text symbolizer.
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.
virtual std::size_t getNumProperties() const =0
It returns the number of properties that composes an item of the dataset.
A class to represent a scatter's chart.
A class to represent a scatter.
A dataset is the unit of information manipulated by the data access module of TerraLib.
const std::vector< Mark * > getMarks() const
TEDATAACCESSEXPORT void GetOIDPropertyPos(const DataSetType *type, std::vector< std::size_t > &ppos)
A Stroke specifies the appearance of a linear geometry.
virtual bool moveBeforeFirst()=0
It moves the internal pointer to a position before the first item in the collection.
SimpleData< double, DOUBLE_TYPE > Double
A helper class for 32-bit RGBA (Red-Green-Blue-Alpha channel) color.
TESEEXPORT int GetInt(const te::se::ParameterValue *param)
It gets the parameter value as an integer.
int getTypeCode() const
It returns the data type code associated to date and time values: DATETIME_TYPE.
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)
A template for atomic data types (integers, floats, strings and others).
virtual int getPropertyDataType(std::size_t i) const =0
It returns the underlying data type of the property at position pos.
A class to represent a chart display.
const ParameterValue * getSize() const