#ifndef LLMR_MAP_TILE #define LLMR_MAP_TILE #include "../geometry/debug_font_buffer.hpp" #include "../geometry/fill_buffer.hpp" #include "../geometry/line_buffer.hpp" #include "layer.hpp" #include "vector_tile.hpp" #include #include #include #include #include #include #include namespace llmr { struct pbf; class Style; class Bucket; class LayerDescription; class BucketDescription; class Tile : public std::enable_shared_from_this { public: struct exception : std::exception {}; struct geometry_too_long_exception : exception {}; public: typedef std::shared_ptr Ptr; typedef vec3 ID; enum state { initial, loading, ready, obsolete }; public: Tile(ID id, const Style& style); ~Tile(); // Make noncopyable Tile(const Tile&) = delete; Tile(const Tile&&) = delete; Tile& operator=(const Tile&) = delete; Tile& operator=(const Tile && ) = delete; // Start loading the tile. void request(); // Other functions bool parse(); void parseStyleLayers(const std::vector& layers); std::shared_ptr createBucket(const BucketDescription& bucket_desc); std::shared_ptr createFillBucket(const VectorTileLayer& layer, const BucketDescription& bucket_desc); std::shared_ptr createLineBucket(const VectorTileLayer& layer, const BucketDescription& bucket_desc); void cancel(); const std::string toString() const; static ID parent(const ID& id, int32_t z); static std::forward_list children(const ID& id, int32_t z); public: const ID id; state state; // Holds the actual geometries in this tile. std::shared_ptr debugFontBuffer; std::shared_ptr fillBuffer; std::shared_ptr lineBuffer; // Holds the buckets of this tile. // They contain the location offsets in the buffers stored above std::map> buckets; // std::forward_list layers; private: // Source data std::string data; VectorTile tile; // std::mutex mtx; const Style& style; }; } #endif