[core] When reparsing a tile, replace all existing buckets

A tile may go from having particular layers, to not having them.
(Annotation tiles in particular.)
This commit is contained in:
John Firebaugh
2015-10-29 12:01:05 -07:00
parent f6f5d9608d
commit f745f271e3
3 changed files with 4 additions and 5 deletions

View File

@@ -287,6 +287,6 @@ void TileWorker::createSymbolBucket(const GeometryTileLayer& layer,
void TileWorker::insertBucket(const std::string& name, std::unique_ptr<Bucket> bucket) {
if (bucket->hasData()) {
result.buckets.emplace_back(name, std::move(bucket));
result.buckets.emplace(name, std::move(bucket));
}
}

View File

@@ -31,7 +31,7 @@ class GeometryTileLayer;
class TileParseResultBuckets {
public:
TileData::State state = TileData::State::invalid;
std::vector<std::pair<std::string, std::unique_ptr<Bucket>>> buckets;
std::unordered_map<std::string, std::unique_ptr<Bucket>> buckets;
};
using TileParseResult = mapbox::util::variant<TileParseResultBuckets, // success

View File

@@ -39,6 +39,7 @@ VectorTileData::VectorTileData(const TileID& id_,
if (!tile) {
state = State::parsed;
buckets.clear();
callback();
return;
}
@@ -69,9 +70,7 @@ VectorTileData::VectorTileData(const TileID& id_,
// Move over all buckets we received in this parse request, potentially overwriting
// existing buckets in case we got a refresh parse.
for (auto& bucket : resultBuckets.buckets) {
buckets[bucket.first] = std::move(bucket.second);
}
buckets = std::move(resultBuckets.buckets);
// The target configuration could have changed since we started placement. In this case,
// we're starting another placement run.