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(nullptr),
38  m_description(nullptr),
39  m_semanticTypeIdentifiers(nullptr),
40  m_version(TE_SE_DEFAULT_VERSION)
41 {
42 }
43 
45 {
46  delete m_name;
47  delete m_description;
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 == nullptr)
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 {
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 
111 void te::se::Style::removeRule(std::size_t i)
112 {
113  assert(i < m_rules.size());
114 
115  delete m_rules[i];
116 
117  m_rules.erase(m_rules.begin() + i);
118 }
119 
121 {
123  m_rules.clear();
124 }
125 
127 {
128  assert(onlineResource);
129  m_onlineResources.push_back(onlineResource);
130 }
131 
132 const std::vector<te::xl::SimpleLink*>& te::se::Style::getOnlineResources() const
133 {
134  return m_onlineResources;
135 }
136 
138 {
139  assert(i < m_onlineResources.size());
140  return m_onlineResources[i];
141 }
142 
143 void te::se::Style::setVersion(const std::string& v)
144 {
145  m_version = v;
146 }
147 
148 const std::string& te::se::Style::getVersion() const
149 {
150  return m_version;
151 }
152 
A Description gives human-readable descriptive information for the object it is included within...
Definition: Description.h:56
std::string * m_name
It allows the style to be referenced. Names must be unique in the context in which they are defined...
Definition: Style.h:137
Description * m_description
It gives an informative description of the style. (Optional)
Definition: Style.h:138
std::vector< Rule * > m_rules
It allows conditional rendering. (Mandatory if m_onlineResource is empty, otherwise, it is optional)
Definition: Style.h:140
void setDescription(Description *d)
Definition: Style.cpp:64
void setVersion(const std::string &v)
Definition: Style.cpp:143
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
std::vector< std::string > * m_semanticTypeIdentifiers
The SemanticTypeIdentifier is experimental and is intended to be used to identify what the feature st...
Definition: Style.h:139
const std::vector< te::xl::SimpleLink * > & getOnlineResources() const
Definition: Style.cpp:132
static te::dt::DateTime d(2010, 8, 9, 15, 58, 39)
Style()
It initializes a new Style.
Definition: Style.cpp:36
void removeRules()
Definition: Style.cpp:120
void removeRule(std::size_t i)
Definition: Style.cpp:111
#define TE_SE_DEFAULT_VERSION
It specifies the default version used by OGC Symbology Encoding.
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:76
const std::string * getName() const
Definition: Style.cpp:59
const te::xl::SimpleLink * getOnlineResource(std::size_t i) const
Definition: Style.cpp:137
std::string m_version
The version is an optional attribute on the FeatureTypeStyle that identifies the SE version number th...
Definition: Style.h:142
std::vector< te::xl::SimpleLink * > m_onlineResources
It refers to an external document. (Mandatory if m_rules is empty, otherwise, it is optional) ...
Definition: Style.h:141
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:148