move tile parsing to its own object

This commit is contained in:
Konstantin Käfer
2014-03-12 17:47:40 +01:00
parent be44b6b31f
commit 99cef810ac
4 changed files with 204 additions and 174 deletions

View File

@@ -8,6 +8,7 @@
#include <llmr/geometry/glyph_atlas.hpp>
#include <llmr/geometry/debug_font_buffer.hpp>
#include <llmr/geometry/vao.hpp>
#include <llmr/map/vector_tile.hpp>
#include <llmr/platform/platform.hpp>
#include <cstdint>
@@ -24,9 +25,6 @@ class Style;
class Bucket;
class LayerDescription;
class BucketDescription;
class VectorTile;
class VectorTileLayer;
class VectorTileFace;
class FillVertexBuffer;
class LineVertexBuffer;
class PointVertexBuffer;
@@ -59,26 +57,12 @@ public:
TileData(Tile::ID id, const Style& style, GlyphAtlas& glyphAtlas);
~TileData();
// Start loading the tile.
void request();
// Other functions
bool parse();
void parseStyleLayers(const VectorTile& tile, const std::vector<LayerDescription>& layers);
std::shared_ptr<Bucket> createBucket(const VectorTile& tile, const BucketDescription& bucket_desc);
template <class Bucket> void addBucketFeatures(Bucket& bucket, const VectorTileLayer& layer, const BucketDescription& bucket_desc);
std::shared_ptr<Bucket> createFillBucket(const VectorTile& tile, const VectorTileLayer& layer, const BucketDescription& bucket_desc);
std::shared_ptr<Bucket> createLineBucket(const VectorTile& tile, const VectorTileLayer& layer, const BucketDescription& bucket_desc);
std::shared_ptr<Bucket> createPointBucket(const VectorTile& tile, const VectorTileLayer& layer, const BucketDescription& bucket_desc);
std::shared_ptr<Bucket> createTextBucket(const VectorTile& tile, const VectorTileLayer& layer, const BucketDescription& bucket_desc);
void cancel();
const std::string toString() const;
private:
void loadGlyphs(const std::map<std::string, const VectorTileFace>& faces);
public:
const Tile::ID id;
std::atomic<State> state;

View File

@@ -0,0 +1,36 @@
#ifndef LLMR_MAP_TILE_PARSER
#define LLMR_MAP_TILE_PARSER
#include <llmr/map/tile_data.hpp>
namespace llmr {
typedef std::map<uint32_t, Rect<uint16_t>> GlyphPositions;
typedef std::map<std::string, GlyphPositions> FaceGlyphPositions;
class TileParser {
public:
TileParser(const std::string& data, TileData& tile, const Style& style, GlyphAtlas& glyphAtlas);
private:
bool obsolete() const;
void parseGlyphs();
void parseStyleLayers(const std::vector<LayerDescription>& layers);
std::shared_ptr<Bucket> createBucket(const BucketDescription& bucket_desc);
std::shared_ptr<Bucket> createFillBucket(const VectorTileLayer& layer, const BucketDescription& bucket_desc);
std::shared_ptr<Bucket> createLineBucket(const VectorTileLayer& layer, const BucketDescription& bucket_desc);
std::shared_ptr<Bucket> createPointBucket(const VectorTileLayer& layer, const BucketDescription& bucket_desc);
std::shared_ptr<Bucket> createTextBucket(const VectorTileLayer& layer, const BucketDescription& bucket_desc);
template <class Bucket> void addBucketFeatures(Bucket& bucket, const VectorTileLayer& layer, const BucketDescription& bucket_desc);
private:
const VectorTile data;
TileData& tile;
const Style& style;
GlyphAtlas& glyphAtlas;
FaceGlyphPositions rects;
};
}
#endif