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(
TE_TR(
"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())
82 layer->setExtent(*mbr);
85 else if(dataset->hasRaster())
89 layer->setSRID(grid->
getSRID());
104 static boost::uuids::basic_random_generator<boost::mt19937> gen;
106 if(dataset.get() == 0)
107 throw Exception(
TE_TR(
"Can not convert a NULL dataset to a layer!"));
109 boost::uuids::uuid u = gen();
110 std::string
id = boost::uuids::to_string(u);
112 std::string title = dataset->getTitle().empty() ? dataset->getName() : dataset->getTitle();
115 layer->setDataSetName(dataset->getName());
116 layer->setDataSourceId(m_datasourceId);
118 layer->setRendererType(
"ABSTRACT_LAYER_RENDERER");
120 if(dataset->size() == 0)
126 if(dataset->hasGeom())
129 geomPropertyName.empty() ? gp =
te::da::GetFirstGeomProperty(dataset.get()) : gp = dynamic_cast<te::gm::GeometryProperty*>(dataset->getProperty(geomPropertyName));
136 layer->setExtent(*mbr);
138 layer->setGeomPropertytName(geomPropertyName);
140 else if(dataset->hasRaster())
143 geomPropertyName.empty() ? rp =
te::da::GetFirstRasterProperty(dataset.get()) : rp = dynamic_cast<te::rst::RasterProperty*>(dataset->getProperty(geomPropertyName));
152 layer->setGeomPropertytName(geomPropertyName);
TEDATAACCESSEXPORT te::rst::RasterProperty * GetFirstRasterProperty(const DataSetType *dt)
TEDATAACCESSEXPORT te::gm::Envelope * GetExtent(const std::string &datasetName, const std::string &propertyName, const std::string &datasourceId)
TEDATAACCESSEXPORT void LoadProperties(te::da::DataSetType *dataset, const std::string &datasourceId)
boost::shared_ptr< DataSetType > DataSetTypePtr
boost::shared_ptr< DataSource > DataSourcePtr
int getSRID() const
Returns the grid spatial reference system identifier.
TESEEXPORT Style * CreateCoverageStyle(const std::vector< te::rst::BandProperty * > &properties)
Try creates an appropriate coverage style based on given band properties.
#define TE_TR(message)
It marks a string in order to get translated.
TESEEXPORT Style * CreateFeatureTypeStyle(const te::gm::GeomType &geomType)
Try creates an appropriate feature type style based on given geometry type.
int getSRID() const
It returns the spatial reference system identifier associated to this property.
static DataSourceManager & getInstance()
It returns a reference to the singleton instance.
#define TE_UNKNOWN_SRS
A numeric value to represent a unknown SRS identification in TerraLib.
GeomType getGeometryType() const
It returns the geometry subtype allowed for the property.
te::rst::Grid * getGrid()
Returns the definition of the raster grid support.
boost::intrusive_ptr< DataSetLayer > DataSetLayerPtr
te::gm::Envelope * getExtent()
Returns the geographic extension of the grid.
A layer with reference to a dataset.
void setSRID(int srid)
Just sets the grid spatial reference system identifier.
TEDATAACCESSEXPORT te::gm::GeometryProperty * GetFirstGeomProperty(const DataSetType *dt)
A rectified grid is the spatial support for raster data.
const std::string & getName() const
It returns the property name.