1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
|
#ifndef MBGL_SYMBOL_LAYER
#define MBGL_SYMBOL_LAYER
#include <mbgl/style/style_layer.hpp>
#include <mbgl/style/layout_property.hpp>
#include <mbgl/style/paint_property.hpp>
namespace mbgl {
class SpriteAtlas;
class SymbolLayoutProperties {
public:
LayoutProperty<PlacementType> placement { PlacementType::Point };
LayoutProperty<float> spacing { 250.0f };
LayoutProperty<bool> avoidEdges { false };
class IconProperties {
public:
LayoutProperty<bool> allowOverlap { false };
LayoutProperty<bool> ignorePlacement { false };
LayoutProperty<bool> optional { false };
LayoutProperty<RotationAlignmentType> rotationAlignment { RotationAlignmentType::Viewport };
LayoutProperty<float> size { 1.0f };
LayoutProperty<std::string> image { "" };
LayoutProperty<float> rotate { 0.0f };
LayoutProperty<float> padding { 2.0f };
LayoutProperty<bool> keepUpright { false };
LayoutProperty<std::array<float, 2>> offset { {{ 0, 0 }} };
} icon;
class TextProperties {
public:
LayoutProperty<RotationAlignmentType> rotationAlignment { RotationAlignmentType::Viewport };
LayoutProperty<std::string> field { "" };
LayoutProperty<std::string> font { "Open Sans Regular, Arial Unicode MS Regular" };
LayoutProperty<float> size { 16.0f };
LayoutProperty<float> maxWidth { 15.0f /* em */ };
LayoutProperty<float> lineHeight { 1.2f /* em */ };
LayoutProperty<float> letterSpacing { 0.0f /* em */ };
LayoutProperty<TextJustifyType> justify { TextJustifyType::Center };
LayoutProperty<TextAnchorType> anchor { TextAnchorType::Center };
LayoutProperty<float> maxAngle { 45.0f /* degrees */ };
LayoutProperty<float> rotate { 0.0f };
LayoutProperty<float> padding { 2.0f };
LayoutProperty<bool> keepUpright { true };
LayoutProperty<TextTransformType> transform { TextTransformType::None };
LayoutProperty<std::array<float, 2>> offset { {{ 0, 0 }} };
LayoutProperty<bool> allowOverlap { false };
LayoutProperty<bool> ignorePlacement { false };
LayoutProperty<bool> optional { false };
} text;
// Special case.
float iconMaxSize = 1.0f;
float textMaxSize = 16.0f;
};
class SymbolPaintProperties {
public:
class PaintProperties {
public:
PaintProperties(float size_) : size(size_) {}
PaintProperty<float> opacity { 1.0f };
PaintProperty<Color> color { {{ 0, 0, 0, 1 }} };
PaintProperty<Color> haloColor { {{ 0, 0, 0, 0 }} };
PaintProperty<float> haloWidth { 0.0f };
PaintProperty<float> haloBlur { 0.0f };
PaintProperty<std::array<float, 2>> translate { {{ 0, 0 }} };
PaintProperty<TranslateAnchorType> translateAnchor { TranslateAnchorType::Map };
// Special case
float size;
bool isVisible() const {
return opacity > 0 && (color.value[3] > 0 || haloColor.value[3] > 0) && size > 0;
}
};
PaintProperties icon { 1.0f };
PaintProperties text { 16.0f };
};
class SymbolLayer : public StyleLayer {
public:
SymbolLayer() : StyleLayer(Type::Symbol) {}
std::unique_ptr<StyleLayer> clone() const override;
void parseLayout(const JSValue&) override;
void parsePaints(const JSValue&) override;
void cascade(const StyleCascadeParameters&) override;
bool recalculate(const StyleCalculationParameters&) override;
std::unique_ptr<Bucket> createBucket(StyleBucketParameters&) const override;
SymbolLayoutProperties layout;
SymbolPaintProperties paint;
SpriteAtlas* spriteAtlas = nullptr;
};
template <>
inline bool StyleLayer::is<SymbolLayer>() const {
return type == Type::Symbol;
}
} // namespace mbgl
#endif
|