Calculate clip IDs with a huffman prefix tree

This changes the clip IDs from sequential to a huffman prefix tree, meaning that
parent tiles share the same prefix with child tiles (but are shorter). This allows
us to use the same checkerboard pattern to draw all tiles.

TODO:
- make sure we're not overflowing the 8 bit limit of the stencil buffer
- draw all checkerboard fields at the same time, with one draw call
- fix raster drawing (fading, clipping)

refs #132
This commit is contained in:
Konstantin Käfer
2014-05-09 18:10:28 +02:00
parent 70a7ba81f3
commit 0bfd7b0f43
32 changed files with 1129 additions and 290 deletions

View File

@@ -0,0 +1,43 @@
#include <llmr/map/vector_tile_data.hpp>
#include <llmr/map/map.hpp>
#include <llmr/map/tile_parser.hpp>
using namespace llmr;
VectorTileData::VectorTileData(Tile::ID id, Map &map, const std::string url)
: TileData(id, map, url) {
}
VectorTileData::~VectorTileData() {
map.getGlyphAtlas().removeGlyphs(id.to_uint64());
}
void VectorTileData::parse() {
if (state != State::loaded) {
return;
}
try {
// Parsing creates state that is encapsulated in TileParser. While parsing,
// the TileParser object writes results into this objects. All other state
// is going to be discarded afterwards.
TileParser parser(data, *this, map.getStyle(), map.getGlyphAtlas());
} catch (const std::exception& ex) {
fprintf(stderr, "[%p] exception [%d/%d/%d]... failed: %s\n", this, id.z, id.x, id.y, ex.what());
cancel();
return;
}
if (state != State::obsolete) {
state = State::parsed;
}
}
void VectorTileData::render(Painter &painter, const LayerDescription& layer_desc) {
auto databucket_it = buckets.find(layer_desc.bucket_name);
if (databucket_it != buckets.end()) {
assert(databucket_it->second);
databucket_it->second->render(painter, layer_desc.name, id);
}
}