Add partial tile parsing
This change will add a new state to the tile called "partial" which is a state where the tile can be rendered but some information might be missing. For now we skip the SymbolBucket if the Sprites are not loaded (will also do the same for the glyphs in the future). When the Sprites are finally loaded, we trigger another update, this time the Tile will get completely re-rendered and change the state to "parsed".
This commit is contained in:
@@ -35,7 +35,7 @@ VectorTileData::~VectorTileData() {
|
||||
}
|
||||
|
||||
void VectorTileData::parse() {
|
||||
if (state != State::loaded) {
|
||||
if (state != State::loaded && state != State::partial) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -47,24 +47,47 @@ void VectorTileData::parse() {
|
||||
const VectorTile* vt = &vectorTile;
|
||||
TileParser parser(*vt, *this, style, glyphAtlas, glyphStore, spriteAtlas, sprite);
|
||||
parser.parse();
|
||||
|
||||
if (state == State::obsolete) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (parser.isPartialParse()) {
|
||||
state = State::partial;
|
||||
} else {
|
||||
state = State::parsed;
|
||||
}
|
||||
} catch (const std::exception& ex) {
|
||||
Log::Error(Event::ParseTile, "Parsing [%d/%d/%d] failed: %s", id.z, id.x, id.y, ex.what());
|
||||
state = State::obsolete;
|
||||
return;
|
||||
}
|
||||
|
||||
if (state != State::obsolete) {
|
||||
state = State::parsed;
|
||||
}
|
||||
}
|
||||
|
||||
Bucket* VectorTileData::getBucket(StyleLayer const& layer) {
|
||||
if (state == State::parsed && layer.bucket) {
|
||||
const auto it = buckets.find(layer.bucket->name);
|
||||
if (it != buckets.end()) {
|
||||
assert(it->second);
|
||||
return it->second.get();
|
||||
}
|
||||
if (!ready() || !layer.bucket) {
|
||||
return nullptr;
|
||||
}
|
||||
return nullptr;
|
||||
|
||||
std::lock_guard<std::mutex> lock(bucketsMutex);
|
||||
|
||||
const auto it = buckets.find(layer.bucket->name);
|
||||
if (it == buckets.end()) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
assert(it->second);
|
||||
return it->second.get();
|
||||
}
|
||||
|
||||
void VectorTileData::setBucket(StyleLayer const& layer, std::unique_ptr<Bucket> bucket) {
|
||||
assert(layer.bucket);
|
||||
|
||||
std::lock_guard<std::mutex> lock(bucketsMutex);
|
||||
|
||||
if (buckets.find(layer.bucket->name) != buckets.end()) {
|
||||
return;
|
||||
}
|
||||
|
||||
buckets[layer.bucket->name] = std::move(bucket);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user