Loading...
Searching...
No Matches
QueryLayer.h
Go to the documentation of this file.
1/* Copyright (C) 2008 National Institute For Space Research (INPE) - Brazil.
2
3 This file is part of the TerraLib - a Framework for building GIS enabled applications.
4
5 TerraLib is free software: you can redistribute it and/or modify
6 it under the terms of the GNU Lesser General Public License as published by
7 the Free Software Foundation, either version 3 of the License,
8 or (at your option) any later version.
9
10 TerraLib is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public License
16 along with TerraLib. See COPYING. If not, write to
17 TerraLib Team at <terralib-team@terralib.org>.
18 */
19
20/*!
21 \file terralib/maptools/QueryLayer.h
22
23 \brief A layer resulting from a query.
24*/
25
26#ifndef __TERRALIB_MAPTOOLS_INTERNAL_QUERYLAYER_H
27#define __TERRALIB_MAPTOOLS_INTERNAL_QUERYLAYER_H
28
29// TerraLib
30#include "AbstractLayer.h"
31
32namespace te
33{
34// Forward declaration
35 namespace da {
36 class Select;
37 class Join;
38 }
39
40 namespace map
41 {
42 /*!
43 \class QueryLayer
44
45 \brief A layer resulting from a query.
46
47 A QueryLayer is a reference to a dataset that will result from a query to a data source.
48
49 \ingroup map
50
51 \sa AbstractLayer, DataSetLayer, RasterLayer, FolderLayer
52 */
54 {
55 public:
56
57 /*!
58 \brief It initializes a new layer.
59
60 \param parent The parent layer (NULL if it has no parent).
61 */
63
64 /*!
65 \brief It initializes a new layer.
66
67 \param id The layer id.
68 \param parent The parent layer (NULL if it has no parent).
69 */
70 QueryLayer(const std::string& id, AbstractLayer* parent = 0);
71
72 /*!
73 \brief It initializes a new layer.
74
75 \param id The layer id.
76 \param title The title is a brief description about the layer.
77 \param parent The parent layer (NULL if it has no parent).
78 */
79 QueryLayer(const std::string& id, const std::string& title, AbstractLayer* parent = 0);
80
81 /*! \brief Destructor. */
83
85
86 std::unique_ptr<LayerSchema> getSchema() const;
87
88 /* Fills internal the cached schema for the dataset */
89 void loadSchema() const;
90
91 std::unique_ptr<te::da::DataSet> getData(te::common::TraverseType travType = te::common::FORWARDONLY,
92 const te::common::AccessPolicy accessPolicy = te::common::RAccess) const;
93
94 std::unique_ptr<te::da::DataSet> getData(const std::string& propertyName,
95 const te::gm::Envelope* e,
98 const te::common::AccessPolicy accessPolicy = te::common::RAccess) const;
99
100 std::unique_ptr<te::da::DataSet> getData(const std::string& propertyName,
101 const te::gm::Geometry* g,
104 const te::common::AccessPolicy accessPolicy = te::common::RAccess) const;
105
106 std::unique_ptr<te::da::DataSet> getData(te::da::Expression* restriction,
108 const te::common::AccessPolicy accessPolicy = te::common::RAccess) const;
109
110 std::unique_ptr<te::da::DataSet> getData(const te::da::ObjectIdSet* oids,
112 const te::common::AccessPolicy accessPolicy = te::common::RAccess) const;
113
114 bool isValid() const;
115
116 void draw(Canvas* canvas, const te::gm::Envelope& bbox, int srid, const double& scale, bool* cancel);
117
118 /*!
119 \brief It returns the layer type: QUERY_LAYER.
120
121 \return The layer type: QUERY_LAYER.
122 */
123 const std::string& getType() const;
124
125 /*!
126 \brief
127
128 \return
129 */
131
132 /*!
133 \brief
134
135 \return
136 */
137 std::string getQueryAsString() const;
138
139 /*!
140 \brief
141
142 \param name
143 */
145
146 /*!
147 \brief
148
149 \return
150 */
151 const std::string& getRendererType() const;
152
153 /*!
154 \brief
155
156 \param t
157 */
158 void setRendererType(const std::string& t);
159
161
162 private:
163
164 std::unique_ptr<te::da::DataSet> getData(te::da::Select* query,
166 const te::common::AccessPolicy accessPolicy = te::common::RAccess) const;
167
168 /*!
169 \brief Its indicate that the layer schema is out of date.
170 */
171 virtual void setOutOfDate();
172
173 std::string searchJoin(const te::da::Join* dsJoin,
174 const std::string & token, bool & allowKeysWithNullValues) const;
175
176 private:
177
178 std::string m_rendererType; //!< A pointer to the internal renderer used to paint this layer.
179 te::da::Select* m_query; //!< The dataset name where we will retrieve the layer objects.
180
181 mutable LayerSchema* m_schema; //!< The dataset schema.
182
183 static const std::string sm_type; //!< A static data member used in the implementation of getType method.
184 };
185
186 typedef boost::intrusive_ptr<QueryLayer> QueryLayerPtr;
187
188 } // end namespace map
189} // end namespace te
190
191#endif // __TERRALIB_MAPTOOLS_INTERNAL_QUERYLAYER_H
This is the base class for Layers.
A class that models the description of a dataset.
Definition: DataSetType.h:73
This is an abstract class that models a query expression.
Definition: Expression.h:48
A Join clause combines two FromItems.
Definition: Join.h:51
This class represents a set of unique ids created in the same context. i.e. from the same data set.
Definition: ObjectIdSet.h:56
A Select models a query to be used when retrieving data from a DataSource.
Definition: Select.h:67
An Envelope defines a 2D rectangular region.
Definition: Envelope.h:52
Geometry is the root class of the geometries hierarchy, it follows OGC and ISO standards.
Definition: Geometry.h:78
This is the base class for layers.
Definition: AbstractLayer.h:78
A canvas is an abstraction of a drawing area.
Definition: Canvas.h:93
A layer resulting from a query.
Definition: QueryLayer.h:54
void setQuery(te::da::Select *s)
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.
void loadSchema() const
const std::string & getRendererType() const
te::da::Select * m_query
The dataset name where we will retrieve the layer objects.
Definition: QueryLayer.h:179
LayerSchema * m_schema
The dataset schema.
Definition: QueryLayer.h:181
std::unique_ptr< te::da::DataSet > getData(const std::string &propertyName, const te::gm::Envelope *e, te::gm::SpatialRelation r=te::gm::INTERSECTS, 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 using a spatial filter over the specified property.
~QueryLayer()
Destructor.
void setRendererType(const std::string &t)
te::da::Select * getQuery() const
std::unique_ptr< te::da::DataSet > getData(te::da::Select *query, te::common::TraverseType travType=te::common::FORWARDONLY, const te::common::AccessPolicy accessPolicy=te::common::RAccess) const
const std::string & getType() const
It returns the layer type: QUERY_LAYER.
std::unique_ptr< te::da::DataSet > getData(te::da::Expression *restriction, 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 using the given restriction.
std::unique_ptr< te::da::DataSet > getData(const std::string &propertyName, const te::gm::Geometry *g, te::gm::SpatialRelation r, 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 using a spatial filter over the given geometric prop...
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.
static const std::string sm_type
A static data member used in the implementation of getType method.
Definition: QueryLayer.h:183
QueryLayer(AbstractLayer *parent=0)
It initializes a new layer.
std::unique_ptr< LayerSchema > getSchema() const
It returns the layer schema.
bool isValid() const
It returns true if the layer can be used for instance to draw, otherwise, it returns false.
std::string searchJoin(const te::da::Join *dsJoin, const std::string &token, bool &allowKeysWithNullValues) const
AbstractLayer * clone()
It returns a clone of the object.
QueryLayer(const std::string &id, const std::string &title, AbstractLayer *parent=0)
It initializes a new layer.
std::string m_rendererType
A pointer to the internal renderer used to paint this layer.
Definition: QueryLayer.h:178
std::unique_ptr< te::da::DataSet > getData(const te::da::ObjectIdSet *oids, te::common::TraverseType travType=te::common::FORWARDONLY, const te::common::AccessPolicy accessPolicy=te::common::RAccess) const
It gets the dataset from the given set of objects identification.
QueryLayer(const std::string &id, AbstractLayer *parent=0)
It initializes a new layer.
std::string getQueryAsString() const
virtual void setOutOfDate()
Its indicate that the layer schema is out of date.
TraverseType
A dataset can be traversed in two ways:
Definition: Enums.h:54
@ FORWARDONLY
Definition: Enums.h:55
AccessPolicy
Supported data access policies (can be used as bitfield).
Definition: Enums.h:41
@ RAccess
Definition: Enums.h:43
SpatialRelation
Spatial relations between geometric objects.
Definition: Enums.h:128
@ INTERSECTS
Definition: Enums.h:130
boost::intrusive_ptr< QueryLayer > QueryLayerPtr
Definition: QueryLayer.h:186
TerraLib.
#define TEMAPEXPORT
You can use this macro in order to export/import classes and functions from this module.
Definition: Config.h:60