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/se/Utils.h
22
23 \brief Utility functions for Symbology Enconding module.
24
25 \ingroup se
26*/
27
28#ifndef __TERRALIB_SE_INTERNAL_UTILS_H
29#define __TERRALIB_SE_INTERNAL_UTILS_H
30
31// TerraLib
32#include "../color/RGBAColor.h"
33#include "../geometry/Enums.h"
34#include "Config.h"
35#include "Font.h"
36
37// STL
38#include <string>
39#include <vector>
40
41namespace te
42{
43// Forward declaration
44 namespace rst { class BandProperty; }
45
46 namespace se
47 {
48// Forward declarations
49 class Description;
50 class Fill;
51 class Graphic;
52 class LineSymbolizer;
53 class Mark;
54 class ParameterValue;
55 class PointSymbolizer;
56 class PolygonSymbolizer;
57 class Stroke;
58 class Style;
59 class Symbolizer;
60 class RasterSymbolizer;
61 class TextSymbolizer;
62
63 /*!
64 \brief Creates a stroke.
65
66 \param color The stroke color enconded hexadecimal i.e "#FF0000".
67 \param width The stroke width.
68
69 \return The Symbology Enconding Stroke element.
70
71 \note The caller of this method will take the ownership of the returned pointer.
72 */
73 TESEEXPORT Stroke* CreateStroke(const std::string& color, const std::string& width);
74
75 /*!
76 \brief Creates a stroke.
77
78 \param color The stroke color enconded hexadecimal i.e "#FF0000".
79 \param width The stroke width.
80 \param opacity The stroke opacity [0,1].
81
82 \return The Symbology Enconding Stroke element.
83
84 \note The caller of this method will take the ownership of the returned pointer.
85 */
86 TESEEXPORT Stroke* CreateStroke(const std::string& color, const std::string& width, const std::string& opacity);
87
88 /*!
89 \brief Creates a stroke.
90
91 \param color The stroke color enconded hexadecimal i.e "#FF0000".
92 \param width The stroke width.
93 \param opacity The stroke opacity [0,1].
94 \param dasharray The stroke dasharray.
95
96 \return The Symbology Enconding Stroke element.
97
98 \note The caller of this method will take the ownership of the returned pointer.
99 */
100 TESEEXPORT Stroke* CreateStroke(const std::string& color, const std::string& width,
101 const std::string& opacity, const std::string& dasharray);
102
103 /*!
104 \brief Creates a stroke.
105
106 \param color The stroke color enconded hexadecimal i.e "#FF0000".
107 \param width The stroke width.
108 \param opacity The stroke opacity [0,1].
109 \param dasharray The stroke dasharray.
110 \param linecap The stroke linecap {butt, square, round}.
111 \param linejoin The stroke linejoin {miter, bevel, round}.
112
113 \return The Symbology Enconding Stroke element.
114
115 \note The caller of this method will take the ownership of the returned pointer.
116 */
117 TESEEXPORT Stroke* CreateStroke(const std::string& color, const std::string& width,
118 const std::string& opacity, const std::string& dasharray,
119 const std::string& linecap, const std::string& linejoin);
120
121 /*!
122 \brief Creates a stroke.
123
124 \param graphic The stroke graphic fill.
125 \param width The stroke width.
126 \param opacity The stroke opacity [0,1].
127 \param dasharray The stroke dasharray.
128 \param linecap The stroke linecap {butt, square, round}.
129 \param linejoin The stroke linejoin {miter, bevel, round}.
130
131 \return The Symbology Enconding Stroke element.
132
133 \note The caller of this method will take the ownership of the returned pointer.
134 */
136 const std::string& width, const std::string& opacity,
137 const std::string& dasharray, const std::string& linecap, const std::string& linejoin);
138
139 /*!
140 \brief Creates a fill.
141
142 \param color The fill color enconded hexadecimal i.e "#FF0000".
143 \param opacity The fill opacity.
144
145 \return The Symbology Enconding Fill element.
146
147 \note The caller of this method will take the ownership of the returned pointer.
148 */
149 TESEEXPORT Fill* CreateFill(const std::string& color, const std::string& opacity);
150
151 /*!
152 \brief Creates a fill.
153
154 \param graphic The graphic fill.
155
156 \return The Symbology Enconding Fill element.
157
158 \note The caller of this method will take the ownership of the returned pointer.
159 */
161
162 /*!
163 \brief Creates a mark.
164
165 \param wellKnownName The mark well-known name.
166 \param stroke The mark stroke.
167 \param fill The mark fill.
168
169 \return The Symbology Enconding Mark element.
170
171 \note The caller of this method will take the ownership of the returned pointer.
172 */
173 TESEEXPORT Mark* CreateMark(const std::string& wellKnownName, Stroke* stroke, Fill* fill);
174
175 /*!
176 \brief Creates a graphic.
177
178 \param mark The graphic mark.
179 \param size The graphic size.
180 \param rotation The graphic rotation.
181 \param opacity The graphic opacity.
182
183 \return The Symbology Enconding Graphic element.
184
185 \note The caller of this method will take the ownership of the returned pointer.
186 */
187 TESEEXPORT Graphic* CreateGraphic(Mark* mark, const std::string& size, const std::string& rotation, const std::string& opacity);
188
189 /*!
190 \brief Creates a polygon symbolizer.
191
192 \param stroke The polygon symbolizer stroke.
193 \param fill The polygon symbolizer fill.
194
195 \return The Symbology Enconding PolygonSymbolizer element.
196
197 \note The caller of this method will take the ownership of the returned pointer.
198 */
200
201 /*!
202 \brief Creates a line symbolizer.
203
204 \param stroke The line symbolizer stroke.
205
206 \return The Symbology Enconding LineSymbolizer element.
207
208 \note The caller of this method will take the ownership of the returned pointer.
209 */
211
212 /*!
213 \brief Creates a point symbolizer.
214
215 \param graphic The point symbolizer graphic.
216
217 \return The Symbology Enconding PointSymbolizer element.
218
219 \note The caller of this method will take the ownership of the returned pointer.
220 */
222
223 /*!
224 \brief Creates a font.
225
226 \param family The font family.
227 \param size The font size.
228 \param style The font style.
229 \param weight The font weight.
230
231 \return The Symbology Enconding Font element.
232
233 \note The caller of this method will take the ownership of the returned pointer.
234 */
235 TESEEXPORT Font* CreateFont(const std::string& family, const std::string& size,
238
239 /*!
240 \brief Creates a text symbolizer.
241
242 \param label The property name that will be labelled.
243 \param fill The text symbolizer fill.
244 \param font The text symbolizer font.
245
246 \return The Symbology Enconding TextSymbolizer element.
247
248 \note The caller of this method will take the ownership of the returned pointer.
249 */
250 TESEEXPORT TextSymbolizer* CreateTextSymbolizer(const std::string& label, Fill* fill, Font* font);
251
252 /*!
253 \brief Creates a description.
254
255 \param title The title of description.
256 \param abst The abstratc of description.
257
258 \return The Symbology Enconding Description element.
259
260 \note The caller of this method will take the ownership of the returned pointer.
261 */
262 TESEEXPORT Description* CreateDescription(const std::string& title, const std::string& abst);
263
264 /*!
265 \brief Try creates an appropriate symbolizer based on given geometry type.
266
267 \param geomType The geometry type.
268
269 \return A symbolizer based on given geometry type.
270
271 \note Random colors will be generated.
272 \note The caller of this method will take the ownership of the returned pointer.
273 \note The method will return a NULL pointer if a default symbolizer could not be created.
274 */
276
277 /*!
278 \brief Try creates an appropriate symbolizer based on given geometry type and a default color.
279
280 \param geomType The geometry type.
281 \param color The fill color enconded hexadecimal i.e "#FF0000".
282
283 \return A symbolizer based on given geometry type.
284
285 \note The caller of this method will take the ownership of the returned pointer.
286 \note The method will return a NULL pointer if a default symbolizer could not be created.
287 */
288 TESEEXPORT Symbolizer* CreateSymbolizer(const te::gm::GeomType& geomType, const std::string& color);
289
290 /*!
291 \brief Try creates an appropriate feature type style based on given geometry type.
292
293 \param geomType The geometry type.
294
295 \return A feature type style based on given geometry type.
296 \param color The fill color enconded hexadecimal i.e "#FF0000".
297
298 \note The caller of this method will take the ownership of the returned pointer.
299 \note The method will return a NULL pointer if a default style could not be created.
300 */
301 TESEEXPORT Style* CreateFeatureTypeStyle(const te::gm::GeomType& geomType, const std::string& color = "");
302
303 /*!
304 \brief Try creates an appropriate coverage style based on given band properties.
305
306 \param properties The band properties.
307
308 \return A coverage style based on given geometry type.
309
310 \note The caller of this method will take the ownership of the returned pointer.
311 \note The method will return a NULL pointer if a default style could not be created.
312
313 \todo Review this method in order to extract the maximum information about the given band properties.
314 */
315 TESEEXPORT Style* CreateCoverageStyle(const std::vector<te::rst::BandProperty*>& properties);
316
317 /*!
318 \brief Try creates an appropriate coverage style based on given number of bands.
319
320 \param nBands The number of bands.
321
322 \return A coverage style based on given geometry type.
323
324 \note The caller of this method will take the ownership of the returned pointer.
325 \note The method will return a NULL pointer if a default style could not be created.
326 */
327 TESEEXPORT Style* CreateCoverageStyle(const std::size_t& nBands);
328
329 /*!
330 \brief Try creates an appropriate raster symbolizer style based on given number of bands.
331
332 \param nBands The number of bands.
333
334 \return A raster symbolizer based on number of bands.
335
336 \note The caller of this method will take the ownership of the returned pointer.
337 \note The method will return a NULL pointer if a default raster symbolizer could not be created.
338 */
340
341 /*!
342 \brief Try to get raster symbolizer from a style.
343
344 \param s Style.
345
346 \return A raster symbolizer.
347
348 \note The method will return a NULL pointer if the symbolizer does not have a raster symbolizer.
349 */
351
352 /*!
353 \brief Creates a random RGB color encoded using two hexadecimal digits per primary-color component prefixed with a hash (#) sign.
354
355 \return A random color encoded using two hexadecimal digits per primary-color component prefixed with a hash (#) sign.
356 */
358
359
360 /*!
361 \brief It gets the RGBA color from the Stroke element.
362
363 \param stroke The Symbology Enconding Stroke element.
364 \param color A pre-created color that will be filled with the values extracted from Stroke.
365
366 \note The given color will be altered based on "stroke" and "stroke-opacity" attributes, if availables.
367 */
369
370 /*!
371 \brief It gets the RGBA color from the Fill element.
372
373 \param fill The Symbology Enconding Fill element.
374 \param color A pre-created color that will be filled with the values extracted from Fill.
375
376 \note The given color will be altered based on "fill" and "fill-opacity" attributes, if availables.
377 */
379
380 /*!
381 \brief It gets the RGBA color from the parameter values.
382
383 \param color The Symbology Enconding Parameter Value element that represents the color.
384 \param opacity The Symbology Enconding Parameter Value element that represents the opacity.
385 \param color A pre-created color that will be filled with the values extracted from color and opacity.
386
387 \note The given color will be altered based on "color" and "opacity" parameters, if availables.
388 \note Warning: It considers that the paramater value is enconded using a Literal OGC Filter expression.
389 */
391
392 /*!
393 \brief It gets the parameter value as a RGBA color.
394
395 \param param The Symbology Enconding Parameter Value element.
396
397 \return The RGBA color.
398
399 \note Warning: It considers that the paramater value is enconded using a Literal OGC Filter expression.
400 */
402
403 /*!
404 \brief It gets the parameter value as an integer.
405
406 \param param The Symbology Enconding Parameter Value element.
407
408 \return The integer value.
409
410 \note Warning: It considers that the paramater value is enconded using a Literal OGC Filter expression.
411 */
413
414 /*!
415 \brief It gets the parameter value as a double.
416
417 \param param The Symbology Encoding Parameter Value element.
418
419 \return The double value.
420
421 \note Warning: It considers that the paramater value is enconded using a Literal OGC Filter expression.
422 */
424
425 /*!
426 \brief It gets the parameter value as a string.
427
428 \param param The Symbology Encoding Parameter Value element.
429
430 \return The string value.
431
432 \note Warning: It considers that the paramater value is encoded using a Literal OGC Filter expression.
433 */
434 TESEEXPORT std::string GetString(const te::se::ParameterValue* param);
435
436
437 } // end namespace se
438} // end namespace te
439
440#endif // __TERRALIB_SE_INTERNAL_UTILS_H
A Font specifies the text font to use in a text symbolizer.
A helper class for 32-bit RGBA (Red-Green-Blue-Alpha channel) color.
Definition: RGBAColor.h:58
A Description gives human-readable descriptive information for the object it is included within.
Definition: Description.h:57
A Fill specifies the pattern for filling an area geometry.
Definition: Fill.h:60
A Font specifies the text font to use in a text symbolizer.
Definition: Font.h:64
FontStyleType
It defines the style to use for a font.
Definition: Font.h:73
@ StyleNormal
Definition: Font.h:74
FontWeightType
It gives the amount of weight or boldness to use for a font.
Definition: Font.h:85
@ WeightNormal
Definition: Font.h:87
A Graphic is a graphic symbol with an inherent shape, color(s), and possibly size.
Definition: Graphic.h:67
A LineSymbolizer is used to style a stroke along a linear geometry type, such as a string of line seg...
A Mark specifies a geometric shape and applies coloring to it.
Definition: Mark.h:85
The "ParameterValueType" uses WFS-Filter expressions to give values for SE graphic parameters.
A PointSymbolizer specifies the rendering of a graphic Symbolizer at a point.
A PolygonSymbolizer is used to draw a polygon (or other area-type geometries), including filling its ...
The RasterSymbolizer describes how to render raster/matrix-coverage data (e.g., satellite photos,...
A Stroke specifies the appearance of a linear geometry.
Definition: Stroke.h:68
The Style defines the styling that is to be applied to a geographic dataset (vector geometries or cov...
Definition: Style.h:66
A Symbolizer describes how a feature is to appear on a map.
Definition: Symbolizer.h:81
A TextSymbolizer is used to render text labels according to various graphical parameters.
GeomType
Each enumerated type is compatible with a Well-known Binary (WKB) type code.
Definition: Enums.h:42
TESEEXPORT PointSymbolizer * CreatePointSymbolizer(Graphic *graphic)
Creates a point symbolizer.
TESEEXPORT Style * CreateCoverageStyle(const std::vector< te::rst::BandProperty * > &properties)
Try creates an appropriate coverage style based on given band properties.
TESEEXPORT Fill * CreateFill(const std::string &color, const std::string &opacity)
Creates a fill.
TESEEXPORT int GetInt(const te::se::ParameterValue *param)
It gets the parameter value as an integer.
TESEEXPORT RasterSymbolizer * GetRasterSymbolizer(Style *s)
Try to get raster symbolizer from a style.
TESEEXPORT std::string GenerateRandomColor()
Creates a random RGB color encoded using two hexadecimal digits per primary-color component prefixed ...
TESEEXPORT Stroke * CreateStroke(const std::string &color, const std::string &width)
Creates a stroke.
TESEEXPORT TextSymbolizer * CreateTextSymbolizer(const std::string &label, Fill *fill, Font *font)
Creates a text symbolizer.
TESEEXPORT std::string GetString(const te::se::ParameterValue *param)
It gets the parameter value as a string.
TESEEXPORT Description * CreateDescription(const std::string &title, const std::string &abst)
Creates a description.
TESEEXPORT double GetDouble(const te::se::ParameterValue *param)
It gets the parameter value as a double.
TESEEXPORT RasterSymbolizer * CreateRasterSymbolizer(const std::size_t &nBands)
Try creates an appropriate raster symbolizer style based on given number of bands.
TESEEXPORT Style * CreateFeatureTypeStyle(const te::gm::GeomType &geomType, const std::string &color="")
Try creates an appropriate feature type style based on given geometry type.
TESEEXPORT PolygonSymbolizer * CreatePolygonSymbolizer(Stroke *stroke, Fill *fill)
Creates a polygon symbolizer.
TESEEXPORT Graphic * CreateGraphic(Mark *mark, const std::string &size, const std::string &rotation, const std::string &opacity)
Creates a graphic.
TESEEXPORT Font * CreateFont(const std::string &family, const std::string &size, const te::se::Font::FontStyleType &style=te::se::Font::StyleNormal, const te::se::Font::FontWeightType &weight=te::se::Font::WeightNormal)
Creates a font.
TESEEXPORT Mark * CreateMark(const std::string &wellKnownName, Stroke *stroke, Fill *fill)
Creates a mark.
TESEEXPORT LineSymbolizer * CreateLineSymbolizer(Stroke *stroke)
Creates a line symbolizer.
TESEEXPORT void GetColor(const te::se::Stroke *stroke, te::color::RGBAColor &color)
It gets the RGBA color from the Stroke element.
TESEEXPORT Symbolizer * CreateSymbolizer(const te::gm::GeomType &geomType)
Try creates an appropriate symbolizer based on given geometry type.
TerraLib.
#define TESEEXPORT
You can use this macro in order to export/import classes and functions from this module.
Definition: Config.h:201
Proxy configuration file for TerraView (see terraview_config.h).