summaryrefslogtreecommitdiff
path: root/src/mbgl/annotation/annotation_tile.hpp
blob: ca6b074c210eb089d34fee45cc57c4c473006883 (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
#ifndef MBGL_ANNOTATION_TILE
#define MBGL_ANNOTATION_TILE

#include <mbgl/tile/geometry_tile.hpp>
#include <mbgl/map/tile_id.hpp>

#include <map>
#include <unordered_map>

namespace mbgl {

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

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

    const FeatureType type;
    const std::unordered_map<std::string, std::string> properties;
    const GeometryCollection geometries;
};

class AnnotationTileLayer : public GeometryTileLayer {
public:
    std::size_t featureCount() const override { return features.size(); }
    util::ptr<const GeometryTileFeature> getFeature(std::size_t i) const override { return features[i]; }

    std::vector<util::ptr<const AnnotationTileFeature>> features;
};

class AnnotationTile : public GeometryTile {
public:
    util::ptr<GeometryTileLayer> getLayer(const std::string&) const override;

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

class MapData;

class AnnotationTileMonitor : public GeometryTileMonitor {
public:
    // TODO: should just take AnnotationManager&, but we need to eliminate util::exclusive<AnnotationManager> from MapData first.
    AnnotationTileMonitor(const TileID&, MapData&);
    ~AnnotationTileMonitor();

    void update(std::unique_ptr<GeometryTile>);
    std::unique_ptr<AsyncRequest> monitorTile(const GeometryTileMonitor::Callback&) override;

    TileID tileID;

private:
    MapData& data;
    GeometryTileMonitor::Callback callback;
};

} // namespace mbgl

#endif