27 #include "../../../../common/Translator.h"
28 #include "../../../../dataaccess/dataset/DataSetType.h"
29 #include "../../../../dataaccess/datasource/DataSourceManager.h"
30 #include "../../../../dataaccess/datasource/DataSourceTransactor.h"
31 #include "../../../../dataaccess/utils/Utils.h"
32 #include "../../../../geometry/Envelope.h"
33 #include "../../../../geometry/GeometryProperty.h"
34 #include "../../../../maptools/AbstractLayer.h"
35 #include "../../../../maptools/DataSetLayer.h"
36 #include "../../../../raster/Grid.h"
37 #include "../../../../raster/RasterProperty.h"
38 #include "../../../../se/Utils.h"
39 #include "../../../../srs/Config.h"
40 #include "../../Exception.h"
44 #include <boost/uuid/random_generator.hpp>
45 #include <boost/uuid/uuid_io.hpp>
48 : m_datasourceId(datasourceId)
54 static boost::uuids::basic_random_generator<boost::mt19937> gen;
56 if(dataset.get() == 0)
57 throw Exception(
TR_QT_WIDGETS(
"Can not convert a NULL dataset to a layer!"));
59 boost::uuids::uuid u = gen();
60 std::string
id = boost::uuids::to_string(u);
62 std::string title = dataset->getTitle().empty() ? dataset->getName() : dataset->getTitle();
65 layer->setDataSetName(dataset->getName());
66 layer->setDataSourceId(m_datasourceId);
68 layer->setRendererType(
"ABSTRACT_LAYER_RENDERER");
70 if(dataset->size() == 0)
76 if(dataset->hasGeom())
81 layer->setExtent(*mbr);
84 else if(dataset->hasRaster())
88 layer->setSRID(grid->
getSRID());
A layer with reference to a dataset.
TEDATAACCESSEXPORT te::rst::RasterProperty * GetFirstRasterProperty(const DataSetType *dt)
TEDATAACCESSEXPORT te::gm::GeometryProperty * GetFirstGeomProperty(const DataSetType *dt)
int getSRID() const
It returns the spatial reference system identifier associated to this property.
const std::string & getName() const
It returns the property name.
#define TE_UNKNOWN_SRS
A numeric value to represent a unknown SRS identification in TerraLib.
TEDATAACCESSEXPORT te::gm::Envelope * GetExtent(const std::string &datasetName, const std::string &propertyName, const std::string &datasourceId)
TESEEXPORT Style * CreateFeatureTypeStyle(const te::gm::GeomType &geomType)
Try creates an appropriate feature type style based on given geometry type.
GeomType getGeometryType() const
It returns the geometry subtype allowed for the property.
A rectified grid is the spatial support for raster data.
te::gm::Envelope * getExtent()
Returns the geographic extension of the grid.
TESEEXPORT Style * CreateCoverageStyle(const std::vector< te::rst::BandProperty * > &properties)
Try creates an appropriate coverage style based on given band properties.
DataSet2Layer(const std::string &datasourceId)
boost::shared_ptr< DataSource > DataSourcePtr
boost::intrusive_ptr< DataSetLayer > DataSetLayerPtr
#define TR_QT_WIDGETS(message)
It marks a string in order to get translated. This is a special mark used in the TerraLib Qt Widgets ...
boost::shared_ptr< DataSetType > DataSetTypePtr
TEDATAACCESSEXPORT void LoadProperties(te::da::DataSetType *dataset, const std::string &datasourceId)
int getSRID() const
Returns the grid spatial reference system identifier.
static DataSourceManager & getInstance()
It returns a reference to the singleton instance.
te::map::DataSetLayerPtr operator()(const te::da::DataSetTypePtr &dataset) const