diff options
author | John Firebaugh <john.firebaugh@gmail.com> | 2016-05-31 17:34:11 -0700 |
---|---|---|
committer | John Firebaugh <john.firebaugh@gmail.com> | 2016-06-01 17:37:01 -0700 |
commit | 0fba70d5a8465499b0dce900e5aa74f7189e4594 (patch) | |
tree | 7902b9bd29d25de0de6d116fc3245b1b269477f4 /src/mbgl/annotation/annotation_manager.hpp | |
parent | cfd6757ecc9bd4d9b1f4c5266d19da48c529f58b (diff) | |
download | qtlocation-mapboxgl-0fba70d5a8465499b0dce900e5aa74f7189e4594.tar.gz |
[all] Rationalize annotation API
Diffstat (limited to 'src/mbgl/annotation/annotation_manager.hpp')
-rw-r--r-- | src/mbgl/annotation/annotation_manager.hpp | 31 |
1 files changed, 20 insertions, 11 deletions
diff --git a/src/mbgl/annotation/annotation_manager.hpp b/src/mbgl/annotation/annotation_manager.hpp index aaa60278cf..6862739ebb 100644 --- a/src/mbgl/annotation/annotation_manager.hpp +++ b/src/mbgl/annotation/annotation_manager.hpp @@ -1,8 +1,7 @@ #pragma once #include <mbgl/annotation/annotation.hpp> -#include <mbgl/annotation/point_annotation_impl.hpp> -#include <mbgl/annotation/shape_annotation_impl.hpp> +#include <mbgl/annotation/symbol_annotation_impl.hpp> #include <mbgl/sprite/sprite_store.hpp> #include <mbgl/sprite/sprite_atlas.hpp> #include <mbgl/util/geo.hpp> @@ -11,13 +10,14 @@ #include <string> #include <vector> #include <set> +#include <unordered_map> namespace mbgl { -class PointAnnotation; -class ShapeAnnotation; class AnnotationTile; class AnnotationTileMonitor; +class SymbolAnnotationImpl; +class ShapeAnnotationImpl; class Style; class AnnotationManager : private util::noncopyable { @@ -25,10 +25,9 @@ public: AnnotationManager(float pixelRatio); ~AnnotationManager(); - AnnotationIDs addPointAnnotations(const std::vector<PointAnnotation>&, const uint8_t maxZoom); - AnnotationIDs addShapeAnnotations(const std::vector<ShapeAnnotation>&, const uint8_t maxZoom); - void updatePointAnnotation(const AnnotationID&, const PointAnnotation&, const uint8_t maxZoom); - void removeAnnotations(const AnnotationIDs&); + AnnotationID addAnnotation(const Annotation&, const uint8_t maxZoom); + void updateAnnotation(const AnnotationID&, const Annotation&, const uint8_t maxZoom); + void removeAnnotation(const AnnotationID&); AnnotationIDs getPointAnnotationsInBounds(const LatLngBounds&) const; @@ -46,12 +45,22 @@ public: static const std::string PointLayerID; private: + void add(const AnnotationID&, const SymbolAnnotation&, const uint8_t); + void add(const AnnotationID&, const LineAnnotation&, const uint8_t); + void add(const AnnotationID&, const FillAnnotation&, const uint8_t); + void add(const AnnotationID&, const StyleSourcedAnnotation&, const uint8_t); + std::unique_ptr<AnnotationTile> getTile(const CanonicalTileID&); AnnotationID nextID = 0; - PointAnnotationImpl::Tree pointTree; - PointAnnotationImpl::Map pointAnnotations; - ShapeAnnotationImpl::Map shapeAnnotations; + + using SymbolAnnotationTree = boost::geometry::index::rtree<std::shared_ptr<const SymbolAnnotationImpl>, boost::geometry::index::rstar<16, 4>>; + using SymbolAnnotationMap = std::unordered_map<AnnotationID, std::shared_ptr<SymbolAnnotationImpl>>; + using ShapeAnnotationMap = std::unordered_map<AnnotationID, std::unique_ptr<ShapeAnnotationImpl>>; + + SymbolAnnotationTree symbolTree; + SymbolAnnotationMap symbolAnnotations; + ShapeAnnotationMap shapeAnnotations; std::vector<std::string> obsoleteShapeAnnotationLayers; std::set<AnnotationTileMonitor*> monitors; |