summaryrefslogtreecommitdiff
path: root/include/mbgl/map/tile_parser.hpp
blob: beae3af831cc3371cd38511c0456ecb3caa6f5de (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
#ifndef MBGL_MAP_TILE_PARSER
#define MBGL_MAP_TILE_PARSER

#include <mbgl/map/vector_tile.hpp>
#include <mbgl/style/filter_expression.hpp>
#include <mbgl/text/glyph.hpp>
#include <mbgl/util/ptr.hpp>
#include <mbgl/util/noncopyable.hpp>
#include <cstdint>
#include <iosfwd>
#include <string>

namespace mbgl {

class Bucket;
class TexturePool;
class FontStack;
class GlyphAtlas;
class GlyphStore;
class SpriteAtlas;
class Sprite;
class Style;
class StyleBucket;
class StyleBucketFill;
class StyleBucketRaster;
class StyleBucketLine;
class StyleBucketSymbol;
class StyleLayerGroup;
class VectorTileData;
class Collision;
class TexturePool;

class TileParser : private util::noncopyable
{
public:
    TileParser(const std::string &data, VectorTileData &tile,
               const util::ptr<const Style> &style,
               GlyphAtlas & glyphAtlas,
               GlyphStore & glyphStore,
               SpriteAtlas & spriteAtlas,
               const util::ptr<Sprite> &sprite,
               TexturePool& texturePool);
    ~TileParser();

public:
    void parse();

private:
    bool obsolete() const;
    void parseStyleLayers(util::ptr<StyleLayerGroup> group);
    std::unique_ptr<Bucket> createBucket(util::ptr<StyleBucket> bucket_desc);

    std::unique_ptr<Bucket> createFillBucket(const VectorTileLayer& layer, const FilterExpression &filter, const StyleBucketFill &fill);
    std::unique_ptr<Bucket> createRasterBucket(const StyleBucketRaster &raster);
    std::unique_ptr<Bucket> createLineBucket(const VectorTileLayer& layer, const FilterExpression &filter, const StyleBucketLine &line);
    std::unique_ptr<Bucket> createSymbolBucket(const VectorTileLayer& layer, const FilterExpression &filter, const StyleBucketSymbol &symbol);

    template <class Bucket> void addBucketGeometries(Bucket& bucket, const VectorTileLayer& layer, const FilterExpression &filter);

private:
    const VectorTile vector_data;
    VectorTileData& tile;

    // Cross-thread shared data.
    util::ptr<const Style> style;
    GlyphAtlas & glyphAtlas;
    GlyphStore & glyphStore;
    SpriteAtlas & spriteAtlas;
    util::ptr<Sprite> sprite;
    TexturePool& texturePool;

    std::unique_ptr<Collision> collision;
};

}

#endif