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 
32 namespace te
33 {
34 // Forward declaration
35  namespace da { class Select; }
36 
37  namespace map
38  {
39  /*!
40  \class QueryLayer
41 
42  \brief A layer resulting from a query.
43 
44  A QueryLayer is a reference to a dataset that will result from a query to a data source.
45 
46  \ingroup map
47 
48  \sa AbstractLayer, DataSetLayer, RasterLayer, FolderLayer
49  */
51  {
52  public:
53 
54  /*!
55  \brief It initializes a new layer.
56 
57  \param parent The parent layer (NULL if it has no parent).
58  */
59  QueryLayer(AbstractLayer* parent = 0);
60 
61  /*!
62  \brief It initializes a new layer.
63 
64  \param id The layer id.
65  \param parent The parent layer (NULL if it has no parent).
66  */
67  QueryLayer(const std::string& id, AbstractLayer* parent = 0);
68 
69  /*!
70  \brief It initializes a new layer.
71 
72  \param id The layer id.
73  \param title The title is a brief description about the layer.
74  \param parent The parent layer (NULL if it has no parent).
75  */
76  QueryLayer(const std::string& id, const std::string& title, AbstractLayer* parent = 0);
77 
78  /*! \brief Destructor. */
79  ~QueryLayer();
80 
81  AbstractLayer* clone();
82 
83  std::unique_ptr<LayerSchema> getSchema() const;
84 
85  /* Fills internal the cached schema for the dataset */
86  void loadSchema() const;
87 
88  std::unique_ptr<te::da::DataSet> getData(te::common::TraverseType travType = te::common::FORWARDONLY,
89  const te::common::AccessPolicy accessPolicy = te::common::RAccess) const;
90 
91  std::unique_ptr<te::da::DataSet> getData(const std::string& propertyName,
92  const te::gm::Envelope* e,
95  const te::common::AccessPolicy accessPolicy = te::common::RAccess) const;
96 
97  std::unique_ptr<te::da::DataSet> getData(const std::string& propertyName,
98  const te::gm::Geometry* g,
101  const te::common::AccessPolicy accessPolicy = te::common::RAccess) const;
102 
103  std::unique_ptr<te::da::DataSet> getData(te::da::Expression* restriction,
105  const te::common::AccessPolicy accessPolicy = te::common::RAccess) const;
106 
107  std::unique_ptr<te::da::DataSet> getData(const te::da::ObjectIdSet* oids,
109  const te::common::AccessPolicy accessPolicy = te::common::RAccess) const;
110 
111  bool isValid() const;
112 
113  void draw(Canvas* canvas, const te::gm::Envelope& bbox, int srid, const double& scale, bool* cancel);
114 
115  /*!
116  \brief It returns the layer type: QUERY_LAYER.
117 
118  \return The layer type: QUERY_LAYER.
119  */
120  const std::string& getType() const;
121 
122  /*!
123  \brief
124 
125  \return
126  */
127  te::da::Select* getQuery() const;
128 
129  /*!
130  \brief
131 
132  \return
133  */
134  std::string getQueryAsString() const;
135 
136  /*!
137  \brief
138 
139  \param name
140  */
141  void setQuery(te::da::Select* s);
142 
143  /*!
144  \brief
145 
146  \return
147  */
148  const std::string& getRendererType() const;
149 
150  /*!
151  \brief
152 
153  \param t
154  */
155  void setRendererType(const std::string& t);
156 
157  void computeExtent();
158 
159  private:
160 
161  std::unique_ptr<te::da::DataSet> getData(te::da::Select* query,
163  const te::common::AccessPolicy accessPolicy = te::common::RAccess) const;
164 
165  /*!
166  \brief Its indicate that the layer schema is out of date.
167  */
168  virtual void setOutOfDate();
169 
170  private:
171 
172  std::string m_rendererType; //!< A pointer to the internal renderer used to paint this layer.
173  te::da::Select* m_query; //!< The dataset name where we will retrieve the layer objects.
174 
175  mutable LayerSchema* m_schema; //!< The dataset schema.
176 
177  static const std::string sm_type; //!< A static data member used in the implementation of getType method.
178  };
179 
180  typedef boost::intrusive_ptr<QueryLayer> QueryLayerPtr;
181 
182  } // end namespace map
183 } // end namespace te
184 
185 #endif // __TERRALIB_MAPTOOLS_INTERNAL_QUERYLAYER_H
te::da::Select * m_query
The dataset name where we will retrieve the layer objects.
Definition: QueryLayer.h:173
This is the base class for layers.
Definition: AbstractLayer.h:77
A class that models the description of a dataset.
Definition: DataSetType.h:72
This is the base class for Layers.
SpatialRelation
Spatial relations between geometric objects.
Definition: Enums.h:127
A layer resulting from a query.
Definition: QueryLayer.h:50
This is an abstract class that models a query expression.
Definition: Expression.h:47
AccessPolicy
Supported data access policies (can be used as bitfield).
Definition: Enums.h:40
TraverseType
A dataset can be traversed in two ways:
Definition: Enums.h:53
An Envelope defines a 2D rectangular region.
Definition: Envelope.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:55
TerraLib.
LayerSchema * m_schema
The dataset schema.
Definition: QueryLayer.h:175
#define TEMAPEXPORT
You can use this macro in order to export/import classes and functions from this module.
Definition: Config.h:60
Geometry is the root class of the geometries hierarchy, it follows OGC and ISO standards.
Definition: Geometry.h:77
A Select models a query to be used when retrieving data from a DataSource.
Definition: Select.h:66
A canvas is an abstraction of a drawing area.
Definition: Canvas.h:92
std::string m_rendererType
A pointer to the internal renderer used to paint this layer.
Definition: QueryLayer.h:172
boost::intrusive_ptr< QueryLayer > QueryLayerPtr
Definition: QueryLayer.h:180
static const std::string sm_type
A static data member used in the implementation of getType method.
Definition: QueryLayer.h:177