summaryrefslogtreecommitdiff
path: root/src/mbgl/annotation/annotation_tile.cpp
blob: 3a038cc6eb63375ece206e8057d4ed79d69579ff (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
#include <mbgl/annotation/annotation_tile.hpp>
#include <mbgl/util/constants.hpp>
#include <mbgl/map/map_data.hpp>
#include <mbgl/storage/file_source.hpp>
#include <utility>

namespace mbgl {

AnnotationTileFeature::AnnotationTileFeature(FeatureType type_, GeometryCollection geometries_,
                                 std::unordered_map<std::string, std::string> properties_)
    : type(type_),
      properties(std::move(properties_)),
      geometries(std::move(geometries_)) {}

optional<Value> AnnotationTileFeature::getValue(const std::string& key) const {
    auto it = properties.find(key);
    if (it != properties.end()) {
        return optional<Value>(it->second);
    }
    return optional<Value>();
}

util::ptr<GeometryTileLayer> AnnotationTile::getLayer(const std::string& name) const {
    auto it = layers.find(name);
    if (it != layers.end()) {
        return it->second;
    }
    return nullptr;
}

AnnotationTileMonitor::AnnotationTileMonitor(const TileID& tileID_, MapData& data_)
    : tileID(tileID_),
      data(data_) {
}

AnnotationTileMonitor::~AnnotationTileMonitor() {
    data.getAnnotationManager()->removeTileMonitor(*this);
}

std::unique_ptr<FileRequest> AnnotationTileMonitor::monitorTile(const GeometryTileMonitor::Callback& callback_) {
    callback = callback_;
    data.getAnnotationManager()->addTileMonitor(*this);
    return nullptr;
}

void AnnotationTileMonitor::update(std::unique_ptr<GeometryTile> tile) {
    callback(nullptr, std::move(tile), {}, {});
}

} // namespace mbgl