1 | #include <mbgl/tile/geometry_tile_data.hpp> |
---|---|
2 | |
3 | #include <mapbox/vector_tile.hpp> |
4 | #include <protozero/pbf_reader.hpp> |
5 | |
6 | #include <unordered_map> |
7 | #include <functional> |
8 | #include <utility> |
9 | |
10 | namespace mbgl { |
11 | |
12 | class VectorTileFeature : public GeometryTileFeature { |
13 | public: |
14 | VectorTileFeature(const mapbox::vector_tile::layer&, const protozero::data_view&); |
15 | |
16 | FeatureType getType() const override; |
17 | optional<Value> getValue(const std::string& key) const override; |
18 | std::unordered_map<std::string, Value> getProperties() const override; |
19 | optional<FeatureIdentifier> getID() const override; |
20 | GeometryCollection getGeometries() const override; |
21 | |
22 | private: |
23 | mapbox::vector_tile::feature feature; |
24 | }; |
25 | |
26 | class VectorTileLayer : public GeometryTileLayer { |
27 | public: |
28 | VectorTileLayer(std::shared_ptr<const std::string> data, const protozero::data_view&); |
29 | |
30 | std::size_t featureCount() const override; |
31 | std::unique_ptr<GeometryTileFeature> getFeature(std::size_t i) const override; |
32 | std::string getName() const override; |
33 | |
34 | private: |
35 | std::shared_ptr<const std::string> data; |
36 | mapbox::vector_tile::layer layer; |
37 | }; |
38 | |
39 | class VectorTileData : public GeometryTileData { |
40 | public: |
41 | VectorTileData(std::shared_ptr<const std::string> data); |
42 | |
43 | std::unique_ptr<GeometryTileData> clone() const override; |
44 | std::unique_ptr<GeometryTileLayer> getLayer(const std::string& name) const override; |
45 | |
46 | std::vector<std::string> layerNames() const; |
47 | |
48 | private: |
49 | std::shared_ptr<const std::string> data; |
50 | mutable bool parsed = false; |
51 | mutable std::map<std::string, const protozero::data_view> layers; |
52 | }; |
53 | |
54 | } // namespace mbgl |
55 |