diff options
author | Konstantin Käfer <mail@kkaefer.com> | 2017-06-19 19:17:09 -0700 |
---|---|---|
committer | Konstantin Käfer <mail@kkaefer.com> | 2017-06-21 17:18:08 -0700 |
commit | 2cc330463d11a9767cbee4a028804e026c76d63b (patch) | |
tree | 7b59f9cf3aa9bf1f5029050e1cc77779a1e2b557 /src/mbgl/tile/vector_tile_data.hpp | |
parent | 0f300d8dcda0fab8c6edf7b4759dd545f790c63f (diff) | |
download | qtlocation-mapboxgl-2cc330463d11a9767cbee4a028804e026c76d63b.tar.gz |
[core] switch to vector-tile library for decoding Mapbox vector tiles
Diffstat (limited to 'src/mbgl/tile/vector_tile_data.hpp')
-rw-r--r-- | src/mbgl/tile/vector_tile_data.hpp | 57 |
1 files changed, 13 insertions, 44 deletions
diff --git a/src/mbgl/tile/vector_tile_data.hpp b/src/mbgl/tile/vector_tile_data.hpp index 57b42ecd19..5ecb591273 100644 --- a/src/mbgl/tile/vector_tile_data.hpp +++ b/src/mbgl/tile/vector_tile_data.hpp @@ -1,5 +1,6 @@ #include <mbgl/tile/geometry_tile_data.hpp> +#include <mapbox/vector_tile.hpp> #include <protozero/pbf_reader.hpp> #include <unordered_map> @@ -8,75 +9,43 @@ namespace mbgl { -class VectorTileLayer; - -using packed_iter_type = protozero::iterator_range<protozero::pbf_reader::const_uint32_iterator>; - -struct VectorTileLayerData { - VectorTileLayerData(std::shared_ptr<const std::string>); - - // Hold a reference to the underlying pbf data that backs the lazily-built - // components of the owning VectorTileLayer and VectorTileFeature objects - std::shared_ptr<const std::string> data; - - uint32_t version = 1; - uint32_t extent = 4096; - std::unordered_map<std::string, uint32_t> keysMap; - std::vector<std::reference_wrapper<const std::string>> keys; - std::vector<Value> values; -}; - class VectorTileFeature : public GeometryTileFeature { public: - VectorTileFeature(protozero::pbf_reader, std::shared_ptr<VectorTileLayerData> layerData); + VectorTileFeature(const mapbox::vector_tile::layer&, const protozero::data_view&); - FeatureType getType() const override { return type; } - optional<Value> getValue(const std::string&) const override; - std::unordered_map<std::string,Value> getProperties() const override; + FeatureType getType() const override; + optional<Value> getValue(const std::string& key) const override; + std::unordered_map<std::string, Value> getProperties() const override; optional<FeatureIdentifier> getID() const override; GeometryCollection getGeometries() const override; private: - std::shared_ptr<VectorTileLayerData> layerData; - optional<FeatureIdentifier> id; - FeatureType type = FeatureType::Unknown; - packed_iter_type tags_iter; - packed_iter_type geometry_iter; + mapbox::vector_tile::feature feature; }; class VectorTileLayer : public GeometryTileLayer { public: - VectorTileLayer(protozero::pbf_reader, std::shared_ptr<const std::string>); + VectorTileLayer(std::shared_ptr<const std::string> data, const protozero::data_view&); - std::size_t featureCount() const override { return features.size(); } - std::unique_ptr<GeometryTileFeature> getFeature(std::size_t) const override; + std::size_t featureCount() const override; + std::unique_ptr<GeometryTileFeature> getFeature(std::size_t i) const override; std::string getName() const override; private: - friend class VectorTileData; - friend class VectorTileFeature; - - std::string name; - std::vector<protozero::pbf_reader> features; - std::shared_ptr<VectorTileLayerData> data; + std::shared_ptr<const std::string> data; + mapbox::vector_tile::layer layer; }; class VectorTileData : public GeometryTileData { public: VectorTileData(std::shared_ptr<const std::string> data); - std::unique_ptr<GeometryTileData> clone() const override { - return std::make_unique<VectorTileData>(*this); - } - - const GeometryTileLayer* getLayer(const std::string&) const override; + std::unique_ptr<GeometryTileData> clone() const override; + const GeometryTileLayer* getLayer(const std::string& name) const override; std::vector<std::string> layerNames() const; private: - void parse() const; - -private: std::shared_ptr<const std::string> data; mutable bool parsed = false; mutable std::unordered_map<std::string, VectorTileLayer> layers; |