27 #include "../common/StringUtils.h"
28 #include "../dataaccess/dataset/ObjectIdSet.h"
29 #include "../dataaccess/datasource/DataSource.h"
30 #include "../dataaccess/datasource/DataSourceCapabilities.h"
31 #include "../dataaccess/query/And.h"
32 #include "../dataaccess/query/DataSetName.h"
33 #include "../dataaccess/query/Expression.h"
34 #include "../dataaccess/query/Field.h"
35 #include "../dataaccess/query/Function.h"
36 #include "../dataaccess/query/FunctionNames.h"
37 #include "../dataaccess/query/FromItem.h"
38 #include "../dataaccess/query/LiteralEnvelope.h"
39 #include "../dataaccess/query/PropertyName.h"
40 #include "../dataaccess/query/Select.h"
41 #include "../dataaccess/query/ST_Intersects.h"
42 #include "../dataaccess/query/ST_EnvelopeIntersects.h"
43 #include "../dataaccess/query/Where.h"
44 #include "../dataaccess/utils/Utils.h"
45 #include "../datatype/Property.h"
46 #include "../geometry/GeometryProperty.h"
52 #include <boost/format.hpp>
72 const std::string& title,
92 for(
size_t i = 0; i < fields->size(); ++i)
99 std::vector<std::string> tokens;
102 assert(tokens.size() == 2);
104 std::auto_ptr<te::da::DataSetType> dt = ds->getDataSetType(tokens[0]);
109 std::auto_ptr<te::dt::Property> p(pRef->
clone());
112 output->add(p.release());
121 return getData(m_query, travType, accessPolicy);
143 std::auto_ptr<te::da::Select> select(static_cast<te::da::Select*>(m_query->clone()));
175 return getData(select.get(), travType, accessPolicy);
184 throw Exception(
"Not implemented yet!");
192 std::auto_ptr<te::da::Select> select(static_cast<te::da::Select*>(m_query->clone()));
204 return getData(select.get(), travType, accessPolicy);
212 std::auto_ptr<te::da::Select> select(static_cast<te::da::Select*>(m_query->clone()));
224 return getData(select.get(), travType, accessPolicy);
232 if(m_datasourceId.empty())
245 if(ds.get() == 0 || !ds->isValid() || !ds->isOpened())
253 if(m_rendererType.empty())
254 throw Exception((boost::format(
TR_MAP(
"Could not draw the query layer %1%. The renderer type is empty!")) % getTitle()).str());
258 if(renderer.get() == 0)
259 throw Exception((boost::format(
TR_MAP(
"Could not draw the query layer %1%. The renderer %2% could not be created!")) % getTitle() % m_rendererType).str());
261 renderer->draw(
this, canvas, bbox, srid);
283 return m_datasourceId;
293 return m_rendererType;
310 std::auto_ptr<te::da::DataSet> dataset(ds->query(m_query));
311 assert(dataset.get());
323 return ds->query(query, travType, accessPolicy);
const std::string & getDataSourceId() const
static const std::string sm_ST_Intersects
bool isValid() const
It returns true if the layer can be used for instance to draw, otherwise, it returns false...
This class represents a set of unique ids created in the same context. i.e. from the same data set...
Expression * getExpression() const
It returns the expression set for an output select query.
TEDATAACCESSEXPORT DataSourcePtr GetDataSource(const std::string &datasourceId, const bool opened=true)
Search for a data source with the informed id in the DataSourceManager.
This is the base class for layers.
std::auto_ptr< LayerSchema > getSchema() const
It returns the layer schema.
A Select models a query to be used when retrieving data from a DataSource.
A canvas is an abstraction of a drawing area.
const std::string & getName() const
It returns the property name.
Spatial intersects operator.
The Field class can be used to model an expression that takes part of the output items of a SELECT...
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. ...
const QueryCapabilities & getQueryCapabilities() const
virtual Expression * clone() const =0
It creates a new copy of this expression.
Expression * getExpression() const
It returns the expression that can be used to retrieve the data set that contains the all indentified...
A class that models the name of any property of an object.
An operator that considers the intersection among approximations or envelopes of geometries.
A class that represents the known capabilities of a specific data source, i.e. this class informs all...
A layer resulting from a query.
SpatialRelation
Spatial relations between geometric objects.
static AbstractRenderer * make(const std::string &factoryKey)
It creates an object with the appropriated factory.
const std::string & getRendererType() const
boost::ptr_vector< Field > Fields
Fields is just a boost::ptr_vector of Field pointers.
AccessPolicy
Supported data access policies (can be used as bitfield).
Boolean logic operator: AND.
void setDataSourceId(const std::string &id)
An exception class for the MapTools module.
const std::set< std::string > & getSpatialTopologicOperators() const
Geometry is the root class of the geometries hierarchy, it follows OGC and ISO standards.
static const std::string sm_type
A static data member used in the implementation of getType method.
TEDATAACCESSEXPORT std::size_t GetFirstPropertyPos(const te::da::DataSet *dataset, int datatype)
A class that informs the query support of a given data source.
A class that models a literal for Envelope values.
boost::shared_ptr< DataSource > DataSourcePtr
void Tokenize(const std::string &str, std::vector< std::string > &tokens, const std::string &delimiters=" ")
It tokenizes a given string with a delimiter of your own choice.
TraverseType
A dataset can be traversed in two ways:
#define TR_MAP(message)
It marks a string in order to get translated. This is a special mark used in the Map Rendering module...
A class that models the description of a dataset.
An abstract factory for layer renderers.
Expression * getExp() const
void setRendererType(const std::string &t)
It models a property definition.
This is an abstract class that models a query expression.
An Envelope defines a 2D rectangular region.
A class that can be used to model a filter expression that can be applied to a query.
static const std::string sm_ST_EnvelopeIntersects
te::da::Select * getQuery() const
QueryLayer(AbstractLayer *parent=0)
It initializes a new layer.
virtual Property * clone() const =0
It returns a clone of the object.
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.
void setQuery(te::da::Select *s)
const std::string & getType() const
It returns the layer type: QUERY_LAYER.
void setExp(Expression *exp)
Sets the expression.