27 #include "../../color/ColorBar.h"
28 #include "../../color/ColorScheme.h"
29 #include "../../color/ColorSchemeCatalog.h"
30 #include "../../color/ColorSchemeCatalogManager.h"
31 #include "../../color/ColorSchemeGroup.h"
32 #include "../../color/RGBAColor.h"
33 #include "../../common/Globals.h"
34 #include "../../common/StringUtils.h"
35 #include "../../dataaccess/datasource/DataSource.h"
36 #include "../../dataaccess/datasource/DataSourceInfo.h"
37 #include "../../dataaccess/datasource/DataSourceInfoManager.h"
38 #include "../../dataaccess/datasource/DataSourceManager.h"
39 #include "../../maptools/Grouping.h"
40 #include "../../maptools/GroupingAlgorithms.h"
41 #include "../../maptools/GroupingItem.h"
42 #include "../../maptools/Utils.h"
43 #include "../../raster/RasterSummary.h"
44 #include "../../raster/RasterSummaryManager.h"
45 #include "../../se/ColorMap.h"
46 #include "../../se/Enums.h"
47 #include "../../se/Interpolate.h"
48 #include "../../se/InterpolationPoint.h"
49 #include "../../se/ParameterValue.h"
50 #include "../../se/RasterSymbolizer.h"
51 #include "../../se/Utils.h"
52 #include "../../qt/widgets/layer/utils/DataSet2Layer.h"
56 #include <boost/filesystem.hpp>
57 #include <boost/uuid/random_generator.hpp>
58 #include <boost/uuid/uuid_io.hpp>
66 boost::filesystem::path uri(repository);
68 std::map<std::string, std::string> dsInfo;
69 dsInfo[
"URI"] = uri.string();
71 boost::uuids::basic_random_generator<boost::mt19937> gen;
72 boost::uuids::uuid u = gen();
73 std::string id_ds = boost::uuids::to_string(u);
76 dsInfoPtr->setConnInfo(dsInfo);
77 dsInfoPtr->setTitle(uri.stem().string());
78 dsInfoPtr->setAccessDriver(
"OGR");
79 dsInfoPtr->setType(
"OGR");
80 dsInfoPtr->setDescription(uri.string());
81 dsInfoPtr->setId(id_ds);
90 std::string name = path +
"/" + dataSetName +
".shp";
97 std::string name = path +
"/" + dataSetName +
".tif";
100 boost::filesystem::path uri(name);
102 std::map<std::string, std::string> dsInfo;
103 dsInfo[
"URI"] = uri.string();
105 boost::uuids::basic_random_generator<boost::mt19937> gen;
106 boost::uuids::uuid u = gen();
107 std::string id_ds = boost::uuids::to_string(u);
110 dsInfoPtr->setConnInfo(dsInfo);
111 dsInfoPtr->setTitle(uri.stem().string());
112 dsInfoPtr->setAccessDriver(
"GDAL");
113 dsInfoPtr->setType(
"GDAL");
114 dsInfoPtr->setDescription(uri.string());
115 dsInfoPtr->setId(id_ds);
128 return converter(dt);
138 std::vector<double> vec;
141 std::auto_ptr<te::da::DataSet> ds(layer->getData());
142 ds->moveBeforeFirst();
144 while(ds->moveNext())
146 if(ds->isNull(bayesAttr))
152 vec.push_back(ds->getDouble(bayesAttr));
156 std::vector<te::map::GroupingItem*> legend;
160 std::auto_ptr<te::color::ColorBar> cb(
GetColorBar(
"Default",
"Basic",
"Vermelho"));
162 int legendSize = legend.size();
164 std::vector<te::color::RGBAColor> colorVec;
166 colorVec = cb->getSlices(legendSize);
171 for(
size_t t = 0; t < colorVec.size(); ++t)
173 std::vector<te::se::Symbolizer*> symbVec;
177 symbVec.push_back(s);
179 legend[t]->setSymbolizers(symbVec);
191 std::vector<te::se::Symbolizer*> symbVec;
193 symbVec.push_back(s);
196 legend.push_back(legendItem);
207 layer->setGrouping(group);
216 std::vector<double> vec;
219 std::auto_ptr<te::da::DataSet> ds(layer->getData());
220 ds->moveBeforeFirst();
222 while(ds->moveNext())
224 if(ds->isNull(kernelAttr))
230 vec.push_back(ds->getDouble(kernelAttr));
234 std::vector<te::map::GroupingItem*> legend;
238 std::auto_ptr<te::color::ColorBar> cb(
GetColorBar(
"Default",
"Classification",
"Kernel"));
240 int legendSize = legend.size();
242 std::vector<te::color::RGBAColor> colorVec;
244 colorVec = cb->getSlices(legendSize);
249 for(
size_t t = 0; t < colorVec.size(); ++t)
251 std::vector<te::se::Symbolizer*> symbVec;
255 symbVec.push_back(s);
257 legend[t]->setSymbolizers(symbVec);
269 std::vector<te::se::Symbolizer*> symbVec;
271 symbVec.push_back(s);
274 legend.push_back(legendItem);
285 layer->setGrouping(group);
301 const std::complex<double>* cmin = rsMin->at(0).m_minVal;
302 const std::complex<double>* cmax = rsMax->at(0).m_maxVal;
303 double min = cmin->real();
304 double max = cmax->real();
309 std::auto_ptr<te::color::ColorBar> cb(
GetColorBar(
"Default",
"Classification",
"Kernel"));
311 std::vector<te::color::RGBAColor> colorVec = cb->getSlices(slices + 1);
313 std::vector<te::map::GroupingItem*> legVec;
315 std::vector<double> vec;
324 interpolate->setFallbackValue(
"#000000");
328 for(std::size_t i = 0; i < colorVec.size(); ++i)
330 QColor color(colorVec[i].getRed(), colorVec[i].getGreen(), colorVec[i].getBlue(), colorVec[i].getAlpha());
332 if(i == colorVec.size() - 1)
334 QString rangeStr = legVec[i - 1]->getUpperLimit().c_str();
335 std::string colorStr = color.name().toLatin1().data();
339 ip->
setData(rangeStr.toDouble());
342 interpolate->add(ip);
346 QString rangeStr = legVec[i]->getLowerLimit().c_str();
347 std::string colorStr = color.name().toLatin1().data();
351 ip->
setData(rangeStr.toDouble());
354 interpolate->add(ip);
372 std::vector<te::map::GroupingItem*> legend;
376 std::auto_ptr<te::color::ColorBar> cb(
GetColorBar(
"Default",
"Classification",
"Circular"));
378 int legendSize = legend.size();
380 std::vector<te::color::RGBAColor> colorVec;
382 colorVec = cb->getSlices(legendSize);
387 for(
size_t t = 0; t < colorVec.size(); ++t)
389 std::vector<te::se::Symbolizer*> symbVec;
393 symbVec.push_back(s);
395 legend[t]->setSymbolizers(symbVec);
405 layer->setGrouping(group);
415 std::vector<te::map::GroupingItem*> legend;
417 std::vector<std::string> strVec;
419 for(
int i = 0; i < nClasses; ++i)
437 for(
size_t t = 0; t < legend.size(); ++t)
439 std::vector<te::se::Symbolizer*> symbVec;
443 symbVec.push_back(s);
445 legend[t]->setSymbolizers(symbVec);
455 layer->setGrouping(group);
468 for(std::size_t t = 0; t < csgVec.size(); ++t)
476 for(std::size_t p = 0; p < csVec.size(); ++p)
482 std::vector<te::color::RGBAColor>* colors = cs->
getColors()[0];
484 std::vector<te::color::RGBAColor>::iterator it = colors->begin();
492 while(it != colors->end())
494 if(count != 0 && count != colors->size() - 1)
496 double pos = (1. / (colors->size() - 1)) * count;
void setPrecision(size_t precision)
It sets the precision to be used for the property values.
GeomType
Each enumerated type is compatible with a Well-known Binary (WKB) type code.
TESAEXPORT void CreateKernelColorMaping(te::map::AbstractLayerPtr layer)
boost::shared_ptr< DataSetType > DataSetTypePtr
TESEEXPORT Symbolizer * CreateSymbolizer(const te::gm::GeomType &geomType)
Try creates an appropriate symbolizer based on given geometry type.
boost::shared_ptr< DataSource > DataSourcePtr
const std::vector< ColorScheme * > & getColorSchemes() const
It returns a reference to the list of color schemes belonging to this group.
TESAEXPORT te::da::DataSourcePtr CreateOGRDataSource(std::string repository)
const std::vector< ColorSchemeGroup * > & getColorSchemeGroups() const
It returns the list of color scheme groups in the catalog.
void setData(const double &d)
void setGroupingItems(std::vector< te::map::GroupingItem * > &items)
It sets the vector of grouping items.
TESAEXPORT void CreateSampleGeneratorStratifiedGrouping(te::map::AbstractLayerPtr layer, std::vector< std::string > strVec)
A Symbolizer describes how a feature is to appear on a map.
const std::string & getName() const
It returns the group name.
TESEEXPORT RasterSymbolizer * GetRasterSymbolizer(Style *s)
Try to get raster symbolizer from a style.
It models the concept of color scheme.
TEMAPEXPORT te::gm::GeomType GetGeomType(const te::map::AbstractLayerPtr &layer)
It gets the geometry type of the given layer.
void addColor(const RGBAColor &color, const double &pos)
It adds a color in the color bar.
const std::vector< std::vector< RGBAColor > * > & getColors() const
It returns all color lists.
TESAEXPORT te::da::DataSourcePtr CreateGDALDataSource(std::string path, std::string dataSetName)
void setStdDeviation(double stdDeviation)
It sets the standard deviation for the Standard Deviation grouping.
void setTitle(const std::string &title)
It sets the title of the legend item.
void GroupingByEqualSteps(iterator begin, iterator end, int nSteps, std::vector< te::map::GroupingItem * > &legend, int precision=0, bool countElements=true)
It groups the values defined by a range of iterators using the equal steps algorithm.
The transformation of continuous values to a number of values (Interpolate function).
The "ParameterValueType" uses WFS-Filter expressions to give values for SE graphic parameters...
void setValue(ParameterValue *v)
This class contains the parameters needed for grouping the values of a Property.
void setNumSlices(size_t numSlices)
It sets the number of slices for the EqualSteps and Quantil groupings.
static DataSourceInfoManager & getInstance()
It returns a reference to the singleton instance.
A GroupingItem contains information about a grouping item associated to a layer.
TESAEXPORT void CreateBayesGrouping(te::map::AbstractLayerPtr layer)
An abstract class for raster data strucutures.
void setPropertyType(const int &type)
It sets the property type whose values will be grouped.
boost::ptr_vector< BandSummary > RasterSummary
RasterSummary is just a typedef of a boost::ptr_vector.
The RasterSymbolizer describes how to render raster/matrix-coverage data (e.g., satellite photos...
const std::string & getName() const
It returns the color schema name.
TEMAPEXPORT te::rst::Raster * GetRaster(DataSetLayer *layer)
It gets the raster referenced by the given data set layer.
This class represents a group of color schemes.
They are used to define a graph of points.
TEMAPEXPORT void GroupingByUniqueValues(std::vector< std::string > &inputValues, int dataType, std::vector< te::map::GroupingItem * > &legend, int precision)
It groups the values using the unique value algorithm.
void setCount(std::size_t count)
It It sets the number of objects whose values are between the lower and upper limits.
A catalog for color schemes.
TESAEXPORT te::map::AbstractLayerPtr CreateLayer(te::da::DataSourcePtr ds, std::string dataSetName)
void setColorMap(ColorMap *c)
void setUpperLimit(const std::string &to)
It sets the upper limit value of the legend item.
TESAEXPORT te::color::ColorBar * GetColorBar(std::string catalog, std::string group, std::string schema)
It models the concept of color bar.
A class that represents a data source component.
#define TE_SA_SKATER_ATTR_CLASS_NAME
TESEEXPORT std::string GenerateRandomColor()
Creates a random RGB color encoded using two hexadecimal digits per primary-color component prefixed ...
A layer with reference to a dataset.
TESAEXPORT void CreateKernelGrouping(te::map::AbstractLayerPtr layer, std::string kernelAttr)
std::string Convert2String(boost::int16_t value)
It converts a short integer value to a string.
TESAEXPORT void CreateSkaterGrouping(te::map::AbstractLayerPtr layer, int nClasses)
boost::intrusive_ptr< AbstractLayer > AbstractLayerPtr
#define TE_SA_SPG_ATTR_CLASS_NAME
#define TE_SA_BAYES_ATTR_NAME
void setInterpolate(Interpolate *i)
A ColorMap defines either the colors of a pallette-type raster source or the mapping of numeric pixel...
boost::shared_ptr< DataSourceInfo > DataSourceInfoPtr
void setSymbolizers(const std::vector< te::se::Symbolizer * > &symbolizers)
It sets the symbolizers of the legend item.
static const std::string sm_nanStr
Not a number string value.
void setLowerLimit(const std::string &from)
It sets the lower limit value of the legend item.