27 #include "../../../common/BoostUtils.h" 28 #include "../../../core/translator/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/AbstractWriter.h" 46 #include "../../../xml/Reader.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/QueryLayer.h" 54 #include "../../../maptools/RasterLayer.h" 55 #include "../../../maptools/RasterContrast.h" 56 #include "../../../se/RasterSymbolizer.h" 57 #include "../../../se/serialization/xml/Style.h" 58 #include "../../../se/serialization/xml/Symbolizer.h" 59 #include "../../Exception.h" 68 #include <boost/algorithm/string/case_conv.hpp> 69 #include <boost/format.hpp> 70 #include <boost/lexical_cast.hpp> 131 simpleProperty =
nullptr;
136 return simpleProperty;
148 LayerFnctIdxType::const_iterator it =
m_fncts.find(layerType);
151 throw Exception((boost::format(
TE_TR(
"Could not find a reader for the following layer type: %1%.")) % layerType).str());
153 assert(it->second.second);
155 return it->second.first(reader);
162 LayerFnctIdxType::const_iterator it =
m_fncts.find(alayer->
getType());
165 throw Exception((boost::format(
TE_TR(
"Could not find a writer for the following layer type: %1%.")) % alayer->
getType()).str());
167 assert(it->second.second);
169 return it->second.second(alayer, writer);
185 std::string
id = reader.
getAttr(
"id");
198 if (!encoding.empty())
252 std::unique_ptr<te::se::Style> style;
269 std::unique_ptr<te::se::Style> selectionStyle;
291 layer->setExtent(*mbr.get());
293 layer->setDataSetName(dataset);
294 layer->setDataSourceId(datasourceId);
295 layer->setRendererType(rendererId);
296 layer->setCompositionMode(static_cast<te::map::CompositionMode>(compositionMode));
297 layer->setStyle(style.release());
298 layer->setSelectionStyle(selectionStyle.release());
299 layer->setSRID(srid);
303 layer->setGrouping(grouping);
306 layer->setChart(chart.release());
309 layer->setRasterContrast(rc.release());
311 return layer.release();
316 std::string
id = reader.
getAttr(
"id");
329 if (!encoding.empty())
392 std::unique_ptr<te::se::Style> style;
409 std::unique_ptr<te::se::Style> selectionStyle;
431 layer->setDataSetName(dataset);
432 layer->setDataSourceId(datasourceId);
433 layer->setSRID(srid);
434 layer->setExtent(*mbr.get());
436 layer->setQuery(query);
437 layer->setDataSourceId(datasourceId);
438 layer->setRendererType(rendererId);
439 layer->setCompositionMode(static_cast<te::map::CompositionMode>(compositionMode));
440 layer->setStyle(style.release());
441 layer->setSelectionStyle(selectionStyle.release());
445 layer->setGrouping(grouping);
448 layer->setChart(chart.release());
451 layer->setRasterContrast(rc.release());
453 return layer.release();
458 std::string
id = reader.
getAttr(
"id");
485 if(layer.get() ==
nullptr)
497 return flayer.release();
502 std::string
id = reader.
getAttr(
"id");
524 std::map<std::string, std::string> conninfo;
526 while(reader.
next() &&
550 conninfo[paramName] = paramValue;
590 std::unique_ptr<te::se::Style> style;
612 layer->setDataSetName(dataset);
613 layer->setDataSourceId(datasourceId);
614 layer->setSRID(srid);
615 layer->setExtent(*mbr.get());
616 layer->setRasterInfo(conninfo);
618 layer->setRendererType(rendererId);
619 layer->setCompositionMode(static_cast<te::map::CompositionMode>(compositionMode));
620 layer->setStyle(dynamic_cast<te::se::CoverageStyle*>(style.release()));
622 return layer.release();
627 std::string
id = reader.
getAttr(
"id");
677 std::unique_ptr<te::se::Style> style;
694 std::unique_ptr<te::se::Style> selectionStyle;
728 std::vector<std::pair<std::string, std::vector<std::size_t> > > props;
789 std::pair<std::string, std::vector<std::size_t> > prop;
791 std::vector<std::size_t> typeVec;
792 typeVec.push_back(static_cast<unsigned long>(type));
793 typeVec.push_back(static_cast<unsigned long>(geomType));
794 typeVec.push_back(static_cast<unsigned long>(srid));
795 prop.second = typeVec;
796 props.push_back(prop);
799 std::vector<std::vector<std::size_t> > propertyIndexes;
806 std::vector<std::size_t> inIdxs;
826 propertyIndexes.push_back(inIdxs);
831 std::vector<std::string> functionsNames;
870 std::unique_ptr<te::da::DataSetType> dst = ds->getDataSetType(dataSetName);
874 for(std::size_t i = 0; i < propertyIndexes.size(); ++i)
876 converter->add(propertyIndexes[i],
GetProperty(props[i].first, static_cast<int>(props[i].second[0]), static_cast<int>(props[i].second[1]), static_cast<int>(props[i].second[2])), functionsNames[i]);
879 std::vector<te::dt::Property*> convertedProps = converter->getResult()->getProperties();
886 std::vector<te::dt::Property*> pkProps = pkIn->
getProperties();
887 for(std::size_t i = 0; i < convertedProps.size(); ++i)
889 for(std::size_t t = 0; t < pkProps.size(); ++t)
891 if(convertedProps[i]->getName() == pkProps[t]->getName())
892 pk->
add(convertedProps[i]);
902 std::unique_ptr<te::da::DataSet> dataset = result->
getData();
908 while(dataset->moveNext())
1018 for(
size_t i=0; i<count; i++)
1030 if(layer ==
nullptr)
1038 std::map<std::string, std::string> info = layer->
getRasterInfo();
1039 std::map<std::string, std::string>::iterator conIt;
1041 for(conIt=info.begin(); conIt!=info.end(); ++conIt)
1078 if(layer ==
nullptr)
1116 std::vector<te::dt::Property*> outProps = resultDt->
getProperties();
1118 for(std::size_t i = 0; i < outProps.size(); ++i)
1122 writer.
writeElement(
"te_map:type", outProps[i]->getType());
1123 writer.
writeElement(
"te_map:name", outProps[i]->getName());
1145 for(std::size_t i = 0; i < propertyIndexes.size(); ++i)
1151 std::vector<std::size_t> inputPropertiesIdx = propertyIndexes[i];
1153 for(std::size_t j = 0; j < inputPropertiesIdx.size(); ++j)
1154 writer.
writeElement(
"te_map:InIdx", static_cast<int>(inputPropertiesIdx[j]));
1159 std::vector<te::da::AttributeConverter> converters = converter->
getConverters();
1160 for(std::size_t i = 0; i < converters.size(); ++i)
TEDATAACCESSEXPORT DataSourcePtr GetDataSource(const std::string &datasourceId, const bool opened=true)
Search for a data source with the informed id in the DataSourceManager.
TEMAPEXPORT std::string ReadLayerVisibility(te::xml::Reader &reader)
TEMAPEXPORT void WriteAbstractLayer(const te::map::AbstractLayer *layer, te::xml::AbstractWriter &writer)
virtual const std::string & getId() const
It returns the layer id.
TEMAPEXPORT te::map::RasterContrast * ReadLayerRasterContrast(te::xml::Reader &reader)
TEMAPEXPORT std::string ReadLayerEncoding(te::xml::Reader &reader)
virtual void setDataSourceId(const std::string &id)
void add(te::dt::Property *p)
It adds a property to the list of properties of the primary key.
virtual boost::int32_t getElementValueAsInt32() const
It returns the element data value in the case of VALUE node.
const std::vector< std::vector< std::size_t > > & getConvertedPropertyIndexes() const
const TreeItemPtr & getChild(std::size_t i) const
It returns the n-th child.
std::size_t getChildrenCount() const
It returns the number of children of this node.
An atomic property like an integer or double.
This class models a XML reader object.
This is the base class for layers.
virtual const te::gm::Envelope & getExtent() const
It returns the Layer extent (or minimum bounding box).
boost::shared_ptr< DataSource > DataSourcePtr
TEMAPEXPORT std::string ReadDataSourceId(te::xml::Reader &reader)
virtual const std::string & getTitle() const
It returns the layer title.
void setConverter(std::unique_ptr< te::da::DataSetTypeConverter > converter)
It sets the converter that will be used by the layer.
virtual const std::string & getType() const =0
It returns the layer type.
virtual void writeStartElement(const std::string &qName)=0
virtual te::se::Style * getSelectionStyle() const
It returns the selection Style associated to the layer.
Base exception class for plugin module.
A class that models the description of a dataset.
virtual void writeValue(const std::string &value)=0
TEMAPEXPORT std::string ReadLayerTitle(te::xml::Reader &reader)
void setDataSetName(const std::string &name)
void setCompositionMode(te::map::CompositionMode mode)
It sets the composition mode.
DataSetType * getResult() const
virtual std::string getElementLocalName() const =0
It returns the local part of the element name in the case of an element node.
te::da::DataSetTypeConverter * getConverter() const
It returns the DataSetTypeConverter.
A layer resulting from a query.
virtual Visibility getVisibility() const
It returns the layer visibility.
std::map< std::string, std::string > getRasterInfo() const
static te::dt::Date ds(2010, 01, 01)
A layer that can be used as a container for other kind of layers.
std::unique_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.
This class models a XML writer object.
#define TE_TR(message)
It marks a string in order to get translated.
virtual void setTitle(const std::string &title)
It sets the layer title.
std::string getConverterName(std::size_t propertyPos)
This method tells which Attribute Converter was used in the porperty position.
TEMAPEXPORT std::string ReadDataSetName(te::xml::Reader &reader)
void Union(const Envelope &rhs)
It updates the envelop with coordinates of another envelope.
TEMAPEXPORT te::map::Grouping * ReadLayerGrouping(te::xml::Reader &reader)
DataSetType * getConvertee()
This method returns the pointer to the DataSetType that is handled by the converter.
const std::vector< te::dt::Property * > & getProperties() const
It returns the properties that take part of the primary key.
TEMAPEXPORT int ReadSRIDValue(te::xml::Reader &reader)
An converter for DataSetType.
te::map::CompositionMode getCompositionMode() const
It returns the composition mode.
TEMAPEXPORT void WriteSRIDValue(const int &srid, te::xml::AbstractWriter &writer)
const std::vector< AttributeConverter > & getConverters() const
const std::string & getRendererType() const
This class contains the parameters needed for grouping the values of a Property.
The type for arbitrary precison numbers, like numeric(p, q).
A layer with reference to a DataSetTypeConverter.
std::pair< LayerReadFnctType, LayerWriteFnctType > LayerFnctSerializeType
virtual void writeElement(const std::string &qName, const std::string &value)=0
A layer with reference to a raster.
static std::string getEncodingName(EncodingType et)
Retrive a string from a given character encoding type enum.
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.
const std::vector< Property * > & getProperties() const
It returns the list of properties describing the CompositeProperty.
te::map::AbstractLayer * read(te::xml::Reader &reader) const
int getSRID() const
It returns the spatial reference system identifier associated to this property.
static Style & getInstance()
It returns a reference to the singleton instance.
const Envelope * getMBR() const _NOEXCEPT_OP(true)
It returns the minimum bounding rectangle for the geometry in an internal representation.
TEGEOMEXPORT std::unique_ptr< te::gm::Envelope > ReadExtent(te::xml::Reader &reader)
An Envelope defines a 2D rectangular region.
virtual te::se::Style * getStyle() const
It returns the Style associated to the layer.
GeomType getGeometryType() const
It returns the geometry subtype allowed for the property.
TEDATAACCESSEXPORT void Save(const std::string &fileName)
virtual void setVisibility(Visibility v)
It sets the layer visibility.
TEGEOMEXPORT void SaveExtent(const te::gm::Envelope &e, te::xml::AbstractWriter &writer)
void setRendererType(const std::string &t)
virtual void setExtent(const te::gm::Envelope &mbr)
It sets the Layer extent (or minimum bounding box).
te::da::Select * getQuery() const
The type for string types: FIXED_STRING, VAR_STRING or STRING.
boost::function< te::map::AbstractLayer *(te::xml::Reader &)> LayerReadFnctType
virtual void setSelectionStyle(te::se::Style *style)
It sets the selection Style associated to the layer.
Utility functions for the data access module.
Geometry is the root class of the geometries hierarchy, it follows OGC and ISO standards.
A Select models a query to be used when retrieving data from a DataSource.
TEMAPEXPORT te::map::Visibility GetVisibility(const std::string &visible)
TEMAPEXPORT std::unique_ptr< te::map::Chart > ReadLayerChart(te::xml::Reader &reader)
virtual void writeAttribute(const std::string &attName, const std::string &value)=0
const std::string & getDataSetName() const
TEDATAACCESSEXPORT te::da::Select * ReadSelect(te::xml::Reader &reader)
static te::core::EncodingType getEncodingType(const std::string &name)
Retrive an EncodingType from a given character encoding name.
virtual void setSRID(int srid)
It sets the Spatial Reference System ID associated to the Layer.
It describes a primary key (pk) constraint.
void write(const te::map::AbstractLayer *alayer, te::xml::AbstractWriter &writer) const
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.
virtual void setStyle(te::se::Style *style)
It sets the Style associated to the layer.
const std::string & getRendererType() const
virtual void writeEndElement(const std::string &qName)=0
virtual std::string getElementValue() const =0
It returns the element data value in the case of VALUE node.
virtual NodeType getNodeType() const =0
It return the type of node read.
virtual int getSRID() const
It returns the Spatial Reference System ID associated to the Layer.
A layer with reference to a dataset.
void reg(const std::string &layerType, const LayerFnctSerializeType &fncts)
TEDATAACCESSEXPORT te::gm::GeometryProperty * GetFirstGeomProperty(const DataSetType *dt)
boost::intrusive_ptr< AbstractLayer > AbstractLayerPtr
virtual bool next()=0
It gets the next event to be read.
const std::string & getRendererType() const
virtual const std::string & getDataSourceId() const
boost::function< void(const te::map::AbstractLayer *, te::xml::AbstractWriter &)> LayerWriteFnctType
const std::string & getRendererType() const
const std::string & getName() const
It returns the property name.