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 "../../../maptools/Utils.h"
39 #include "../../../se.h"
40 #include "../../../qt/widgets/Utils.h"
46 #include <boost/lexical_cast.hpp>
54 double getDouble(
const std::string& value, std::vector<std::string>& sVector)
57 for(std::size_t i=0;i<sVector.size();++i)
63 sVector.push_back(value);
64 return (
double)sVector.size()-1;
72 boost::gregorian::date basedate(1400, 01, 01);
73 boost::gregorian::date_duration days = ti->getDate().getDate() - basedate;
74 long long int seconds = ti->getTime().getTimeDuration().total_seconds();
75 long long int dias = days.days();
76 double v = (double) dias * 86400 + seconds;
82 boost::gregorian::date basedate(1400, 01, 01);
83 boost::gregorian::date_duration days = d->getDate() - basedate;
84 double v = days.days();
119 res = boost::lexical_cast<
double>(dataset->
getNumeric(propId));
131 std::vector<size_t>::iterator it;
132 std::vector<std::string> propNames;
134 for(it=pkeys.begin(); it!=pkeys.end(); ++it)
139 valuesOIDs.push_back(oid);
144 std::vector<size_t>::iterator it;
145 std::vector<std::string> propNames;
147 for(it=pkeys.begin(); it!=pkeys.end(); ++it)
159 std::vector<std::size_t> objIdIdx;
162 std::map<double, std::vector<te::da::ObjectId*> > valuesIdsByinterval;
163 std::vector<te::da::ObjectId*> valuesOIds;
166 if(rpos != std::string::npos)
168 std::auto_ptr<te::rst::Raster> raster(dataset->
getRaster(rpos));
170 unsigned int nCol = raster->getNumberOfColumns();
171 unsigned int nLin = raster->getNumberOfRows();
177 for (
unsigned int c=0; c < nCol; ++c)
183 for (
unsigned int r=0; r <nLin; ++r)
187 raster->getValue(c, r, val1, propX);
188 raster->getValue(c, r, val2, propY);
190 newScatter->
addX(val1);
191 newScatter->
addY(val2);
214 double x_doubleValue = 0.;
215 double y_doubleValue = 0.;
221 if(dataset->
isNull(propX))
224 x_doubleValue =
getDouble(dataset, propX);
228 if(dataset->
isNull(propX))
231 std::auto_ptr<te::dt::DateTime> dateTime = dataset->
getDateTime(propX);
232 x_doubleValue =
getDouble(dateTime.get());
240 if(dataset->
isNull(propY))
242 y_doubleValue =
getDouble(dataset, propY);
246 if(dataset->
isNull(propY))
249 std::auto_ptr<te::dt::DateTime> dateTime = dataset->
getDateTime(propY);
250 y_doubleValue =
getDouble(dateTime.get());
268 std::vector<std::size_t> objIdIdx;
271 if(rpos != std::string::npos)
273 std::auto_ptr<te::rst::Raster> rstptr = dataset->
getRaster(rpos);
274 std::map<double, unsigned int> values = rstptr->getBand(propId)->getHistogramR(0, 0, 0, 0, slices);
276 for(std::map<double, unsigned int>::iterator it = values.begin(); it != values.end(); ++it)
285 newHistogram->
setType(propType);
288 std::vector< unsigned int> values;
294 std::map<double, std::vector<te::da::ObjectId*> > intervalToOIds;
295 std::vector<te::da::ObjectId*> valuesOIds;
297 double interval, minValue, maxValue;
298 minValue = std::numeric_limits<double>::max();
299 maxValue = -std::numeric_limits<double>::max();
301 std::vector<double> intervals;
317 if(minValue >
getDouble(dataset, propId))
319 if(maxValue <
getDouble(dataset, propId))
326 interval = maxValue - minValue;
332 intervals.push_back(i);
333 intervalToOIds.insert(std::make_pair(i, valuesOIds));
336 values.resize(intervals.size(), 0);
349 double currentValue =
getDouble(dataset, propId);
351 for (
unsigned int i= 0; i<intervals.size(); ++i)
353 if((currentValue >= intervals[i]) && (currentValue <= intervals[i+1]))
355 values[i] = values[i]+1;
356 getObjectIds(dataset, objIdIdx, intervalToOIds.at(intervals[i]));
365 for (
unsigned int i= 0; i<intervals.size(); ++i)
368 newHistogram->
insert(std::make_pair(data, values[i]), intervalToOIds.at(intervals[i]));
385 std::vector<std::size_t> objIdIdx;
392 if(rpos != std::string::npos)
394 std::auto_ptr<te::rst::Raster> rstptr = dataset->
getRaster(rpos);
395 std::map<double, unsigned int> values = rstptr->getBand(propId)->getHistogramR();
397 for(std::map<double, unsigned int>::iterator it = values.begin(); it != values.end(); ++it)
407 newHistogram->
setType(propType);
410 std::vector< unsigned int> values;
415 std::set <std::string> intervals;
416 std::set <std::string>::iterator intervalsIt;
417 std::map<std::string, std::vector<te::da::ObjectId*> > valuesIdsByinterval;
418 std::vector<te::da::ObjectId*> valuesOIds;
429 std::string interval = dataset->
getString(propId);
432 intervals.insert(interval);
436 for (intervalsIt = intervals.begin(); intervalsIt != intervals.end(); ++intervalsIt)
438 valuesIdsByinterval.insert(make_pair((*intervalsIt), valuesOIds));
441 values.resize(intervals.size(), 0);
454 std::string currentValue = dataset->
getString(propId);
457 for ( i= 0, intervalsIt = intervals.begin(); intervalsIt != intervals.end(); ++intervalsIt,++i)
459 if(currentValue == *intervalsIt)
461 values[i] = values[i]+1;
462 getObjectIds(dataset, objIdIdx, valuesIdsByinterval.at(*intervalsIt));
471 for (i= 0, intervalsIt = intervals.begin(); intervalsIt != intervals.end(); ++intervalsIt,++i)
474 newHistogram->
insert(std::make_pair(data, values[i]), valuesIdsByinterval.at(*intervalsIt));
485 QwtText* result =
new QwtText(text.c_str());
486 result->setBackgroundBrush(QBrush(QColor(0, 255, 0)));
495 QwtText* result =
new QwtText(QString(text.c_str()));
503 QwtSymbol* symbol =
new QwtSymbol( QwtSymbol::Ellipse, QBrush( Qt::yellow ), QPen( Qt::red, 2 ), QSize( 8, 8 ));
506 size_t height = 8, width = 8;
531 pixmap = QPixmap::fromImage(*qimg);
534 symbol->setPixmap(pixmap);
535 symbol->setSize(width, height);
virtual std::string getPropertyName(std::size_t i) const =0
It returns the property name at position pos.
virtual double getDouble(std::size_t i) const =0
Method for retrieving a double attribute value.
bool isActive() const
Verify if the task is active.
TEQTWIDGETSEXPORT Histogram * createHistogram(te::da::DataSet *dataset, te::da::DataSetType *dataType, int propId, int slices)
Histogram Creator.
double & getInterval()
It returns the histogram's interval. Will be invalid if the histogram was created based on string int...
virtual std::size_t getNumProperties() const =0
It returns the number of properties that composes an item of the dataset.
A Fill specifies the pattern for filling an area geometry.
TEMAPEXPORT int GetInt(const te::se::ParameterValue *param)
Gets the parameter value as integer.
virtual std::auto_ptr< te::rst::Raster > getRaster(std::size_t i) const =0
Method for retrieving a raster attribute value.
virtual float getFloat(std::size_t i) const =0
Method for retrieving a float attribute value.
A class to represent a Histogram.
void setTotalSteps(int value)
Set the task total stepes.
void getObjectIds(te::da::DataSet *dataset, std::vector< std::size_t > pkeys, std::vector< te::da::ObjectId * > &valuesOIDs)
virtual std::auto_ptr< te::dt::DateTime > getDateTime(std::size_t i) const =0
Method for retrieving a date and time attribute value.
virtual boost::int32_t getInt32(std::size_t i) const =0
Method for retrieving a 32-bit integer attribute value (4 bytes long).
void setType(int new_type)
It sets the histogram's type.
virtual std::string getString(std::size_t i) const =0
Method for retrieving a string value attribute.
A template for atomic data types (integers, floats, strings and others).
virtual bool moveNext()=0
It moves the internal pointer to the next item of the collection.
A Stroke specifies the appearance of a linear geometry.
virtual std::string getNumeric(std::size_t i) const =0
Method for retrieving a numeric attribute value.
A class to represent a histogram.
virtual bool isNull(std::size_t i) const =0
It checks if the attribute value is NULL.
A base class for date data types.
virtual boost::int16_t getInt16(std::size_t i) const =0
Method for retrieving a 16-bit integer attribute value (2 bytes long).
void setStringInterval(std::set< std::string > new_Interval)
It sets the histogram's string set of intervals.
TEDATAACCESSEXPORT ObjectId * GenerateOID(DataSet *dataset, const std::vector< std::string > &names)
A class to represent a scatter.
Utility functions for the data access module.
void pulse()
Calls setCurrentStep() function using getCurrentStep() + 1.
void addY(double &yValue)
It adds a new value to the vector containing the Y axis values.
A helper class for 32-bit RGBA (Red-Green-Blue-Alpha channel) color.
SimpleData< std::string, STRING_TYPE > String
TEDATAACCESSEXPORT void GetOIDPropertyPos(const DataSetType *type, std::vector< std::size_t > &ppos)
A Font specifies the text font to use in a text symbolizer.
virtual int getPropertyDataType(std::size_t i) const =0
It returns the underlying data type of the property at position pos.
TEDATAACCESSEXPORT std::size_t GetFirstPropertyPos(const te::da::DataSet *dataset, int datatype)
virtual boost::int64_t getInt64(std::size_t i) const =0
Method for retrieving a 64-bit integer attribute value (8 bytes long).
A class to represent a scatter.
void calculateMinMaxValues()
Calculates the minimum and maximum values for both the X and Y axis.
virtual bool moveBeforeFirst()=0
It moves the internal pointer to a position before the first item in the collection.
This class represents an unique id for a data set element.
TEQTWIDGETSEXPORT Scatter * createScatter(te::da::DataSet *dataset, te::da::DataSetType *dataType, int propX, int propY)
Scatter Creator.
TEQTWIDGETSEXPORT QwtText * Terralib2Qwt(const std::string &title)
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.
A class that models the description of a dataset.
void setMinValue(double new_minValue)
It sets the histogram's minimum value.
A class to represent time instant.
const ParameterValue * getSize() const
void setInterval(double new_Interval)
It sets the histogram's interval.
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...
double getDouble(const std::string &value, std::vector< std::string > &sVector)
void setMessage(const std::string &message)
Set the task message.
This class can be used to inform the progress of a task.
void addX(double &xValue)
It adds a new value to the vector containing the X axis values.
const std::vector< ExternalGraphic * > getExternalGraphics() const
SimpleData< double, DOUBLE_TYPE > Double
static MarkRendererManager & getInstance()
It returns a reference to the singleton instance.
A Graphic is a graphic symbol with an inherent shape, color(s), and possibly size.
A dataset is the unit of information manipulated by the data access module of TerraLib.
int getTypeCode() const
It returns the data type code associated to date and time values: DATETIME_TYPE.
const std::vector< Mark * > getMarks() const
TEQTWIDGETSEXPORT QImage * GetImage(te::color::RGBAColor **img, int width, int height)
It creates a QImage from an RGBA color array.