All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
Style.cpp
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/Style.cpp
22 
23  \brief The Style defines the styling that is to be applied to a single feature (also applies to coverage).
24 */
25 
26 // TerraLib
27 #include "../common/STLUtils.h"
28 #include "../xlink/SimpleLink.h"
29 #include "Description.h"
30 #include "Rule.h"
31 #include "Style.h"
32 
33 // STL
34 #include <cassert>
35 
37  : m_name(0),
38  m_description(0),
39  m_semanticTypeIdentifiers(0),
40  m_version(TE_SE_DEFAULT_VERSION)
41 {
42 }
43 
45 {
46  delete m_name;
47  delete m_description;
48  delete m_semanticTypeIdentifiers;
49  te::common::FreeContents(m_rules);
50  te::common::FreeContents(m_onlineResources);
51 }
52 
53 void te::se::Style::setName(std::string* name)
54 {
55  delete m_name;
56  m_name = name;
57 }
58 
59 const std::string* te::se::Style::getName() const
60 {
61  return m_name;
62 }
63 
65 {
66  delete m_description;
67  m_description = d;
68 }
69 
71 {
72  return m_description;
73 }
74 
75 void te::se::Style::push_back(const std::string& semanticTypeIdentifier)
76 {
77  if(m_semanticTypeIdentifiers == 0)
78  m_semanticTypeIdentifiers = new std::vector<std::string>;
79 
80  m_semanticTypeIdentifiers->push_back(semanticTypeIdentifier);
81 }
82 
83 const std::string& te::se::Style::getSemanticTypeIdentifier(std::size_t i)
84 {
85  assert(m_semanticTypeIdentifiers && (i < m_semanticTypeIdentifiers->size()));
86  return (*m_semanticTypeIdentifiers)[i];
87 }
88 
89 const std::vector<std::string>* te::se::Style::getSemanticTypeIdentifiers() const
90 {
91  return m_semanticTypeIdentifiers;
92 }
93 
94 const std::vector<te::se::Rule*>& te::se::Style::getRules() const
95 {
96  return m_rules;
97 }
98 
100 {
101  assert(rule);
102  m_rules.push_back(rule);
103 }
104 
106 {
107  assert(i < m_rules.size());
108  return m_rules[i];
109 }
110 
112 {
113  assert(onlineResource);
114  m_onlineResources.push_back(onlineResource);
115 }
116 
117 const std::vector<te::xl::SimpleLink*>& te::se::Style::getOnlineResources() const
118 {
119  return m_onlineResources;
120 }
121 
123 {
124  assert(i < m_onlineResources.size());
125  return m_onlineResources[i];
126 }
127 
128 void te::se::Style::setVersion(const std::string& v)
129 {
130  m_version = v;
131 }
132 
133 const std::string& te::se::Style::getVersion() const
134 {
135  return m_version;
136 }
137 
#define TE_SE_DEFAULT_VERSION
It specifies the default version used by OGC Symbology Encoding.
Definition: Config.h:114
A Description gives human-readable descriptive information for the object it is included within...
Definition: Description.h:56
void setDescription(Description *d)
Definition: Style.cpp:64
void setVersion(const std::string &v)
Definition: Style.cpp:128
virtual ~Style()
Virtual destructor.
Definition: Style.cpp:44
A Rule is used to attach property/scale conditions to and group the individual symbols used for rende...
void push_back(const std::string &semanticTypeIdentifier)
Definition: Style.cpp:75
A Description gives human-readable descriptive information for the object it is included within...
Rule * getRule(std::size_t i) const
Definition: Style.cpp:105
const std::vector< Rule * > & getRules() const
Definition: Style.cpp:94
const std::vector< te::xl::SimpleLink * > & getOnlineResources() const
Definition: Style.cpp:117
Style()
It initializes a new Style.
Definition: Style.cpp:36
const std::string & getSemanticTypeIdentifier(std::size_t i)
Definition: Style.cpp:83
void setName(std::string *name)
Definition: Style.cpp:53
A Rule is used to attach property/scale conditions to and group the individual symbols used for rende...
Definition: Rule.h:78
const std::string * getName() const
Definition: Style.cpp:59
const te::xl::SimpleLink * getOnlineResource(std::size_t i) const
Definition: Style.cpp:122
const std::vector< std::string > * getSemanticTypeIdentifiers() const
Definition: Style.cpp:89
The Style defines the styling that is to be applied to a geographic dataset (vector geometries or cov...
const Description * getDescription() const
Definition: Style.cpp:70
void FreeContents(boost::unordered_map< K, V * > &m)
This function can be applied to a map of pointers. It will delete each pointer in the map...
Definition: BoostUtils.h:55
const std::string & getVersion() const
Definition: Style.cpp:133