summaryrefslogtreecommitdiff
path: root/src/mbgl/style/style_bucket.hpp
blob: eac899cb97ced5e9c25fd21eaf6d9dc4fa3a32f7 (plain)
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
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
#ifndef MBGL_STYLE_STYLE_BUCKET
#define MBGL_STYLE_STYLE_BUCKET

#include <mbgl/style/types.hpp>
#include <mbgl/style/filter_expression.hpp>
#include <mbgl/style/style_source.hpp>

#include <mbgl/util/vec.hpp>
#include <mbgl/util/variant.hpp>
#include <mbgl/util/noncopyable.hpp>
#include <mbgl/util/ptr.hpp>
#include <mbgl/style/class_properties.hpp>

#include <forward_list>

namespace mbgl {

class Source;

class StyleBucketFill {
public:
    // Make movable only.
    StyleBucketFill() = default;
    StyleBucketFill(StyleBucketFill &&) = default;
    StyleBucketFill& operator=(StyleBucketFill &&) = default;
    StyleBucketFill(const StyleBucketFill &) = delete;
    StyleBucketFill& operator=(const StyleBucketFill &) = delete;
};

class StyleBucketLine {
public:
    // Make movable only.
    StyleBucketLine() = default;
    StyleBucketLine(StyleBucketLine &&) = default;
    StyleBucketLine& operator=(StyleBucketLine &&) = default;
    StyleBucketLine(const StyleBucketLine &) = delete;
    StyleBucketLine& operator=(const StyleBucketLine &) = delete;

    CapType cap = CapType::Butt;
    JoinType join = JoinType::Miter;
    float miter_limit = 2.0f;
    float round_limit = 1.0f;
};

class StyleBucketSymbol {
public:
    // Make movable only.
    StyleBucketSymbol() = default;
    StyleBucketSymbol(StyleBucketSymbol &&) = default;
    StyleBucketSymbol& operator=(StyleBucketSymbol &&) = default;
    StyleBucketSymbol(const StyleBucketSymbol &) = delete;
    StyleBucketSymbol& operator=(const StyleBucketSymbol &) = delete;

    PlacementType placement = PlacementType::Point;
    float min_distance = 250.0f;
    bool avoid_edges = false;

    struct {
        bool allow_overlap = false;
        bool ignore_placement = false;
        bool optional = false;
        RotationAlignmentType rotation_alignment = RotationAlignmentType::Viewport;
        float max_size = 1.0f;
        std::string image;
        float rotate = 0.0f;
        float padding = 2.0f;
        bool keep_upright = false;
        std::array<float, 2> offset = {{ 0, 0 }};
    } icon;

    struct {
        RotationAlignmentType rotation_alignment = RotationAlignmentType::Viewport;
        std::string field;
        std::string font;
        float max_size = 16.0f;
        float max_width = 15.0f /* em */;
        float line_height = 1.2f /* em */;
        float letter_spacing = 0.0f /* em */;
        TextJustifyType justify = TextJustifyType::Center;
        TextAnchorType anchor = TextAnchorType::Center;
        float max_angle = 45.0f /* degrees */;
        float rotate = 0.0f;
        float padding = 2.0f;
        bool keep_upright = true;
        TextTransformType transform = TextTransformType::None;
        std::array<float, 2> offset = {{ 0, 0 }};
        bool allow_overlap = false;
        bool ignore_placement = false;
        bool optional = false;
    } text;
};

class StyleBucketRaster {
public:
    // Make movable only.
    StyleBucketRaster() = default;
    StyleBucketRaster(StyleBucketRaster &&) = default;
    StyleBucketRaster& operator=(StyleBucketRaster &&) = default;
    StyleBucketRaster(const StyleBucketRaster &) = delete;
    StyleBucketRaster& operator=(const StyleBucketRaster &) = delete;
};

class StyleBucketBackground {
public:
};

typedef mapbox::util::variant<StyleBucketFill, StyleBucketLine, StyleBucketSymbol,
                              StyleBucketRaster, StyleBucketBackground, std::false_type> StyleBucketRender;


class StyleBucket : public util::noncopyable {
public:
    typedef util::ptr<StyleBucket> Ptr;

    StyleBucket(StyleLayerType type);
    StyleLayerType type;
    std::string name;
    util::ptr<StyleSource> style_source;
    std::string source_layer;
    FilterExpression filter;
    ClassProperties layout;
    StyleBucketRender render = std::false_type();
    float min_zoom = -std::numeric_limits<float>::infinity();
    float max_zoom = std::numeric_limits<float>::infinity();
    VisibilityType visibility = VisibilityType::Visible;
};

template <typename T>
const T &defaultLayoutProperties();

};

#endif