Loading...
Searching...
No Matches
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
45namespace te
46{
47// Forward declarations
48 namespace common
49 {
50 class TaskProgress;
51 }
52
53 namespace da
54 {
55 class DataAccessPtr;
56 class DataSet;
57 class DataSetType;
58 }
59
60 namespace rst
61 {
62 class RasterProperty;
63 }
64
65 namespace se
66 {
67 class CoverageStyle;
68 class FeatureTypeStyle;
69 class Graphic;
70 class Symbolizer;
71 }
72
73 namespace map
74 {
75// Forward declaration
76 class DataSetLayer;
77 class RasterContrast;
78
79 /*!
80 \brief It calculates the extent of selected objects of the given layers in the given SRID.
81
82 \param layers The layer list that will be consulted.
83 \param srid The result extent SRID.
84 \param onlyVisibles A flag that indicates if the method should consider only the visible layers.
85
86 \return The extent of selected objects of the given layers in the given SRID.
87
88 \note This method considers the children of layers.
89 */
90 TEMAPEXPORT te::gm::Envelope GetSelectedExtent(const std::list<te::map::AbstractLayerPtr> layers, int srid, bool onlyVisibles);
91
92 /*!
93 \brief It calculates the extent of selected objects of the given layer in the given SRID.
94
95 \param layer The layer that will be consulted.
96 \param srid The result extent SRID.
97 \param onlyVisibles A flag that indicates if the method should consider only the visible layers.
98
99 \return The extent of the selected objects of the given layer in the given SRID.
100
101 \note This method considers the children of layers.
102 */
104
105 /*!
106 \brief Converts a dasharray pattern coded by a string to a vector of double.
107
108 \param dasharray The dasharray pattern coded by a string.
109 \param style The vector of double that will be filled with the values extracted from dasharray string.
110
111 \note The dasharray should be specified as an even number of positive values separated by blank space. i.e "10 5 3 4"
112 Here, the values "10" and "3" (in uom) are dashes and the values "5" and "4" are spaces (in uom).
113 The given vector style will be filled with the values: style[0] = 10; style[1] = 5; style[2] = 3; style[3] = 4.
114 */
115 TEMAPEXPORT void GetDashStyle(const std::string& dasharray, std::vector<double>& style);
116
117 /*!
118 \brief It gets the raster property referenced by the given data set layer.
119
120 \param layer The data set layer that will be used to retrieve the raster property.
121
122 \return The raster property referenced by the data set layer.
123
124 \note The caller will take the ownership of the returned pointer.
125
126 \exception Exception It will throw an exception if the raster property could not be retrieved.
127 */
129
130 /*!
131 \brief It gets the raster referenced by the given data set layer.
132
133 \param layer The data set layer that will be used to retrieve the raster.
134
135 \return The raster referenced by the data set layer.
136
137 \note The caller will take the ownership of the returned pointer.
138
139 \exception Exception It will throw an exception if the raster could not be retrieved.
140 */
142
143 /*!
144 \brief It gets the visible layers of the given layer list.
145
146 \param layers The layer list that will be consulted.
147 \param visibleLayers A layer list that will be filled with the visible layers.
148 */
149 TEMAPEXPORT void GetVisibleLayers(const std::list<te::map::AbstractLayerPtr>& layers, std::list<te::map::AbstractLayerPtr>& visibleLayers);
150
151 TEMAPEXPORT void GetVisibleLayers(const std::list<te::map::AbstractLayer*>& layers, std::list<te::map::AbstractLayer*>& visibleLayers);
152
153 /*!
154 \brief It gets the visible layers of the given layer.
155
156 \param layer The layer that will be consulted.
157 \param visibleLayers A layer list that will be filled with the visible layers.
158 */
159 TEMAPEXPORT void GetVisibleLayers(const te::map::AbstractLayerPtr& layer, std::list<te::map::AbstractLayerPtr>& visibleLayers);
160
161 /*!
162 \brief It calculates the extent of the given layers in the given SRID.
163
164 \param layers The layer list that will be consulted.
165 \param srid The result extent SRID.
166 \param onlyVisibles A flag that indicates if the method should consider only the visible layers.
167
168 \return The extent of the given layers in the given SRID.
169
170 \note This method considers the children of layers.
171 */
172 TEMAPEXPORT te::gm::Envelope GetExtent(const std::list<te::map::AbstractLayerPtr>& layers, int srid, bool onlyVisibles);
173
174 /*!
175 \brief It calculates the extent of the given layer in the given SRID.
176
177 \param layer The layer that will be consulted.
178 \param srid The result extent SRID.
179 \param onlyVisibles A flag that indicates if the method should consider only the visible layers.
180
181 \return The extent of the given layer in the given SRID.
182
183 \note This method considers the children of layer.
184 */
185 TEMAPEXPORT te::gm::Envelope GetExtent(const te::map::AbstractLayerPtr& layer, int srid, bool onlyVisibles);
186
187 /*!
188 \brief It creates a new In-Memory dataset with the items from the given dataset.
189
190 \param dataset The dataset which will provide the items. Do not pass NULL!
191
192 \return A new In-Memory dataset.
193
194 \note The new dataset will not have a transactor associated to it.
195
196 \note To copy all items the caller is responsible for informing the
197 dataset in the right position. i.e. at before begin.
198
199 \note The caller will take the ownership of the returned pointer.
200 */
202
203 /*!
204 \brief It draws the data set geometries in the given canvas using the informed SRID and style.
205
206 The informed bounding box (bbox) is used to constraint the data set to be drawn.
207 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.
208
209 \param type The data set type that describes the data set that will be drawn.
210 \param ds A datasource that will be used to retrieve the data set objects.
211 \param canvas The canvas were the data set geometries will be drawn.
212 \param bbox The interest area to render the geometries.
213 \param bboxSRID The SRID of interest area.
214 \param srid The SRID to be used to draw the data set geometries.
215 \param style The style that will be used.
216 */
218 const te::gm::Envelope& bbox, int bboxSRID,
219 int srid, te::se::FeatureTypeStyle* style);
220
221 /*!
222 \brief It draws the data set geometries in the given canvas using the informed SRS.
223
224 \param dataset The data set that will be drawn.
225 \param gpos The geometry property position that will be drawn.
226 \param canvas The canvas were the data set geometries will be drawn.
227 \param fromSRID The SRID of data set geometries.
228 \param srid The SRID to be used to draw the data set geometries.
229 \param task An optional task that can be used cancel the draw process.
230 */
231 TEMAPEXPORT void DrawGeometries(te::da::DataSet* dataset, const std::size_t& gpos,
232 Canvas* canvas, int fromSRID, int toSRID, te::common::TaskProgress* task = 0);
233
235 const te::gm::Envelope& bbox, int bboxSRID, const te::gm::Envelope& visibleArea, int srid, te::se::CoverageStyle* style,
236 te::map::RasterContrast* rc, const double& scale, bool* cancel);
237
238 TEMAPEXPORT void DrawRaster(te::rst::Raster* raster, Canvas* canvas, const te::gm::Envelope& bbox, int bboxSRID,
239 const te::gm::Envelope& visibleArea, int srid, te::se::CoverageStyle* style, te::map::RasterContrast* rc,
240 const double& scale, bool* cancel);
241
242 TEMAPEXPORT te::rst::Raster* GetExtentRaster(te::rst::Raster* raster, int w, int h, const te::gm::Envelope& bbox, int bboxSRID,
243 const te::gm::Envelope& visibleArea, int srid);
244
245 /*!
246 \brief It gets the geometry type of the given layer.
247
248 \param layer The layer that will be consulted.
249 */
251
252
253 /*!
254 \brief It gets the requested envelope on a UTM planar projection
255
256 \param worldBox WordBox to be transformed to planar
257 \param srid The WorldBox SRID to transform from
258 */
260
261 /*!
262 \brief Returns proj4 string with UTM projection in the specified zone (Only working for south).
263 \param UTM Zone
264 \return proj4 string
265 */
266 TEMAPEXPORT std::string GetUTMProj4FromZone(int zone);
267
268 /*!
269 \brief Calculates the UTM zone from a Geographic envelope.
270
271 \param latLongBox Geographic envelope
272 \return UTM zone
273 */
275
276 /*!
277 \brief Make a copy of refLayer abstract attributes to layer. Creating new id.
278
279 \param refLayer The reference layer
280 \param layer Target layer
281 */
283
284
285 /*!
286 \brief It draws marks along a line in the given canvas.
287
288 \param line The geometry style that will be drawn.
289 \param canvas The canvas were the data set geometries will be drawn.
290 \param graphic The graphic configuration of a mark that will be drawn.
291 \param initialGap The initial gap to draw marks in a line.
292 \param gap The gap between marks.
293
294 \note Only geometries will be drawn with marks if the style has the option of Graphic Stroke.
295 */
297 Canvas* canvas,
298 const te::se::Graphic* graphic,
299 double gap,
300 double initialGap);
301
302
303 /*!
304 \brief It draws the geometry in the given canvas with marks.
305
306 \param symb The geometry style that will be drawn.
307 \param geom The geometry that will be drawn.
308 \param canvas The canvas were the data set geometries will be drawn.
309
310 \note Only geometries will be drawn with marks if the style has the
311 option of Graphic Stroke.
312 */
313 TEMAPEXPORT void DrawGraphicStrokeLine(const te::se::Graphic* graphic, const te::gm::LineString* lineString, Canvas* canvas, double gap, double initialGap = 0., double offset = 0.);
314
315 /*!
316 \brief It draws the geometry in the given canvas with marks.
317
318 \param symb The geometry style that will be drawn.
319 \param geom The geometry that will be drawn.
320 \param canvas The canvas were the data set geometries will be drawn.
321
322 \note Only geometries will be drawn with marks if the style has the
323 option of Graphic Stroke.
324 */
325 TEMAPEXPORT void DrawGraphicStroke(const te::se::Graphic* graphic, const te::gm::Geometry* geom, Canvas* canvas, double gap, double initialGap = 0., double offset = 0.);
326
327
328 /*!
329 \brief It draws the geometry in the given canvas with marks.
330
331 \param symbolizer The geometry style that will be drawn.
332 \param geom The geometry that will be drawn.
333 \param canvas The canvas were the data set geometries will be drawn.
334
335 \note Only geometries will be drawn with marks if the style has the option of Graphic Stroke.
336 */
337 TEMAPEXPORT void DrawGraphicStroke(const te::se::Symbolizer* symbolizer, const te::gm::Geometry* geom, Canvas* canvas);
338
339 /*!
340 \brief It gets the dataAccess that can be used to access data information from the given layer.
341
342 \param absLayer The layer from which the data will be access
343
344 \return The dataAccess associated to the given layer
345 */
347
348 /*!
349 \brief From the given layer list containing an optional hierarchical structure, returns a plain list without any hierarchy
350
351 \param listLayersTree The layer list containing an optional hierarchical structure
352
353 \return A plain list without any hierarchy. Caller MUST NOT delete the returned pointers. The will be valid as long as listLayersTree is valid
354 */
355 TEMAPEXPORT std::list<te::map::AbstractLayer*> GetPlainLayerList(const std::list<te::map::AbstractLayerPtr>& listLayersTree);
356
357 } // end namespace map
358} // end namespace te
359
360#endif // __TERRALIB_MAPTOOLS_INTERNAL_UTILS_H
This is the base class for Layers.
This class can be used to inform the progress of a task.
Definition: TaskProgress.h:54
A class that models the description of a dataset.
Definition: DataSetType.h:73
A dataset is the unit of information manipulated by the data access module of TerraLib.
Definition: DataSet.h:114
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
LineString is a curve with linear interpolation between points.
Definition: LineString.h:65
This is the base class for layers.
Definition: AbstractLayer.h:78
A canvas is an abstraction of a drawing area.
Definition: Canvas.h:93
This class contains the parameters needed to apply dynamic contrast over a raster.
Raster property.
An abstract class for raster data strucutures.
Definition: Raster.h:72
The CoverageStyle defines the styling that is to be applied to a subset of Coverage data.
Definition: CoverageStyle.h:46
The FeatureTypeStyle defines the styling that is to be applied to a dataset that can be viewed as a f...
A Graphic is a graphic symbol with an inherent shape, color(s), and possibly size.
Definition: Graphic.h:67
A Symbolizer describes how a feature is to appear on a map.
Definition: Symbolizer.h:81
boost::shared_ptr< DataSource > DataSourcePtr
Definition: DataSource.h:1449
GeomType
Each enumerated type is compatible with a Well-known Binary (WKB) type code.
Definition: Enums.h:42
TEMAPEXPORT std::list< te::map::AbstractLayer * > GetPlainLayerList(const std::list< te::map::AbstractLayerPtr > &listLayersTree)
From the given layer list containing an optional hierarchical structure, returns a plain list without...
TEMAPEXPORT te::da::DataAccessPtr GetDataAccess(te::map::AbstractLayerPtr absLayer)
It gets the dataAccess that can be used to access data information from the given layer.
boost::intrusive_ptr< AbstractLayer > AbstractLayerPtr
TEMAPEXPORT te::rst::RasterProperty * GetRasterProperty(AbstractLayer *layer)
It gets the raster property referenced by the given data set layer.
TEMAPEXPORT void DrawGraphicStroke(const te::se::Graphic *graphic, const te::gm::Geometry *geom, Canvas *canvas, double gap, double initialGap=0., double offset=0.)
It draws the geometry in the given canvas with marks.
TEMAPEXPORT void GetDashStyle(const std::string &dasharray, std::vector< double > &style)
Converts a dasharray pattern coded by a string to a vector of double.
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.
TEMAPEXPORT te::gm::GeomType GetGeomType(const te::map::AbstractLayerPtr &layer)
It gets the geometry type of the given layer.
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.
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, te::map::RasterContrast *rc, const double &scale, bool *cancel)
TEMAPEXPORT int CalculatePlanarZone(te::gm::Envelope latLongBox)
Calculates the UTM zone from a Geographic envelope.
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.
TEMAPEXPORT void DrawPointAlongLine(const te::gm::LineString *line, Canvas *canvas, const te::se::Graphic *graphic, double gap, double initialGap)
It draws marks along a line in the given canvas.
TEMAPEXPORT te::gm::Envelope GetWorldBoxInPlanar(const te::gm::Envelope &worldBox, int srid)
It gets the requested envelope on a UTM planar projection.
TEMAPEXPORT void DrawGraphicStrokeLine(const te::se::Graphic *graphic, const te::gm::LineString *lineString, Canvas *canvas, double gap, double initialGap=0., double offset=0.)
It draws the geometry in the given canvas with marks.
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)
TEMAPEXPORT te::da::DataSet * DataSet2Memory(te::da::DataSet *dataset)
It creates a new In-Memory dataset with the items from the given dataset.
TEMAPEXPORT void CopyAbstractLayerInfo(const te::map::AbstractLayer *refLayer, te::map::AbstractLayer *layer)
Make a copy of refLayer abstract attributes to layer. Creating new id.
TEMAPEXPORT std::string GetUTMProj4FromZone(int zone)
Returns proj4 string with UTM projection in the specified zone (Only working for south).
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.
TEMAPEXPORT te::rst::Raster * GetRaster(AbstractLayer *layer)
It gets the raster referenced by the given data set layer.
TerraLib.
#define TEMAPEXPORT
You can use this macro in order to export/import classes and functions from this module.
Definition: Config.h:60
Proxy configuration file for TerraView (see terraview_config.h).