Skip to content
This repository has been archived by the owner on Aug 8, 2023. It is now read-only.

Commit

Permalink
[core] When reparsing a tile, replace all existing buckets
Browse files Browse the repository at this point in the history
A tile may go from having particular layers, to not having them.
(Annotation tiles in particular.)
  • Loading branch information
jfirebaugh committed Oct 30, 2015
1 parent c06812a commit 5f7dfa0
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/mbgl/map/tile_worker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}
}
2 changes: 1 addition & 1 deletion src/mbgl/map/tile_worker.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 2 additions & 3 deletions src/mbgl/map/vector_tile_data.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ VectorTileData::VectorTileData(const TileID& id_,

if (!tile) {
state = State::parsed;
buckets.clear();
callback();
return;
}
Expand Down Expand Up @@ -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.
Expand Down

0 comments on commit 5f7dfa0

Please sign in to comment.