summaryrefslogtreecommitdiff
path: root/src/mbgl/map/live_tile.hpp
blob: b13b5a1f66149c3070f61ffa23d08cef55b2d279 (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
#ifndef MBGL_MAP_LIVE_TILE
#define MBGL_MAP_LIVE_TILE

#include <map>

#include <mbgl/map/geometry_tile.hpp>

namespace mbgl {

class LiveTileFeature : public GeometryTileFeature {
public:
    LiveTileFeature(FeatureType, GeometryCollection, std::map<std::string, std::string> properties = {{}});

    FeatureType getType() const override { return type; }
    mapbox::util::optional<Value> getValue(const std::string&) const override;
    GeometryCollection getGeometries() const override { return geometries; }

private:
    FeatureType type = FeatureType::Unknown;
    std::map<std::string, std::string> properties;
    GeometryCollection geometries;
};

class LiveTileLayer : public GeometryTileLayer {
public:
    LiveTileLayer();

    void prepareToAddFeatures(size_t count);
    void addFeature(util::ptr<const LiveTileFeature>);
    void removeFeature(util::ptr<const LiveTileFeature>);
    std::size_t featureCount() const override { return features.size(); }
    util::ptr<const GeometryTileFeature> getFeature(std::size_t i) const override { return features[i]; }

private:
    std::vector<util::ptr<const LiveTileFeature>> features;
};

class LiveTile : public GeometryTile {
public:
    LiveTile();

    void addLayer(const std::string&, util::ptr<LiveTileLayer>);
    util::ptr<GeometryTileLayer> getLayer(const std::string&) const override;
    util::ptr<LiveTileLayer> getMutableLayer(const std::string&) const;

private:
    std::map<std::string, util::ptr<LiveTileLayer>> layers;
};

}

#endif