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/SQLVisitor.h" 44 #include "../dataaccess/query/ST_Intersects.h" 45 #include "../dataaccess/query/ST_EnvelopeIntersects.h" 46 #include "../dataaccess/query/Where.h" 47 #include "../dataaccess/utils/Utils.h" 48 #include "../datatype/Property.h" 49 #include "../geometry/GeometryProperty.h" 56 #include <boost/format.hpp> 76 const std::string& title,
114 for(
size_t i = 0; i < fields->size(); ++i)
121 std::vector<std::string> tokens;
124 assert(tokens.size() == 2);
128 for(
size_t j = 0; j < from->size(); ++j)
132 if(dsName !=
nullptr)
155 assert(!name.empty());
157 std::unique_ptr<te::da::DataSetType> input = ds->getDataSetType(name);
164 p->
setId(static_cast<unsigned int>(i));
167 if(input->getPrimaryKey() !=
nullptr){
168 if (input->getPrimaryKey()->has(pRef) )
179 output->setPrimaryKey(outKey);
208 std::unique_ptr<te::da::Select>
select(static_cast<te::da::Select*>(
m_query->
clone()));
251 select->setWhere(wh);
254 return getData(select.get(), travType, accessPolicy);
270 std::unique_ptr<te::da::Select>
select(static_cast<te::da::Select*>(
m_query->
clone()));
287 select->setWhere(wh);
290 return getData(select.get(), travType, accessPolicy);
298 std::unique_ptr<te::da::Select>
select(static_cast<te::da::Select*>(
m_query->
clone()));
315 select->setWhere(wh);
318 return getData(select.get(), travType, accessPolicy);
339 if(ds.get() ==
nullptr || !ds->isValid() || !ds->isOpened())
348 throw Exception((boost::format(
TE_TR(
"Could not draw the query layer %1%. The renderer type is empty!")) %
getTitle()).str());
352 if(renderer.get() ==
nullptr)
355 renderer->draw(
this, canvas, bbox, srid, scale, cancel);
415 std::unique_ptr<te::da::DataSet> dataset;
419 assert(dataset.get());
431 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.
std::unique_ptr< LayerSchema > getSchema() const
It returns the layer schema.
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...
te::da::Select * m_query
The dataset name where we will retrieve the layer objects.
TEMAPEXPORT void CopyAbstractLayerInfo(const te::map::AbstractLayer *refLayer, te::map::AbstractLayer *layer)
Make a copy of refLayer abstract attributes to layer. Creating new id.
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
virtual const std::string & getTitle() const
It returns the layer title.
A class that models the name of any property of an object.
Base exception class for plugin module.
A class that models the description of a dataset.
static const std::string sm_ST_Intersects
Expression * getExpression() const
It returns the expression set for an output select query.
virtual Expression * clone() const =0
It creates a new copy of this expression.
An abstract factory for layer renderers.
SpatialRelation
Spatial relations between geometric objects.
QueryLayer(AbstractLayer *parent=0)
It initializes a new layer.
AbstractLayer * clone()
It returns a clone of the object.
A class that represents the known capabilities of a specific data source, i.e. this class informs all...
virtual ReturnType accept(VisitorType &guest) const =0
It call the visit method from the guest object.
A layer resulting from a query.
static te::dt::Date ds(2010, 01, 01)
#define TE_TR(message)
It marks a string in order to get translated.
virtual Property * clone() const =0
It returns a clone of the object.
const QueryCapabilities & getQueryCapabilities() const
void setDatasetName(const std::string &dsName)
It sets the property name.
It models a property definition.
Boolean logic operator: AND.
const From * getFrom() const
It returns the list of source information to be used by the query.
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.
int m_srid
The identifier of the layer spatial reference system.
void setId(unsigned int id)
It sets the property identifier.
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)
void setName(const std::string &name)
It sets the property name.
A class that informs the query support of a given data source.
std::unique_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.
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.
te::gm::Envelope m_mbr
The layer bounding box.
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
const Fields * getFields() const
It returns the list of output expressions used to form the result set.
A Join clause combines two FromItems.
Query * clone() const
It creates a new copy of this query.
Utility functions for the data access module.
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
void draw(Canvas *canvas, const te::gm::Envelope &bbox, int srid, const double &scale, bool *cancel)
It draws the layer geographic objects in the given canvas using the informed SRS. ...
boost::ptr_vector< FromItem > From
It models the FROM clause for a query.
virtual void select(te::da::ObjectIdSet *oids)
It adds the given oids to the selected group of this Layer.
FromItem * getSecond() const
It returns the second item involved in the join.
std::string getQueryAsString() const
A canvas is an abstraction of a drawing area.
void setQuery(te::da::Select *s)
std::string m_datasourceId
DataSource id.
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.
A visitor for building an SQL statement from a given Query hierarchy.
std::string m_rendererType
A pointer to the internal renderer used to paint this layer.
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 tells if the rectangle is valid or not.
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.