All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
Utils.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/Utils.h
22 
23  \brief Utility functions for MapTools module.
24 
25  \ingroup map
26 */
27 
28 #ifndef __TERRALIB_MAPTOOLS_INTERNAL_UTILS_H
29 #define __TERRALIB_MAPTOOLS_INTERNAL_UTILS_H
30 
31 // TerraLib
32 #include "../color/RGBAColor.h"
33 #include "../dataaccess/datasource/DataSource.h"
34 #include "../geometry/Enums.h"
35 #include "../geometry/Envelope.h"
36 #include "../raster/Raster.h"
37 #include "AbstractLayer.h"
38 #include "Config.h"
39 
40 // STL
41 #include <list>
42 #include <string>
43 #include <vector>
44 
45 namespace te
46 {
47 // Forward declarations
48  namespace common
49  {
50  class TaskProgress;
51  }
52 
53  namespace da
54  {
55  class DataSet;
56  class DataSetType;
57  }
58 
59  namespace rst
60  {
61  class RasterProperty;
62  }
63 
64  namespace se
65  {
66  class CoverageStyle;
67  class FeatureTypeStyle;
68  }
69 
70  namespace map
71  {
72 // Forward declaration
73  class DataSetLayer;
74 
75  /*!
76  \brief It calculates the extent of selected objects of the given layers in the given SRID.
77 
78  \param layers The layer list that will be consulted.
79  \param srid The result extent SRID.
80  \param onlyVisibles A flag that indicates if the method should consider only the visible layers.
81 
82  \return The extent of selected objects of the given layers in the given SRID.
83 
84  \note This method considers the children of layers.
85  */
86  TEMAPEXPORT te::gm::Envelope GetSelectedExtent(const std::list<te::map::AbstractLayerPtr> layers, int srid, bool onlyVisibles);
87 
88  /*!
89  \brief It calculates the extent of selected objects of the given layer in the given SRID.
90 
91  \param layer The layer that will be consulted.
92  \param srid The result extent SRID.
93  \param onlyVisibles A flag that indicates if the method should consider only the visible layers.
94 
95  \return The extent of the selected objects of the given layer in the given SRID.
96 
97  \note This method considers the children of layers.
98  */
99  TEMAPEXPORT te::gm::Envelope GetSelectedExtent(const te::map::AbstractLayerPtr layer, int srid, bool onlyVisibles);
100 
101  /*!
102  \brief Converts a dasharray pattern coded by a string to a vector of double.
103 
104  \param dasharray The dasharray pattern coded by a string.
105  \param style The vector of double that will be filled with the values extracted from dasharray string.
106 
107  \note The dasharray should be specified as an even number of positive values separated by blank space. i.e "10 5 3 4"
108  Here, the values "10" and "3" (in uom) are dashes and the values "5" and "4" are spaces (in uom).
109  The given vector style will be filled with the values: style[0] = 10; style[1] = 5; style[2] = 3; style[3] = 4.
110  */
111  TEMAPEXPORT void GetDashStyle(const std::string& dasharray, std::vector<double>& style);
112 
113  /*!
114  \brief It gets the raster property referenced by the given data set layer.
115 
116  \param layer The data set layer that will be used to retrieve the raster property.
117 
118  \return The raster property referenced by the data set layer.
119 
120  \note The caller will take the ownership of the returned pointer.
121 
122  \exception Exception It will throw an exception if the raster property could not be retrieved.
123  */
125 
126  /*!
127  \brief It gets the raster referenced by the given data set layer.
128 
129  \param layer The data set layer that will be used to retrieve the raster.
130 
131  \return The raster referenced by the data set layer.
132 
133  \note The caller will take the ownership of the returned pointer.
134 
135  \exception Exception It will throw an exception if the raster could not be retrieved.
136  */
137  TEMAPEXPORT te::rst::Raster* GetRaster(DataSetLayer* layer);
138 
139  /*!
140  \brief It gets the visible layers of the given layer list.
141 
142  \param layers The layer list that will be consulted.
143  \param visibleLayers A layer list that will be filled with the visible layers.
144  */
145  TEMAPEXPORT void GetVisibleLayers(const std::list<te::map::AbstractLayerPtr>& layers, std::list<te::map::AbstractLayerPtr>& visibleLayers);
146 
147  /*!
148  \brief It gets the visible layers of the given layer.
149 
150  \param layer The layer that will be consulted.
151  \param visibleLayers A layer list that will be filled with the visible layers.
152  */
153  TEMAPEXPORT void GetVisibleLayers(const te::map::AbstractLayerPtr& layer, std::list<te::map::AbstractLayerPtr>& visibleLayers);
154 
155  /*!
156  \brief It calculates the extent of the given layers in the given SRID.
157 
158  \param layers The layer list that will be consulted.
159  \param srid The result extent SRID.
160  \param onlyVisibles A flag that indicates if the method should consider only the visible layers.
161 
162  \return The extent of the given layers in the given SRID.
163 
164  \note This method considers the children of layers.
165  */
166  TEMAPEXPORT te::gm::Envelope GetExtent(const std::list<te::map::AbstractLayerPtr>& layers, int srid, bool onlyVisibles);
167 
168  /*!
169  \brief It calculates the extent of the given layer in the given SRID.
170 
171  \param layer The layer that will be consulted.
172  \param srid The result extent SRID.
173  \param onlyVisibles A flag that indicates if the method should consider only the visible layers.
174 
175  \return The extent of the given layer in the given SRID.
176 
177  \note This method considers the children of layer.
178  */
179  TEMAPEXPORT te::gm::Envelope GetExtent(const te::map::AbstractLayerPtr& layer, int srid, bool onlyVisibles);
180 
181  /*!
182  \brief It creates a new In-Memory dataset with the items from the given dataset.
183 
184  \param dataset The dataset which will provide the items. Do not pass NULL!
185 
186  \return A new In-Memory dataset.
187 
188  \note The new dataset will not have a transactor associated to it.
189 
190  \note To copy all items the caller is responsible for informing the
191  dataset in the right position. i.e. at before begin.
192 
193  \note The caller will take the ownership of the returned pointer.
194  */
196 
197  /*!
198  \brief It draws the data set geometries in the given canvas using the informed SRID and style.
199 
200  The informed bounding box (bbox) is used to constraint the data set to be drawn.
201  Here, we assume that the given bbox was pre-processed. i.e. the bbox was clipped and contains the same projection of data set geometries.
202 
203  \param type The data set type that describes the data set that will be drawn.
204  \param ds A datasource that will be used to retrieve the data set objects.
205  \param canvas The canvas were the data set geometries will be drawn.
206  \param bbox The interest area to render the geometries.
207  \param bboxSRID The SRID of interest area.
208  \param srid The SRID to be used to draw the data set geometries.
209  \param style The style that will be used.
210  */
212  const te::gm::Envelope& bbox, int bboxSRID,
213  int srid, te::se::FeatureTypeStyle* style);
214 
215  /*!
216  \brief It draws the data set geometries in the given canvas using the informed SRS.
217 
218  \param dataset The data set that will be drawn.
219  \param gpos The geometry property position that will be drawn.
220  \param canvas The canvas were the data set geometries will be drawn.
221  \param fromSRID The SRID of data set geometries.
222  \param srid The SRID to be used to draw the data set geometries.
223  \param task An optional task that can be used cancel the draw process.
224  */
225  TEMAPEXPORT void DrawGeometries(te::da::DataSet* dataset, const std::size_t& gpos,
226  Canvas* canvas, int fromSRID, int toSRID, te::common::TaskProgress* task = 0);
227 
228  TEMAPEXPORT void DrawRaster(te::da::DataSetType* type, te::da::DataSourcePtr ds, Canvas* canvas,
229  const te::gm::Envelope& bbox, int bboxSRID, const te::gm::Envelope& visibleArea, int srid, te::se::CoverageStyle* style);
230 
231  TEMAPEXPORT void DrawRaster(te::rst::Raster* raster, Canvas* canvas, const te::gm::Envelope& bbox, int bboxSRID,
232  const te::gm::Envelope& visibleArea, int srid, te::se::CoverageStyle* style);
233 
234  TEMAPEXPORT te::rst::Raster* GetExtentRaster(te::rst::Raster* raster, int w, int h, const te::gm::Envelope& bbox, int bboxSRID,
235  const te::gm::Envelope& visibleArea, int srid);
236 
237  /*!
238  \brief It gets the geometry type of the given layer.
239 
240  \param layer The layer that will be consulted.
241  */
243 
244  } // end namespace map
245 } // end namespace te
246 
247 #endif // __TERRALIB_MAPTOOLS_INTERNAL_UTILS_H
GeomType
Each enumerated type is compatible with a Well-known Binary (WKB) type code.
Definition: Enums.h:41
boost::shared_ptr< DataSource > DataSourcePtr
Definition: DataSource.h:1435
TEMAPEXPORT te::gm::Envelope GetExtent(const std::list< te::map::AbstractLayerPtr > &layers, int srid, bool onlyVisibles)
It calculates the extent of the given layers in the given SRID.
Definition: Utils.cpp:254
A class that models the description of a dataset.
Definition: DataSetType.h:72
TEMAPEXPORT te::rst::RasterProperty * GetRasterProperty(DataSetLayer *layer)
It gets the raster property referenced by the given data set layer.
Definition: Utils.cpp:163
The CoverageStyle defines the styling that is to be applied to a subset of Coverage data...
Definition: CoverageStyle.h:45
This is the base class for Layers.
This class can be used to inform the progress of a task.
Definition: TaskProgress.h:53
TEMAPEXPORT te::gm::GeomType GetGeomType(const te::map::AbstractLayerPtr &layer)
It gets the geometry type of the given layer.
Definition: Utils.cpp:748
TEMAPEXPORT void DrawGeometries(te::da::DataSetType *type, te::da::DataSourcePtr ds, Canvas *canvas, const te::gm::Envelope &bbox, int bboxSRID, int srid, te::se::FeatureTypeStyle *style)
It draws the data set geometries in the given canvas using the informed SRID and style.
Definition: Utils.cpp:293
Raster property.
TEMAPEXPORT te::gm::Envelope GetSelectedExtent(const std::list< te::map::AbstractLayerPtr > layers, int srid, bool onlyVisibles)
It calculates the extent of selected objects of the given layers in the given SRID.
Definition: Utils.cpp:79
TEMAPEXPORT te::da::DataSet * DataSet2Memory(te::da::DataSet *dataset)
It creates a new In-Memory dataset with the items from the given dataset.
Definition: Utils.cpp:283
TEMAPEXPORT void GetDashStyle(const std::string &dasharray, std::vector< double > &style)
Converts a dasharray pattern coded by a string to a vector of double.
Definition: Utils.cpp:155
An Envelope defines a 2D rectangular region.
Definition: Envelope.h:51
The FeatureTypeStyle defines the styling that is to be applied to a dataset that can be viewed as a f...
An abstract class for raster data strucutures.
Definition: Raster.h:71
#define TEMAPEXPORT
You can use this macro in order to export/import classes and functions from this module.
Definition: Config.h:63
TEMAPEXPORT te::rst::Raster * GetRaster(DataSetLayer *layer)
It gets the raster referenced by the given data set layer.
Definition: Utils.cpp:192
A dataset is the unit of information manipulated by the data access module of TerraLib.
Definition: DataSet.h:112
TEMAPEXPORT te::rst::Raster * GetExtentRaster(te::rst::Raster *raster, int w, int h, const te::gm::Envelope &bbox, int bboxSRID, const te::gm::Envelope &visibleArea, int srid)
Definition: Utils.cpp:680
boost::intrusive_ptr< AbstractLayer > AbstractLayerPtr
TEMAPEXPORT void DrawRaster(te::da::DataSetType *type, te::da::DataSourcePtr ds, Canvas *canvas, const te::gm::Envelope &bbox, int bboxSRID, const te::gm::Envelope &visibleArea, int srid, te::se::CoverageStyle *style)
Definition: Utils.cpp:460
TEMAPEXPORT void GetVisibleLayers(const std::list< te::map::AbstractLayerPtr > &layers, std::list< te::map::AbstractLayerPtr > &visibleLayers)
It gets the visible layers of the given layer list.
Definition: Utils.cpp:248