diff options
author | Konstantin Käfer <mail@kkaefer.com> | 2017-06-20 11:40:56 -0700 |
---|---|---|
committer | Konstantin Käfer <mail@kkaefer.com> | 2017-06-21 17:18:08 -0700 |
commit | 4ea47151796cb885fbcb2dd3803aa3f7132467bb (patch) | |
tree | 3c10360ed2da83e4e912576560ba2841b0af9597 /src/mbgl/annotation/annotation_tile.hpp | |
parent | 4bfc5592239d96d6d352ddbbb906dde0ea4012be (diff) | |
download | qtlocation-mapboxgl-4ea47151796cb885fbcb2dd3803aa3f7132467bb.tar.gz |
[core] shared data among AnnotationTileFeature objects
Diffstat (limited to 'src/mbgl/annotation/annotation_tile.hpp')
-rw-r--r-- | src/mbgl/annotation/annotation_tile.hpp | 37 |
1 files changed, 23 insertions, 14 deletions
diff --git a/src/mbgl/annotation/annotation_tile.hpp b/src/mbgl/annotation/annotation_tile.hpp index ea4ff5ebd5..68a4d342ac 100644 --- a/src/mbgl/annotation/annotation_tile.hpp +++ b/src/mbgl/annotation/annotation_tile.hpp @@ -11,8 +11,7 @@ class TileParameters; class AnnotationTile : public GeometryTile { public: - AnnotationTile(const OverscaledTileID&, - const TileParameters&); + AnnotationTile(const OverscaledTileID&, const TileParameters&); ~AnnotationTile() override; void setNecessity(Necessity) final; @@ -21,37 +20,45 @@ private: AnnotationManager& annotationManager; }; +class AnnotationTileFeatureData; + class AnnotationTileFeature : public GeometryTileFeature { public: - AnnotationTileFeature(AnnotationID, FeatureType, GeometryCollection, - std::unordered_map<std::string, std::string> properties = {{}}); + AnnotationTileFeature(std::shared_ptr<const AnnotationTileFeatureData>); + ~AnnotationTileFeature() override; - FeatureType getType() const override { return type; } + FeatureType getType() const override; optional<Value> getValue(const std::string&) const override; - optional<FeatureIdentifier> getID() const override { return { static_cast<uint64_t>(id) }; } - GeometryCollection getGeometries() const override { return geometries; } + optional<FeatureIdentifier> getID() const override; + GeometryCollection getGeometries() const override; - const AnnotationID id; - const FeatureType type; - const std::unordered_map<std::string, std::string> properties; - const GeometryCollection geometries; +private: + std::shared_ptr<const AnnotationTileFeatureData> data; }; class AnnotationTileLayer : public GeometryTileLayer { public: AnnotationTileLayer(std::string); - std::size_t featureCount() const override { return features.size(); } + std::size_t featureCount() const override { + return features.size(); + } std::unique_ptr<GeometryTileFeature> getFeature(std::size_t i) const override { return std::make_unique<AnnotationTileFeature>(features.at(i)); } - std::string getName() const override { return name; }; + std::string getName() const override { + return name; + } - std::vector<AnnotationTileFeature> features; + void addFeature(const AnnotationID, + FeatureType, + GeometryCollection, + std::unordered_map<std::string, std::string> properties = { {} }); private: + std::vector<std::shared_ptr<const AnnotationTileFeatureData>> features; std::string name; }; @@ -59,7 +66,9 @@ class AnnotationTileData : public GeometryTileData { public: std::unique_ptr<GeometryTileData> clone() const override; const GeometryTileLayer* getLayer(const std::string&) const override; + AnnotationTileLayer& addLayer(const std::string&); +private: std::unordered_map<std::string, AnnotationTileLayer> layers; }; |