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
|
#include <mbgl/map/annotation.hpp>
#include <mbgl/map/live_tile_data.hpp>
#include <mbgl/map/live_tile.hpp>
#include <mbgl/style/style_layer.hpp>
#include <mbgl/map/source.hpp>
#include <mbgl/text/collision_tile.hpp>
#include <mbgl/util/worker.hpp>
#include <mbgl/util/work_request.hpp>
#include <mbgl/style/style.hpp>
#include <sstream>
using namespace mbgl;
LiveTileData::LiveTileData(const TileID& id_,
const LiveTile* tile,
Style& style_,
const SourceInfo& source_,
std::function<void()> callback)
: TileData(id_),
worker(style_.workers),
tileWorker(id_,
source_.source_id,
source_.max_zoom,
style_,
style_.layers,
state,
std::make_unique<CollisionTile>(0, 0, false)) {
state = State::loaded;
if (!tile) {
state = State::parsed;
return;
}
workRequest = worker.parseLiveTile(tileWorker, *tile, [this, callback] (TileParseResult result) {
if (result.is<State>()) {
state = result.get<State>();
} else {
error = result.get<std::string>();
state = State::obsolete;
}
callback();
});
}
LiveTileData::~LiveTileData() {
cancel();
}
Bucket* LiveTileData::getBucket(const StyleLayer& layer) {
if (!isReady() || !layer.bucket) {
return nullptr;
}
return tileWorker.getBucket(layer);
}
void LiveTileData::cancel() {
state = State::obsolete;
workRequest.reset();
}
|