summaryrefslogtreecommitdiff
path: root/src/mbgl/annotation/annotation_manager.hpp
diff options
context:
space:
mode:
authorJohn Firebaugh <john.firebaugh@gmail.com>2015-09-21 17:39:17 -0700
committerJohn Firebaugh <john.firebaugh@gmail.com>2015-09-28 14:10:01 -0700
commit0c4c7ed901a2c984f120b1f23abf0dd528991b38 (patch)
tree1f18fb15910e702794014000efd770647f07a5c2 /src/mbgl/annotation/annotation_manager.hpp
parent588fed9a9d01e03165ff70b537b892995a1d24e3 (diff)
downloadqtlocation-mapboxgl-0c4c7ed901a2c984f120b1f23abf0dd528991b38.tar.gz
map/annotation.* ⇢ annotation/annotation_manager.*
Diffstat (limited to 'src/mbgl/annotation/annotation_manager.hpp')
-rw-r--r--src/mbgl/annotation/annotation_manager.hpp81
1 files changed, 81 insertions, 0 deletions
diff --git a/src/mbgl/annotation/annotation_manager.hpp b/src/mbgl/annotation/annotation_manager.hpp
new file mode 100644
index 0000000000..60cafdf342
--- /dev/null
+++ b/src/mbgl/annotation/annotation_manager.hpp
@@ -0,0 +1,81 @@
+#ifndef MBGL_MAP_ANNOTATIONS
+#define MBGL_MAP_ANNOTATIONS
+
+#include <mbgl/map/map.hpp>
+#include <mbgl/map/geometry_tile.hpp>
+#include <mbgl/map/tile_id.hpp>
+#include <mbgl/style/style_properties.hpp>
+#include <mbgl/style/types.hpp>
+#include <mbgl/util/geo.hpp>
+#include <mbgl/util/geojsonvt/geojsonvt.hpp>
+#include <mbgl/util/noncopyable.hpp>
+#include <mbgl/util/vec.hpp>
+
+#include <string>
+#include <vector>
+#include <memory>
+#include <unordered_map>
+#include <unordered_set>
+
+namespace mbgl {
+
+class Annotation;
+class PointAnnotation;
+class ShapeAnnotation;
+class LiveTile;
+
+using GeoJSONVT = mapbox::util::geojsonvt::GeoJSONVT;
+
+class AnnotationManager : private util::noncopyable {
+public:
+ typedef std::unordered_set<TileID, TileID::Hash> AffectedTiles;
+
+ AnnotationManager();
+ ~AnnotationManager();
+
+ void markStaleTiles(std::unordered_set<TileID, TileID::Hash>);
+ size_t getStaleTileCount() const { return staleTiles.size(); }
+ std::unordered_set<TileID, TileID::Hash> resetStaleTiles();
+
+ void setDefaultPointAnnotationSymbol(const std::string& symbol);
+
+ std::pair<AffectedTiles, AnnotationIDs>
+ addPointAnnotations(const std::vector<PointAnnotation>&, const uint8_t maxZoom);
+
+ std::pair<AffectedTiles, AnnotationIDs>
+ addShapeAnnotations(const std::vector<ShapeAnnotation>&, const uint8_t maxZoom);
+
+ AffectedTiles
+ removeAnnotations(const AnnotationIDs&, const uint8_t maxZoom);
+
+ AnnotationIDs getOrderedShapeAnnotations() const { return orderedShapeAnnotations; }
+ const StyleProperties getAnnotationStyleProperties(uint32_t) const;
+
+ AnnotationIDs getAnnotationsInBounds(const LatLngBounds&, const uint8_t maxZoom, const AnnotationType& = AnnotationType::Any) const;
+ LatLngBounds getBoundsForAnnotations(const AnnotationIDs&) const;
+
+ const LiveTile* getTile(const TileID& id);
+
+ static const std::string PointLayerID;
+ static const std::string ShapeLayerID;
+
+private:
+ inline uint32_t nextID();
+ static vec2<double> projectPoint(const LatLng& point);
+
+ uint32_t addShapeAnnotation(const ShapeAnnotation&, const uint8_t maxZoom);
+ uint32_t addPointAnnotation(const PointAnnotation&, const uint8_t maxZoom, AffectedTiles&);
+
+private:
+ std::string defaultPointAnnotationSymbol;
+ std::unordered_map<uint32_t, std::unique_ptr<Annotation>> annotations;
+ std::vector<uint32_t> orderedShapeAnnotations;
+ std::unordered_map<TileID, std::pair<std::unordered_set<uint32_t>, std::unique_ptr<LiveTile>>, TileID::Hash> tiles;
+ std::unordered_map<uint32_t, std::unique_ptr<GeoJSONVT>> shapeTilers;
+ std::unordered_set<TileID, TileID::Hash> staleTiles;
+ uint32_t nextID_ = 0;
+};
+
+}
+
+#endif