27 #include "../common/StringUtils.h"
28 #include "../dataaccess/dataset/ObjectIdSet.h"
29 #include "../dataaccess/dataset/PrimaryKey.h"
30 #include "../dataaccess/datasource/DataSource.h"
31 #include "../dataaccess/datasource/DataSourceCapabilities.h"
32 #include "../dataaccess/query/And.h"
33 #include "../dataaccess/query/DataSetName.h"
34 #include "../dataaccess/query/Expression.h"
35 #include "../dataaccess/query/Field.h"
36 #include "../dataaccess/query/Function.h"
37 #include "../dataaccess/query/FunctionNames.h"
38 #include "../dataaccess/query/FromItem.h"
39 #include "../dataaccess/query/Join.h"
40 #include "../dataaccess/query/LiteralEnvelope.h"
41 #include "../dataaccess/query/PropertyName.h"
42 #include "../dataaccess/query/Select.h"
43 #include "../dataaccess/query/ST_Intersects.h"
44 #include "../dataaccess/query/ST_EnvelopeIntersects.h"
45 #include "../dataaccess/query/Where.h"
46 #include "../dataaccess/utils/Utils.h"
47 #include "../datatype/Property.h"
48 #include "../geometry/GeometryProperty.h"
54 #include <boost/format.hpp>
74 const std::string& title,
97 for(
size_t i = 0; i < fields->size(); ++i)
104 std::vector<std::string> tokens;
107 assert(tokens.size() == 2);
111 for(
size_t j = 0; j < from->size(); ++j)
138 assert(!name.empty());
140 std::auto_ptr<te::da::DataSetType> input = ds->getDataSetType(name);
145 std::auto_ptr<te::dt::Property> p(pRef->
clone());
146 p->setDatasetName(name);
147 output->add(p.release());
149 if(input->getPrimaryKey()->has(pRef))
150 outKey->
add(output->getProperty(pRef->
getName()));
154 output->setPrimaryKey(outKey);
162 return getData(m_query, travType, accessPolicy);
184 std::auto_ptr<te::da::Select> select(static_cast<te::da::Select*>(m_query->clone()));
227 select->setWhere(wh);
230 return getData(select.get(), travType, accessPolicy);
239 throw Exception(
"Not implemented yet!");
247 std::auto_ptr<te::da::Select> select(static_cast<te::da::Select*>(m_query->clone()));
264 select->setWhere(wh);
267 return getData(select.get(), travType, accessPolicy);
275 std::auto_ptr<te::da::Select> select(static_cast<te::da::Select*>(m_query->clone()));
292 select->setWhere(wh);
295 return getData(select.get(), travType, accessPolicy);
303 if(m_datasourceId.empty())
316 if(ds.get() == 0 || !ds->isValid() || !ds->isOpened())
324 if(m_rendererType.empty())
325 throw Exception((boost::format(
TE_TR(
"Could not draw the query layer %1%. The renderer type is empty!")) % getTitle()).str());
329 if(renderer.get() == 0)
330 throw Exception((boost::format(
TE_TR(
"Could not draw the query layer %1%. The renderer %2% could not be created!")) % getTitle() % m_rendererType).str());
332 renderer->draw(
this, canvas, bbox, srid);
354 return m_datasourceId;
364 return m_rendererType;
380 std::auto_ptr<te::da::DataSet> dataset;
383 dataset = ds->query(m_query);
384 assert(dataset.get());
396 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.
void add(te::dt::Property *p)
It adds a property to the list of properties of the primary key.
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
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.
const std::vector< te::dt::Property * > & getProperties() const
It returns the properties that take part of the primary key.
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
A Join clause combines two FromItems.
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.
FromItem * getSecond() const
It returns the second item involved in the join.
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)
It describes a primary key (pk) constraint.
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.
Expression * getExpression() const
It returns the expression that can be used to retrieve the data set that contains the all indentified...
bool isValid() const
It returns true if the layer can be used for instance to draw, otherwise, it returns false...
FromItem * getFirst() const
It returns the first from item involved in the join.
const std::string & getName() const
It returns the property name.