27 #include "../common/Translator.h"
28 #include "../dataaccess/dataset/DataSetAdapter.h"
29 #include "../dataaccess/dataset/DataSetTypeConverter.h"
30 #include "../dataaccess/dataset/FilteredDataSet.h"
31 #include "../dataaccess/query/DataSetName.h"
32 #include "../dataaccess/query/Field.h"
33 #include "../dataaccess/query/Fields.h"
34 #include "../dataaccess/query/From.h"
35 #include "../dataaccess/query/FromItem.h"
36 #include "../dataaccess/query/Select.h"
37 #include "../dataaccess/query/Where.h"
38 #include "../dataaccess/utils/Utils.h"
44 #include <boost/format.hpp>
62 const std::string& title,
75 std::auto_ptr<te::da::DataSetType> type;
76 type.reset(dynamic_cast<te::da::DataSetType*>(m_converter->getResult()->clone()));
83 assert(!m_datasetName.empty());
84 std::auto_ptr<te::da::DataSet> inputData, outputDataSet;
88 inputData = ds->getDataSet(m_datasetName, travType, accessPolicy);
100 assert(!m_datasetName.empty());
104 std::auto_ptr<te::da::DataSetType> dsType = ds->getDataSetType(m_datasetName);
107 std::auto_ptr<te::da::DataSet> inputData = ds->getDataSet(m_datasetName, travType, accessPolicy);
110 std::auto_ptr<te::da::DataSet> adaptedDataSet;
113 std::vector<std::size_t> positions;
115 m_rtree.search(*(e), positions);
117 adaptedDataSet->moveBeforeFirst();
130 assert(!m_datasetName.empty());
131 std::auto_ptr<te::da::DataSet> inputData, outputDataSet;
135 inputData = ds->getDataSet(m_datasetName, propertyName, g, r, travType, accessPolicy);
138 return outputDataSet;
145 assert(!m_datasetName.empty());
146 std::auto_ptr<te::da::DataSet> inputData, outputDataSet;
160 from->push_back(fromItem);
163 std::auto_ptr<te::da::Select> select(
new te::da::Select(all, from, filter));
165 inputData = ds->query(select.get(), travType, accessPolicy);
168 return outputDataSet;
176 std::auto_ptr<te::da::DataSet> inputData, outputDataSet;
180 inputData = ds->getDataSet(m_datasetName, oids, travType, accessPolicy);
183 return outputDataSet;
188 if(m_datasourceId.empty() || m_datasetName.empty())
191 if(m_converter.get() == 0)
204 if(ds.get() == 0 || !ds->isValid() || !ds->isOpened())
212 if(m_rendererType.empty())
213 throw Exception((boost::format(
TE_TR(
"Could not draw the data set layer %1%. The renderer type is empty!")) % getTitle()).str());
215 std::auto_ptr<te::da::DataSetType> dsType = getSchema();
217 if(!dsType->hasGeom())
222 if(renderer.get() == 0)
223 throw Exception((boost::format(
TE_TR(
"Could not draw the data set layer %1%. The renderer %2% could not be created!")) % getTitle() % m_rendererType).str());
225 renderer->draw(
this, canvas, bbox, srid);
230 return m_converter.get();
235 m_converter = converter;
239 std::auto_ptr<te::da::DataSetType> dsType = ds->getDataSetType(m_datasetName);
241 if(m_converter->getResult()->hasGeom())
246 std::auto_ptr<te::da::DataSet> inputData = ds->getDataSet(m_datasetName);
249 std::auto_ptr<te::da::DataSet> adaptedDataSet;
256 while(adaptedDataSet->moveNext())
258 std::auto_ptr<te::gm::Geometry> geom(adaptedDataSet->getGeometry(geomPropPos));
263 m_rtree.insert(env, pos);
277 return m_datasetName;
282 m_datasetName = name;
287 return m_datasourceId;
297 return m_rendererType;
TEDATAACCESSEXPORT DataSourcePtr GetDataSource(const std::string &datasourceId, const bool opened=true)
Search for a data source with the informed id in the DataSourceManager.
bool isValid() const
It returns true if the layer can be used for instance to draw, otherwise, it returns false...
DataSetAdapterLayer(AbstractLayer *parent=0)
It initializes a new layer.
An abstract class that models a source of data in a query.
The Field class can be used to model an expression that takes part of the output items of a SELECT...
This is the base class for layers.
A class that models the name of a dataset used in a From clause.
boost::shared_ptr< DataSource > DataSourcePtr
An abstract factory for layer renderers.
te::da::DataSetTypeConverter * getConverter() const
It returns the DataSetTypeConverter.
SpatialRelation
Spatial relations between geometric objects.
static const std::string sm_type
A static data member used in the implementation of getType method.
#define TE_TR(message)
It marks a string in order to get translated.
~DataSetAdapterLayer()
Destructor.
void setDataSourceId(const std::string &id)
This is an abstract class that models a query expression.
void setConverter(std::auto_ptr< te::da::DataSetTypeConverter > converter)
It sets the converter that will be used by the layer.
An converter for DataSetType.
const std::string & getRendererType() const
AccessPolicy
Supported data access policies (can be used as bitfield).
TraverseType
A dataset can be traversed in two ways:
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.
TEDATAACCESSEXPORT std::size_t GetFirstSpatialPropertyPos(const te::da::DataSet *dataset)
It returns the first dataset spatial property or NULL if none is found.
An Envelope defines a 2D rectangular region.
This class represents a set of unique ids created in the same context. i.e. from the same data set...
const std::string & getType() const
It returns the layer type: DATASET_LAYER.
const std::string & getDataSourceId() const
boost::ptr_vector< Field > Fields
Fields is just a boost::ptr_vector of Field pointers.
A class that can be used to model a filter expression that can be applied to a query.
void setRendererType(const std::string &t)
void setDataSetName(const std::string &name)
const std::string & getDataSetName() const
Geometry is the root class of the geometries hierarchy, it follows OGC and ISO standards.
static AbstractRenderer * make(const std::string &factoryKey)
It creates an object with the appropriated factory.
A Select models a query to be used when retrieving data from a DataSource.
A layer with reference to a DataSetTypeConverter.
This class represents a filtered data set.
boost::ptr_vector< FromItem > From
It models the FROM clause for a query.
A canvas is an abstraction of a drawing area.
std::auto_ptr< LayerSchema > getSchema() const
It returns the layer schema.
void draw(Canvas *canvas, const te::gm::Envelope &bbox, int srid)
It draws the layer geographic objects in the given canvas using the informed SRS. ...
TEDATAACCESSEXPORT DataSetAdapter * CreateAdapter(DataSet *ds, DataSetTypeConverter *converter, bool isOwner=false)