27 #include "../../common/BoostUtils.h"
28 #include "../../common/Translator.h"
29 #include "../../color/RGBAColor.h"
30 #include "../../dataaccess/dataset/AttributeConverterManager.h"
31 #include "../../dataaccess/dataset/DataSetTypeConverter.h"
32 #include "../../dataaccess/datasource/DataSourceManager.h"
33 #include "../../dataaccess/serialization/xml/Serializer.h"
34 #include "../../dataaccess/utils/Utils.h"
35 #include "../../datatype/DateTimeProperty.h"
36 #include "../../datatype/NumericProperty.h"
37 #include "../../datatype/Property.h"
38 #include "../../datatype/SimpleProperty.h"
39 #include "../../datatype/StringProperty.h"
40 #include "../../datatype/serialization/xml/Serializer.h"
41 #include "../../geometry/Envelope.h"
42 #include "../../geometry/GeometryProperty.h"
43 #include "../../geometry/serialization/xml/Serializer.h"
44 #include "../../se/CoverageStyle.h"
45 #include "../../xml/Reader.h"
46 #include "../../xml/Writer.h"
47 #include "../../maptools/AbstractLayer.h"
48 #include "../../maptools/Chart.h"
49 #include "../../maptools/DataSetAdapterLayer.h"
50 #include "../../maptools/DataSetLayer.h"
51 #include "../../maptools/FolderLayer.h"
52 #include "../../maptools/Grouping.h"
53 #include "../../maptools/GroupingItem.h"
54 #include "../../maptools/QueryLayer.h"
55 #include "../../maptools/RasterLayer.h"
56 #include "../../se/RasterSymbolizer.h"
57 #include "../se/Style.h"
58 #include "../se/Symbolizer.h"
59 #include "../Exception.h"
67 #include <boost/algorithm/string/case_conv.hpp>
68 #include <boost/format.hpp>
69 #include <boost/lexical_cast.hpp>
98 if(type ==
"EQUAL_STEPS")
101 if(type ==
"QUANTIL")
104 if(type ==
"STD_DEVIATION")
107 assert(type ==
"UNIQUE_VALUE");
117 return "EQUAL_STEPS";
123 return "STD_DEVIATION";
128 return "UNIQUE_VALUE";
186 return simpleProperty;
233 item->setTitle(title);
247 item->setLowerLimit(fromValue);
260 item->setUpperLimit(toValue);
274 item->setValue(value);
280 std::vector<te::se::Symbolizer*> symbs;
290 item->setSymbolizers(symbs);
292 return item.release();
341 g->setPropertyType(propertyType);
353 g->setStdDeviation(stdDeviation);
359 std::vector<te::map::GroupingItem*> items;
369 g->setGroupingItems(items);
377 return std::auto_ptr<te::map::Chart>();
446 std::size_t barWidth = -1;
498 std::vector<std::string> properties;
499 std::vector<te::color::RGBAColor> colors;
539 properties.push_back(propName);
540 colors.push_back(hColor);
547 std::auto_ptr<te::map::Chart> chart(
new te::map::Chart(type, properties, colors));
548 chart->setContourColor(contourColor);
549 chart->setContourWidth(contourWidth);
550 chart->setHeight(height);
551 chart->setVisibility(isVisible);
553 chart->setBarWidth(barWidth);
555 chart->setMaxValue(maxValue);
582 std::vector<std::string> properties = chart->
getProperties();
584 for(std::size_t i = 0; i < properties.size(); ++i)
588 writer.
writeElement(
"te_map:PropertyName", properties[i]);
614 for(std::size_t i = 0; i < items.size(); ++i)
631 const std::vector<te::se::Symbolizer*>& symbs = item->
getSymbolizers();
633 for(std::size_t j = 0; j < symbs.size(); ++j)
685 LayerFnctIdxType::const_iterator it = m_fncts.find(layerType);
687 if(it == m_fncts.end())
688 throw Exception((boost::format(
TR_SERIALIZATION(
"Could not find a reader for the following layer type: %1%.")) % layerType).str());
690 assert(it->second.second);
692 return it->second.first(reader);
699 LayerFnctIdxType::const_iterator it = m_fncts.find(alayer->
getType());
701 if(it == m_fncts.end())
702 throw Exception((boost::format(
TR_SERIALIZATION(
"Could not find a writer for the following layer type: %1%.")) % alayer->
getType()).str());
704 assert(it->second.second);
706 return it->second.second(alayer, writer);
724 std::string
id = reader.
getAttr(0);
789 std::auto_ptr<te::se::Style> style;
814 layer->setSRID(srid);
815 layer->setExtent(*mbr.get());
817 layer->setDataSetName(dataset);
818 layer->setDataSourceId(datasourceId);
819 layer->setRendererType(rendererId);
820 layer->setStyle(style.release());
823 layer->setGrouping(grouping);
826 layer->setChart(chart.release());
828 return layer.release();
835 std::string
id = reader.
getAttr(0);
891 std::auto_ptr<te::se::Style> style;
913 layer->setSRID(srid);
914 layer->setExtent(*mbr.get());
916 layer->setQuery(query);
917 layer->setDataSourceId(datasourceId);
918 layer->setRendererType(rendererId);
919 layer->setStyle(style.release());
922 layer->setGrouping(grouping);
924 return layer.release();
929 std::string
id = reader.
getAttr(0);
968 return flayer.release();
973 std::string
id = reader.
getAttr(0);
988 std::map<std::string, std::string> conninfo;
990 while(reader.
next() &&
1014 conninfo[paramName] = paramValue;
1050 std::auto_ptr<te::se::Style> style;
1072 layer->setSRID(srid);
1073 layer->setExtent(*mbr.get());
1074 layer->setRasterInfo(conninfo);
1076 layer->setRendererType(rendererId);
1077 layer->setStyle(dynamic_cast<te::se::CoverageStyle*>(style.release()));
1079 return layer.release();
1084 std::string
id = reader.
getAttr(0);
1142 std::auto_ptr<te::se::Style> style;
1176 std::vector<std::pair<std::string, std::vector<std::size_t> > > props;
1250 std::pair<std::string, std::vector<std::size_t> > prop;
1252 std::vector<std::size_t> typeVec;
1253 typeVec.push_back(type);
1254 typeVec.push_back(geomType);
1255 typeVec.push_back(srid);
1256 prop.second = typeVec;
1257 props.push_back(prop);
1260 std::vector<std::vector<std::size_t> > propertyIndexes;
1270 std::vector<std::size_t> inIdxs;
1290 propertyIndexes.push_back(inIdxs);
1295 std::vector<std::string> functionsNames;
1334 std::auto_ptr<te::da::DataSetType> dst = ds->getDataSetType(dataSetName);
1338 for(std::size_t i = 0; i < propertyIndexes.size(); ++i)
1340 converter->add(propertyIndexes[i],
GetProperty(props[i].first, props[i].second[0], props[i].second[1], props[i].second[2]), functionsNames[i]);
1343 std::vector<te::dt::Property*> convertedProps = converter->getResult()->getProperties();
1350 std::vector<te::dt::Property*> pkProps = pkIn->
getProperties();
1351 for(std::size_t i = 0; i < convertedProps.size(); ++i)
1353 for(std::size_t t = 0; t < pkProps.size(); ++t)
1355 if(convertedProps[i]->getName() == pkProps[t]->getName())
1356 pk->
add(convertedProps[i]);
1366 std::auto_ptr<te::da::DataSet> dataset = result->
getData();
1370 while(dataset->moveNext())
1459 for(
size_t i=0; i<count; i++)
1479 std::map<std::string, std::string> info = layer->
getRasterInfo();
1480 std::map<std::string, std::string>::iterator conIt;
1482 for(conIt=info.begin(); conIt!=info.end(); ++conIt)
1546 std::vector<te::dt::Property*> outProps = resultDt->
getProperties();
1548 for(std::size_t i = 0; i < outProps.size(); ++i)
1552 writer.
writeElement(
"te_map:type", outProps[i]->getType());
1553 writer.
writeElement(
"te_map:name", outProps[i]->getName());
1575 for(std::size_t i = 0; i < propertyIndexes.size(); ++i)
1581 std::vector<std::size_t> inputPropertiesIdx = propertyIndexes[i];
1583 for(std::size_t j = 0; j < inputPropertiesIdx.size(); ++j)
1584 writer.
writeElement(
"te_map:InIdx", (
int)inputPropertiesIdx[j]);
1589 std::vector<te::da::AttributeConverter> converters = converter->
getConverters();
1590 for(std::size_t i = 0; i < converters.size(); ++i)
const std::string & getDataSourceId() const
GroupingType
The grouping type associated to the layer.
virtual void setExtent(const te::gm::Envelope &mbr)
It sets the Layer extent (or minimum bounding box).
A layer with reference to a dataset.
const std::string & getDataSetName() const
virtual te::map::Chart * getChart() const
It returns the Chart associated to the Layer.
void setDataSetName(const std::string &name)
This class contains the parameters needed for grouping the values of a Property.
virtual bool getElementValueAsBoolean() const
It returns the element data value in the case of VALUE node.
te::map::AbstractLayer * DataSetAdapterLayerReader(te::xml::Reader &reader)
An atomic property like an integer or double.
const te::color::RGBAColor & getContourColor() const
TEDATAACCESSEXPORT te::da::Select * ReadSelect(te::xml::Reader &reader)
TECOMMONEXPORT std::string ConvertLatin1UTFString(const std::string &data, const bool &toUtf=true)
Converts a string from latin1 to utf8 and vice-versa.
const std::string & getDataSetName() const
std::size_t getContourWidth() const
const std::string & getDataSourceId() const
TEDATAACCESSEXPORT DataSourcePtr GetDataSource(const std::string &datasourceId, const bool opened=true)
Search for a data source with the informed id in the DataSourceManager.
ChartType getType() const
An converter for DataSetType.
TEDATAACCESSEXPORT void Save(const std::string &fileName)
virtual const std::string & getTitle() const
It returns the layer title.
TEDATAACCESSEXPORT te::gm::GeometryProperty * GetFirstGeomProperty(const DataSetType *dt)
const double getStdDeviation() const
It gets the standard deviation used in the Standard Deviation grouping.
This is the base class for layers.
The type for date and time types: date, date period, date duration, time duration, time instant, time period, time instant with time zone or time period with time zone.
A Select models a query to be used when retrieving data from a DataSource.
int getSRID() const
It returns the spatial reference system identifier associated to this property.
te::map::AbstractLayer * read(te::xml::Reader &reader) const
The type for string types: FIXED_STRING, VAR_STRING or STRING.
This class models a XML reader object.
std::map< std::string, std::string > getRasterInfo() const
bool isVisible() const
It gets the chart visibility.
std::string ReadLayerTitle(te::xml::Reader &reader)
void write(const te::se::Style *style, te::xml::Writer &writer) const
It describes a primary key (pk) constraint.
te::map::GroupingType GetGroupingType(const std::string &type)
virtual bool next()=0
It gets the next event to be read.
const std::string & getName() const
It returns the property name.
#define TR_SERIALIZATION(message)
It marks a string in order to get translated. This is a special mark used in the XML module of TerraL...
A layer that can be used as a container for other kind of layers.
Visibility
Each layer can have three states of visibility.
const std::string & getDataSourceId() const
const std::string & getValue() const
It gets the value of the legend item.
virtual te::map::Grouping * getGrouping() const
It returns the Grouping associated to the Layer.
int getPropertyType() const
It gets the property type whose values will be grouped.
const std::vector< AttributeConverter > & getConverters() const
const std::vector< te::dt::Property * > & getProperties() const
It returns the properties that take part of the primary key.
const std::string & getRendererType() const
virtual double getElementValueAsDouble() const
It returns the element data value in the case of VALUE node.
const std::string & getRendererType() const
const std::vector< std::string > & getProperties() const
boost::function< te::map::AbstractLayer *(te::xml::Reader &)> LayerReadFnctType
void RasterLayerWriter(const te::map::AbstractLayer *layer, te::xml::Writer &writer)
te::map::GroupingItem * ReadGroupingItem(te::xml::Reader &reader)
virtual void writeStartElement(const std::string &qName)
virtual void writeAttribute(const std::string &attName, const std::string &value)
virtual void setTitle(const std::string &title)
It sets the layer title.
GeomType getGeometryType() const
It returns the geometry subtype allowed for the property.
te::map::AbstractLayer * QueryLayerReader(te::xml::Reader &reader)
void DataSetAdapterLayerWriter(const te::map::AbstractLayer *layer, te::xml::Writer &writer)
virtual std::string getElementValue() const =0
It returns the element data value in the case of VALUE node.
virtual void writeEndElement(const std::string &qName)
ChartType
The chart types.
void QueryLayerWriter(const te::map::AbstractLayer *layer, te::xml::Writer &writer)
std::size_t getChildrenCount() const
It returns the number of children of this node.
TEGEOMEXPORT std::auto_ptr< te::gm::Envelope > ReadExtent(te::xml::Reader &reader)
Geometry is the root class of the geometries hierarchy, it follows OGC and ISO standards.
void WriteLayerChart(te::map::Chart *chart, te::xml::Writer &writer)
std::string getPropertyName() const
It gets the property name whose values will be grouped.
A helper class for 32-bit RGBA (Red-Green-Blue-Alpha channel) color.
te::map::Grouping * ReadLayerGrouping(te::xml::Reader &reader)
std::pair< LayerReadFnctType, LayerWriteFnctType > LayerFnctSerializeType
virtual boost::int32_t getElementValueAsInt32() const
It returns the element data value in the case of VALUE node.
const std::vector< Property * > & getProperties() const
It returns the list of properties describing the CompositeProperty.
const std::string & getRendererType() const
std::string getColor() const
It gets the color encoded using two hexadecimal digits per primary-color component, in the order Red, Green, Blue, prefixed with a hash (#) sign.
GeomType
Each enumerated type is compatible with a Well-known Binary (WKB) type code.
te::map::AbstractLayer * DataSetLayerReader(te::xml::Reader &reader)
boost::shared_ptr< DataSource > DataSourcePtr
A layer resulting from a query.
virtual te::se::Style * getStyle() const
It returns the Style associated to the layer.
virtual const std::string & getType() const =0
It returns the layer type.
te::dt::Property * GetProperty(const QString &propertyType)
virtual const te::gm::Envelope & getExtent() const
It returns the Layer extent (or minimum bounding box).
const TreeItemPtr & getChild(std::size_t i) const
It returns the n-th child.
te::map::AbstractLayer * RasterLayerReader(te::xml::Reader &reader)
const size_t getPrecision() const
It gets the precision used for the property values.
std::string ReadLayerVisibility(te::xml::Reader &reader)
const std::string & getLowerLimit() const
It gets the lower limit value of the legend item.
const te::color::RGBAColor & getColor(std::size_t i) const
void FolderLayerWriter(const te::map::AbstractLayer *layer, te::xml::Writer &writer)
virtual void writeElement(const std::string &qName, const std::string &value)
void WriteLayerGrouping(te::map::Grouping *g, te::xml::Writer &writer)
virtual void writeValue(const std::string &value)
virtual void setVisibility(Visibility v)
It sets the layer visibility.
A class that models the description of a dataset.
DataSetType * getResult() const
void setDataSourceId(const std::string &id)
const std::vector< te::se::Symbolizer * > & getSymbolizers() const
It gets the symbolizer of the legend item.
void WriteAbstractLayer(const te::map::AbstractLayer *layer, te::xml::Writer &writer)
void add(te::dt::Property *p)
It adds a property to the list of properties of the primary key.
std::auto_ptr< te::map::Chart > ReadLayerChart(te::xml::Reader &reader)
void write(const te::map::AbstractLayer *alayer, te::xml::Writer &writer) const
void setRendererType(const std::string &t)
This class represents the informations needed to build map charts.
te::map::Visibility GetVisibility(const std::string &visible)
A layer with reference to a DataSetTypeConverter.
const Envelope * getMBR() const
It returns the minimum bounding rectangle for the geometry in an internal representation.
The type for arbitrary precison numbers, like numeric(p, q).
boost::intrusive_ptr< AbstractLayer > AbstractLayerPtr
A layer with reference to a raster.
std::string getTitle()
It gets the title of the legend item.
virtual Visibility getVisibility() const
It returns the layer visibility.
te::map::AbstractLayer * FolderLayerReader(te::xml::Reader &reader)
static Symbolizer & getInstance()
It returns a reference to the singleton instance.
std::auto_ptr< te::da::DataSet > getData(te::common::TraverseType travType=te::common::FORWARDONLY, const te::common::AccessPolicy accessPolicy=te::common::RAccess) const
It gets the dataset identified by the layer name.
virtual NodeType getNodeType() const =0
It return the type of node read.
TEGEOMEXPORT void SaveExtent(const te::gm::Envelope &e, te::xml::Writer &writer)
An Envelope defines a 2D rectangular region.
te::da::DataSetTypeConverter * getConverter() const
It returns the DataSetTypeConverter.
std::string getConverterName(std::size_t propertyPos)
This method tells which Attribute Converter was used in the porperty position.
virtual std::string getElementLocalName() const =0
It returns the local part of the element name in the case of an element node.
std::size_t getHeight() const
double getMaxValue() const
virtual int getSRID() const
It returns the Spatial Reference System ID associated to the Layer.
te::da::Select * getQuery() const
void WriteOGRAbstractLayer(const te::map::AbstractLayer *layer, te::xml::Writer &writer)
const std::string & getUpperLimit() const
It gets the upper limit value of the legend item.
virtual boost::int32_t getAttrAsInt32(const std::string &name) const
It returns the attribute value in the case of an element node with valid attributes.
const std::vector< std::vector< std::size_t > > & getConvertedPropertyIndexes() const
const std::vector< te::map::GroupingItem * > & getGroupingItems() const
It gets the vector of grouping items.
virtual const std::string & getId() const
It returns the layer id.
const std::string & getRendererType() const
std::size_t getBarWidth() const
void Union(const Envelope &rhs)
It updates the envelop with coordinates of another envelope.
boost::function< void(const te::map::AbstractLayer *, te::xml::Writer &)> LayerWriteFnctType
virtual void setStyle(te::se::Style *style)
It sets the Style associated to the layer.
void DataSetLayerWriter(const te::map::AbstractLayer *layer, te::xml::Writer &writer)
DataSetType * getConvertee()
This method returns the pointer to the DataSetType that is handled by the converter.
void reg(const std::string &layerType, const LayerFnctSerializeType &fncts)
virtual std::string getAttr(const std::string &name) const =0
It returns the attribute value in the case of an element node with valid attributes.
This class models a XML writer object.
const GroupingType getType() const
It gets the grouping type.
void setConverter(std::auto_ptr< te::da::DataSetTypeConverter > converter)
It sets the converter that will be used by the layer.
A GroupingItem contains information about a grouping item associated to a layer.