Layer.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 Layer.h
22 
23  \brief A Layer is a reference to a virtual dataset with/without geometric attributes.
24 */
25 
26 #ifndef __TERRALIB_GRAPH_INTERNAL_LAYER_H
27 #define __TERRALIB_GRAPH_INTERNAL_LAYER_H
28 
29 // TerraLib
30 #include "../../maptools/AbstractLayer.h"
31 #include "../Config.h"
32 
33 
34 // STL
35 #include <memory>
36 
37 namespace te
38 {
39  namespace gm { class Envelope; }
40 
41  namespace map
42  {
43  class Canvas;
44  }
45 
46  namespace se { class Style; }
47 
48  namespace graph
49  {
50 // Forward declarations
51  class AbstractGraph;
52  class LayerRenderer;
53 
54  /*!
55  \class Layer
56 
57  \brief A Layer is a reference to a virtual dataset with/without geometric attributes.
58 
59  A Layer is the result of a query in a given DataSource.
60 
61  \sa AbstractLayer
62  */
64  {
65  public:
66 
67  /*!
68  \brief It initializes a new Layer.
69 
70  \param id The layer id.
71  \param title The title is a brief description about the layer, that can be used by an application to show a meaninfull label to the user.
72  \param parent The parent Layer (or NULL if it has no parent).
73 
74  \note If parent is informed, it will take the ownership of the new layer.
75  */
76  Layer(const std::string& id, const std::string& title, AbstractLayer* parent = 0);
77 
78  /*! \brief Destructor. */
79  ~Layer();
80 
81  /*!
82  \brief It returns the layer schema.
83 
84  \return The Layer schema.
85 
86  \note The caller will take the ownership of the returned layer schema.
87  */
88  virtual std::auto_ptr<te::da::DataSetType> getSchema() const;
89 
90  /*!
91  \brief It gets the dataset identified by the layer name.
92 
93  \param travType The traverse type associated to the returned dataset.
94  \param accessPolicy Access policy.
95 
96  \return The caller of this method will take the ownership of the returned dataset.
97 
98  \exception Exception It can throws an exception if:
99  <ul>
100  <li>something goes wrong during the data retrieval</li>
101  <li>if the data source driver doesn't support the traversal type</li>
102  <li>if the data source driver doesn't support the access policy</li>
103  </ul>
104 
105  \note Not thread-safe!
106  */
107  virtual std::auto_ptr<te::da::DataSet> getData(te::common::TraverseType travType = te::common::FORWARDONLY,
108  const te::common::AccessPolicy accessPolicy = te::common::RAccess) const;
109 
110  /*!
111  \brief It gets the dataset identified by the layer name using a spatial filter over the specified property.
112 
113  \param propertyName The name of the spatial property used to apply the spatial filter.
114  \param e A rectangle to be used as a spatial filter when retrieving datasets.
115  \param r The spatial relation to be used during the filter.
116  \param travType The traverse type associated to the returned dataset.
117  \param accessPolicy Access policy.
118 
119  \return The caller of this method will take the ownership of the returned DataSet.
120 
121  \exception Exception It can throws an exception if:
122  <ul>
123  <li>something goes wrong during data retrieval</li>
124  <li>if the data source driver doesn't support the traversal type</li>
125  <li>if the data source driver doesn't support the access policy</li>
126  </ul>
127 
128  \note Transactor will not take the ownership of the given envelope.
129 
130  \note The envelope coordinates should be in the same coordinate system as the dataset.
131 
132  \note Not thread-safe!
133  */
134  virtual std::auto_ptr<te::da::DataSet> getData(const std::string& propertyName,
135  const te::gm::Envelope* e,
138  const te::common::AccessPolicy accessPolicy = te::common::RAccess) const;
139 
140  /*!
141  \brief It gets the dataset identified by the layer name using a spatial filter over the given geometric property.
142 
143  \param propertyName The name of the spatial property used to apply the spatial filter.
144  \param g A geometry to be used as a spatial filter when retrieving datasets.
145  \param r The spatial relation to be used during the filter.
146  \param travType The traverse type associated to the returned dataset.
147  \param accessPolicy Access policy.
148 
149  \return The caller of this method will take the ownership of the returned DataSet.
150 
151  \exception Exception It can throws an exception if:
152  <ul>
153  <li>something goes wrong during data retrieval</li>
154  <li>if the data source driver doesn't support the traversal type</li>
155  <li>if the data source driver doesn't support the access policy</li>
156  </ul>
157 
158  \note Transactor will not take the ownership of the given geometry.
159 
160  \note The geometry coordinates should be in the same coordinate system as the dataset.
161 
162  \note Not thread-safe!
163  */
164  virtual std::auto_ptr<te::da::DataSet> getData(const std::string& propertyName,
165  const te::gm::Geometry* g,
168  const te::common::AccessPolicy accessPolicy = te::common::RAccess) const;
169 
170  /*!
171  \brief It gets the dataset identified by the layer name using the given restriction.
172 
173  \param restriction The restriction expression that will be used.
174  \param travType The traverse type associated to the returned dataset.
175  \param accessPolicy Access policy.
176 
177  \return The caller of this method will take the ownership of the returned DataSet.
178 
179  \exception Exception It can throws an exception if:
180  <ul>
181  <li>something goes wrong during data retrieval</li>
182  <li>if the data source driver doesn't support the traversal type</li>
183  <li>if the data source driver doesn't support the access policy</li>
184  </ul>
185 
186  \note Not thread-safe!
187  */
188  virtual std::auto_ptr<te::da::DataSet> getData(te::da::Expression* restriction,
190  const te::common::AccessPolicy accessPolicy = te::common::RAccess) const;
191 
192  /*!
193  \brief It gets the dataset from the given set of objects identification.
194 
195  \param oids The set of object ids.
196  \param travType The traverse type associated to the returned dataset.
197  \param accessPolicy Access policy.
198 
199  \return The caller of this method will take the ownership of the returned dataset.
200 
201  \exception Exception It can throws an exception if:
202  <ul>
203  <li>something goes wrong during the data retrieval</li>
204  <li>if the data source driver doesn't support the traversal type</li>
205  <li>if the data source driver doesn't support the access policy</li>
206  </ul>
207 
208  \note Not thread-safe!
209  */
210  virtual std::auto_ptr<te::da::DataSet> getData(const te::da::ObjectIdSet* oids,
212  const te::common::AccessPolicy accessPolicy = te::common::RAccess) const;
213 
214  /*!
215  \brief It returns the layer type.
216 
217  \return The layer type.
218  */
219  virtual const std::string& getType() const;
220 
221  /*!
222  \brief It returns true if the layer can be drawn, otherwise, it returns false.
223 
224  This method can be used to check if the data referenced by the layer is available (accessible), or not.
225 
226  \return True, if the layer can be drawn, otherwise, it returns false.
227  */
228  virtual bool isValid() const;
229 
230  /*!
231  \brief It draws the layer geographic objects in the given canvas using the informed SRS.
232 
233  The informed bounding box can be used to constraint the layer objects to be drawn.
234 
235  The bbox coordinates must be in the same Spatial Reference System given by srid.
236 
237  \param canvas The canvas were the layer objects will be drawn.
238  \param bbox The interest area to render the map.
239  \param srid The SRS to be used to draw the layer objects.
240  */
241  virtual void draw(te::map::Canvas* canvas, const te::gm::Envelope& bbox, int srid, const double& scale);
242 
243  /*!
244  \brief It returns the graph associated to the layer.
245 
246  \return the graph associated to the layer.
247  */
248  te::graph::AbstractGraph* getGraph() const;
249 
250  /*!
251  \brief It sets the graph associated to the layer.
252 
253  \param ds The graph associated to the layer.
254  */
255  void setGraph(te::graph::AbstractGraph* ds);
256 
257  /*!
258  \brief It returns the renderer used to paint this layer.
259 
260  \return The renderer used to paint this layer.
261  */
262  LayerRenderer* getRenderer() const;
263 
264  /*!
265  \brief It sets the renderer used to paint this layer.
266 
267  \param renderer The renderer to be used to paint this layer.
268 
269  \note The Layer will take the ownership of the given renderer.
270  */
271  void setRenderer(LayerRenderer* renderer);
272 
273  public:
274 
275  static const std::string sm_type; //!< A static data member used in the implementation of getType method.
276 
277  private:
278 
279  std::auto_ptr<LayerRenderer> m_renderer; //!< A pointer to the internal renderer used to paint this layer.
280  te::graph::AbstractGraph* m_graph; //!< The graph associated to this Layer.
281  };
282 
283  } // end namespace graph
284 } // end namespace te
285 
286 #endif // __TERRALIB_GRAPH_INTERNAL_LAYER_H
287 
#define TEGRAPHEXPORT
You can use this macro in order to export/import classes and functions from this module.
Definition: Config.h:178
The Style defines the styling that is to be applied to a geographic dataset (vector geometries or cov...
Definition: Style.h:65
This is the base class for layers.
Definition: AbstractLayer.h:76
SpatialRelation
Spatial relations between geometric objects.
Definition: Enums.h:127
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
Abstract class used to define the main functions of graph struct. All graph implementations must used...
Definition: AbstractGraph.h:55
URI C++ Library.
Geometry is the root class of the geometries hierarchy, it follows OGC and ISO standards.
Definition: Geometry.h:73
te::graph::AbstractGraph * m_graph
The graph associated to this Layer.
Definition: Layer.h:280
It renders the objects associated to a Layer.
Definition: LayerRenderer.h:57
A canvas is an abstraction of a drawing area.
Definition: Canvas.h:92
static const std::string sm_type
A static data member used in the implementation of getType method.
Definition: Layer.h:275
std::auto_ptr< LayerRenderer > m_renderer
A pointer to the internal renderer used to paint this layer.
Definition: Layer.h:279
A Layer is a reference to a virtual dataset with/without geometric attributes.
Definition: Layer.h:63