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,
93 for(
size_t i = 0; i < fields->size(); ++i)
100 std::vector<std::string> tokens;
103 assert(tokens.size() == 2);
107 for(
size_t j = 0; j < from->size(); ++j)
115 assert(!name.empty());
117 std::auto_ptr<te::da::DataSetType> dt = ds->getDataSetType(name);
122 std::auto_ptr<te::dt::Property> p(pRef->
clone());
125 output->add(p.release());
134 return getData(m_query, travType, accessPolicy);
156 std::auto_ptr<te::da::Select> select(static_cast<te::da::Select*>(m_query->clone()));
185 return getData(select.get(), travType, accessPolicy);
194 throw Exception(
"Not implemented yet!");
202 std::auto_ptr<te::da::Select> select(static_cast<te::da::Select*>(m_query->clone()));
214 return getData(select.get(), travType, accessPolicy);
222 std::auto_ptr<te::da::Select> select(static_cast<te::da::Select*>(m_query->clone()));
234 return getData(select.get(), travType, accessPolicy);
242 if(m_datasourceId.empty())
255 if(ds.get() == 0 || !ds->isValid() || !ds->isOpened())
263 if(m_rendererType.empty())
264 throw Exception((boost::format(
TE_TR(
"Could not draw the query layer %1%. The renderer type is empty!")) % getTitle()).str());
268 if(renderer.get() == 0)
269 throw Exception((boost::format(
TE_TR(
"Could not draw the query layer %1%. The renderer %2% could not be created!")) % getTitle() % m_rendererType).str());
271 renderer->draw(
this, canvas, bbox, srid);
293 return m_datasourceId;
303 return m_rendererType;
320 std::auto_ptr<te::da::DataSet> dataset(ds->query(m_query));
321 assert(dataset.get());
333 return ds->query(query, travType, accessPolicy);
TEDATAACCESSEXPORT DataSourcePtr GetDataSource(const std::string &datasourceId, const bool opened=true)
Search for a data source with the informed id in the DataSourceManager.
const std::string & getName() const
It returns the property name.
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...
Spatial intersects operator.
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
Expression * getExpression(const std::string source="") 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.
A class that models the description of a dataset.
static const std::string sm_ST_Intersects
std::auto_ptr< LayerSchema > getSchema() const
It returns the layer schema.
Expression * getExpression() const
It returns the expression set for an output select query.
An abstract factory for layer renderers.
virtual Property * clone() const =0
It returns a clone of the object.
SpatialRelation
Spatial relations between geometric objects.
QueryLayer(AbstractLayer *parent=0)
It initializes a new layer.
A class that represents the known capabilities of a specific data source, i.e. this class informs all...
#define TE_TR(message)
It marks a string in order to get translated.
const QueryCapabilities & getQueryCapabilities() const
It models a property definition.
Boolean logic operator: AND.
This is an abstract class that models a query expression.
AccessPolicy
Supported data access policies (can be used as bitfield).
TraverseType
A dataset can be traversed in two ways:
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.
void setRendererType(const std::string &t)
A class that informs the query support of a given data source.
An operator that considers the intersection among approximations or envelopes of geometries.
An Envelope defines a 2D rectangular region.
const std::string & getAlias() const
It returns the alias associated to the source item.
This class represents a set of unique ids created in the same context. i.e. from the same data set...
boost::ptr_vector< Field > Fields
Fields is just a boost::ptr_vector of Field pointers.
const std::string & getDataSourceId() const
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
void setExp(Expression *exp)
Sets the expression.
Expression * getExp() const
te::da::Select * getQuery() 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.
const std::set< std::string > & getSpatialTopologicOperators() const
boost::ptr_vector< FromItem > From
It models the FROM clause for a query.
A canvas is an abstraction of a drawing area.
void setDataSourceId(const std::string &id)
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. ...
void setQuery(te::da::Select *s)
A layer resulting from a query.
A class that models a literal for Envelope values.
const std::string & getRendererType() const
const std::string & getName() const
It returns the dataset name.
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.
virtual Expression * clone() const =0
It creates a new copy of this expression.
TEDATAACCESSEXPORT std::size_t GetFirstPropertyPos(const te::da::DataSet *dataset, int datatype)
static const std::string sm_type
A static data member used in the implementation of getType method.
const std::string & getType() const
It returns the layer type: QUERY_LAYER.
bool isValid() const
It returns true if the layer can be used for instance to draw, otherwise, it returns false...