alaCarte Maps
Renderer for OpenStreetMap tiles
style.hpp
Go to the documentation of this file.
1 
21 #pragma once
22 #ifndef STYLE_HPP
23 #define STYLE_HPP
24 
25 #include "settings.hpp"
26 
27 
28 class GeoObject;
29 class Stylesheet;
30 class StyleTemplate;
31 
35 class Style
36 {
37 public:
38  enum TextPosition {
42  };
43  enum LineCap {
44  CAP_NONE = 0,
47  };
48  enum LineJoin {
52  };
53  enum ShieldShape {
54  ROUNDED = 0,
56  };
57  enum FontWeight {
60  };
61  enum FontStyle {
64  };
65 
71  TESTABLE void overmerge(GeoObject* obj, const shared_ptr<StyleTemplate>& style);
72 
76  void finish(GeoObject* associatedObject, shared_ptr<const Stylesheet> stylesheet);
77 
80 
83 
84  float width;
85  float casing_width;
87 
91  float text_offset;
92  float font_size;
96 
97  // The colour (hex or CSS) of the 'halo' or 'pull-out' used to make the text stand out from features underneath it
100 
105 
107  float icon_width;
108  float icon_height;
110 
111 
113  // How transparent the shield is, from 0 (transparent) to 1 (opaque)
116  // Width of the frame. If 0, no frame is rendered
123 
124 
125  std::vector<double> dashes;
126  std::vector<double> casing_dashes;
127 
128  int z_index;
129 
130  Style();
131 };
132 
133 template<typename Stream>
134 Stream& operator >> (Stream& stream, Style::TextPosition& position)
135 {
136  string expr;
137  stream >> expr;
138 
139  if(expr == "line")
140  position = Style::POSITION_LINE;
141  else if(expr == "center")
142  position = Style::POSITION_CENTER;
143 
144  return stream;
145 }
146 
147 template<typename Stream>
148 Stream& operator >> (Stream& stream, Style::LineCap& cap)
149 {
150  string expr;
151  stream >> expr;
152 
153  if(expr == "round")
154  cap = Style::CAP_ROUND;
155  else if(expr == "square")
156  cap = Style::CAP_SQUARE;
157 
158  return stream;
159 }
160 
161 template<typename Stream>
162 Stream& operator >> (Stream& stream, Style::LineJoin& join)
163 {
164  string expr;
165  stream >> expr;
166 
167  if(expr == "bevel")
168  join = Style::JOIN_BEVEL;
169  else if(expr == "miter")
170  join = Style::JOIN_MITER;
171  else if(expr == "round")
172  join = Style::JOIN_ROUND;
173 
174  return stream;
175 }
176 
177 template<typename Stream>
178 Stream& operator >> (Stream& stream, Style::ShieldShape& shape)
179 {
180  string expr;
181  stream >> expr;
182 
183  if(expr == "rounded")
184  shape = Style::ROUNDED;
185  else if(expr == "rectangular")
186  shape = Style::RECTANGULAR;
187 
188  return stream;
189 }
190 
191 template<typename Stream>
192 Stream& operator >> (Stream& stream, Style::FontWeight& weight)
193 {
194  string expr;
195  stream >> expr;
196 
197  if(expr == "normal")
198  weight = Style::WEIGHT_NORMAL;
199  else if(expr == "bold")
200  weight = Style::WEIGHT_BOLD;
201 
202  return stream;
203 }
204 
205 template<typename Stream>
206 Stream& operator >> (Stream& stream, Style::FontStyle& style)
207 {
208  string expr;
209  stream >> expr;
210 
211  if(expr == "normal")
212  style = Style::STYLE_NORMAL;
213  else if(expr == "italic")
214  style = Style::STYLE_ITALIC;
215 
216  return stream;
217 }
218 
219 #endif
MaybeCachedString shield_text
Definition: style.hpp:120
float text_halo_radius
Definition: style.hpp:99
void finish(GeoObject *associatedObject, shared_ptr< const Stylesheet > stylesheet)
Performs finishing operations on the style, like resolve tags for texts or check for icon path existe...
Definition: style.cpp:88
float casing_width
Definition: style.hpp:85
float shield_casing_width
Definition: style.hpp:119
FontWeight
Definition: style.hpp:57
LineJoin casing_linejoin
Definition: style.hpp:104
float text_offset
Definition: style.hpp:91
A StyleTemplate is the "raw" / "unevaluated" form of a Style specified by a single MapCSS rule...
float shield_frame_width
Definition: style.hpp:117
TESTABLE void overmerge(GeoObject *obj, const shared_ptr< StyleTemplate > &style)
Takes all non-"null" (meaning only properties that were explicitely set) properties from the given St...
Definition: style.cpp:38
Color shield_frame_color
Definition: style.hpp:115
ShieldShape
Definition: style.hpp:53
Definition: color.hpp:40
int z_index
Definition: style.hpp:128
MaybeCachedString image
Definition: style.hpp:81
MaybeCachedString fill_image
Definition: style.hpp:82
LineCap casing_linecap
Definition: style.hpp:103
ShieldShape shield_shape
Definition: style.hpp:122
Represents a string which could be cached into an internal cache.
float shield_opacity
Definition: style.hpp:114
MaybeCachedString font_family
Definition: style.hpp:93
A Stylesheet parses a given MapCSS Stylesheet file and stores the defined rules.
Definition: stylesheet.hpp:39
Color text_color
Definition: style.hpp:90
float icon_width
Definition: style.hpp:107
Color shield_casing_color
Definition: style.hpp:118
FontWeight font_weight
Definition: style.hpp:94
MaybeCachedString shield_image
Definition: style.hpp:121
LineJoin linejoin
Definition: style.hpp:102
FontStyle
Definition: style.hpp:61
A Style stores the MapCSS properties for a single Node or Way, or a Relation of type multipolygon...
Definition: style.hpp:35
LineCap
Definition: style.hpp:43
float icon_opacity
Definition: style.hpp:109
Style()
Definition: style.cpp:198
TextPosition
Definition: style.hpp:38
Color color
Definition: style.hpp:78
float icon_height
Definition: style.hpp:108
std::vector< double > casing_dashes
Definition: style.hpp:126
float font_size
Definition: style.hpp:92
MaybeCachedString icon_image
Definition: style.hpp:106
Color fill_color
Definition: style.hpp:79
LineCap linecap
Definition: style.hpp:101
TextPosition text_position
Definition: style.hpp:89
LineJoin
Definition: style.hpp:48
float width
Definition: style.hpp:84
std::vector< double > dashes
Definition: style.hpp:125
#define TESTABLE
Definition: settings.hpp:85
FontStyle font_style
Definition: style.hpp:95
Color text_halo_color
Definition: style.hpp:98
Color casing_color
Definition: style.hpp:86
Color shield_color
Definition: style.hpp:112
Stream & operator>>(Stream &stream, Style::TextPosition &position)
Definition: style.hpp:134
MaybeCachedString text
Definition: style.hpp:88