diff options
author | Konstantin Käfer <mail@kkaefer.com> | 2015-03-20 13:14:00 +0100 |
---|---|---|
committer | Konstantin Käfer <mail@kkaefer.com> | 2015-03-20 13:14:00 +0100 |
commit | f73dfc73f101e8023fe5719225cdec35c7e4a84b (patch) | |
tree | f1a3caedd2a60d860aaa4c8f2d017216e55a087c /include/mbgl | |
parent | 0cdf21c62d1f4ed8f54bd63b3f26459ef78a78d0 (diff) | |
download | qtlocation-mapboxgl-f73dfc73f101e8023fe5719225cdec35c7e4a84b.tar.gz |
make more things const and refs, and add mutexes
Diffstat (limited to 'include/mbgl')
-rw-r--r-- | include/mbgl/map/annotation.hpp | 50 | ||||
-rw-r--r-- | include/mbgl/map/map.hpp | 17 | ||||
-rw-r--r-- | include/mbgl/util/constants.hpp | 2 |
3 files changed, 25 insertions, 44 deletions
diff --git a/include/mbgl/map/annotation.hpp b/include/mbgl/map/annotation.hpp index e88d98b5c6..2eb0509d9a 100644 --- a/include/mbgl/map/annotation.hpp +++ b/include/mbgl/map/annotation.hpp @@ -2,7 +2,6 @@ #define MBGL_MAP_ANNOTATIONS #include <mbgl/map/tile.hpp> -#include <mbgl/map/live_tile.hpp> #include <mbgl/util/geo.hpp> #include <mbgl/util/noncopyable.hpp> #include <mbgl/util/std.hpp> @@ -18,55 +17,38 @@ namespace mbgl { class Annotation; class Map; +class LiveTile; -typedef std::vector<LatLng> AnnotationSegment; - -enum class AnnotationType : uint8_t { - Point, - Shape -}; +using AnnotationIDs = std::vector<uint32_t>; class AnnotationManager : private util::noncopyable { public: AnnotationManager(); + ~AnnotationManager(); + + void setDefaultPointAnnotationSymbol(const std::string& symbol); + std::pair<std::vector<Tile::ID>, AnnotationIDs> addPointAnnotations( + const std::vector<LatLng>&, const std::vector<std::string>& symbols, const Map&); + std::vector<Tile::ID> removeAnnotations(const AnnotationIDs&); + AnnotationIDs getAnnotationsInBounds(const LatLngBounds&, const Map&) const; + LatLngBounds getBoundsForAnnotations(const AnnotationIDs&) const; - void setDefaultPointAnnotationSymbol(std::string& symbol) { defaultPointAnnotationSymbol = symbol; } - std::pair<std::vector<Tile::ID>, std::vector<uint32_t>> addPointAnnotations(std::vector<LatLng>, std::vector<std::string>& symbols, const Map&); - std::vector<Tile::ID> removeAnnotations(std::vector<uint32_t>); - std::vector<uint32_t> getAnnotationsInBounds(LatLngBounds, const Map&) const; - LatLngBounds getBoundsForAnnotations(std::vector<uint32_t>) const; + const LiveTile* getTile(Tile::ID const& id); - const std::unique_ptr<LiveTile>& getTile(Tile::ID const& id); + static const std::string layerID; private: - uint32_t nextID() { return nextID_++; } - static vec2<double> projectPoint(LatLng& point); + inline uint32_t nextID(); + static vec2<double> projectPoint(const LatLng& point); private: - std::mutex mtx; + mutable std::mutex mtx; std::string defaultPointAnnotationSymbol; std::map<uint32_t, std::unique_ptr<Annotation>> annotations; - std::map<Tile::ID, std::pair<std::vector<uint32_t>, std::unique_ptr<LiveTile>>> annotationTiles; - std::unique_ptr<LiveTile> nullTile; + std::map<Tile::ID, std::pair<AnnotationIDs, std::unique_ptr<LiveTile>>> annotationTiles; uint32_t nextID_ = 0; }; -class Annotation : private util::noncopyable { - friend class AnnotationManager; -public: - Annotation(AnnotationType, std::vector<AnnotationSegment>); - -private: - LatLng getPoint() const; - LatLngBounds getBounds() const { return bounds; } - -private: - const AnnotationType type = AnnotationType::Point; - const std::vector<AnnotationSegment> geometry; - std::map<Tile::ID, std::vector<std::weak_ptr<const LiveTileFeature>>> tileFeatures; - LatLngBounds bounds; -}; - } #endif diff --git a/include/mbgl/map/map.hpp b/include/mbgl/map/map.hpp index 86c89f769d..5e217a706b 100644 --- a/include/mbgl/map/map.hpp +++ b/include/mbgl/map/map.hpp @@ -142,13 +142,14 @@ public: inline const LatLng latLngForPixel(const vec2<double> pixel) const { return state.latLngForPixel(pixel); } // Annotations - void setDefaultPointAnnotationSymbol(std::string&); - uint32_t addPointAnnotation(LatLng, std::string& symbol); - std::vector<uint32_t> addPointAnnotations(std::vector<LatLng>, std::vector<std::string>& symbols); + void setDefaultPointAnnotationSymbol(const std::string&); + uint32_t addPointAnnotation(const LatLng&, const std::string& symbol); + std::vector<uint32_t> addPointAnnotations(const std::vector<LatLng>&, + const std::vector<std::string>& symbols); void removeAnnotation(uint32_t); - void removeAnnotations(std::vector<uint32_t>); - std::vector<uint32_t> getAnnotationsInBounds(LatLngBounds) const; - LatLngBounds getBoundsForAnnotations(std::vector<uint32_t>) const; + void removeAnnotations(const std::vector<uint32_t>&); + std::vector<uint32_t> getAnnotationsInBounds(const LatLngBounds&) const; + LatLngBounds getBoundsForAnnotations(const std::vector<uint32_t>&) const; // Debug void setDebug(bool value); @@ -181,7 +182,7 @@ private: // the stylesheet. void prepare(); - void updateAnnotationTiles(std::vector<Tile::ID>&); + void updateAnnotationTiles(const std::vector<Tile::ID>&); enum class Mode : uint8_t { None, // we're not doing any processing @@ -230,7 +231,7 @@ private: const std::unique_ptr<LineAtlas> lineAtlas; util::ptr<TexturePool> texturePool; const std::unique_ptr<Painter> painter; - util::ptr<AnnotationManager> annotationManager; + const std::unique_ptr<AnnotationManager> annotationManager; std::string styleURL; std::string styleJSON = ""; diff --git a/include/mbgl/util/constants.hpp b/include/mbgl/util/constants.hpp index 9e0856b68a..e598806c20 100644 --- a/include/mbgl/util/constants.hpp +++ b/include/mbgl/util/constants.hpp @@ -16,8 +16,6 @@ extern const double M2PI; extern const double EARTH_RADIUS_M; extern const double LATITUDE_MAX; -extern const std::string ANNOTATIONS_POINTS_LAYER_ID; - } namespace debug { |