summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorBrad Leege <bleege@gmail.com>2015-03-24 15:15:27 -0500
committerBrad Leege <bleege@gmail.com>2015-03-24 15:15:27 -0500
commit88398b2545f88d21c485ff318e7da18a4ee5c0d1 (patch)
treef80aa897cbe7323d75bce57f42ec861b2d405b9a /include
parent708ae14468222ae89aae6798063cf21b04635503 (diff)
parent2990f388240e6de586de6ebf20258503e68dad6a (diff)
downloadqtlocation-mapboxgl-88398b2545f88d21c485ff318e7da18a4ee5c0d1.tar.gz
Merge branch 'master' of github.com:mapbox/mapbox-gl-native into 1033-metrics
Conflicts: platform/ios/MGLMapView.mm
Diffstat (limited to 'include')
-rw-r--r--include/mbgl/map/annotation.hpp55
-rw-r--r--include/mbgl/map/map.hpp17
-rw-r--r--include/mbgl/map/tile.hpp7
-rw-r--r--include/mbgl/util/constants.hpp2
4 files changed, 35 insertions, 46 deletions
diff --git a/include/mbgl/map/annotation.hpp b/include/mbgl/map/annotation.hpp
index e88d98b5c6..efd91d9087 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>
@@ -10,63 +9,47 @@
#include <string>
#include <vector>
-#include <map>
#include <mutex>
#include <memory>
+#include <unordered_map>
+#include <unordered_set>
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&, const Map&);
+ 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::unordered_map<uint32_t, std::unique_ptr<Annotation>> annotations;
+ std::unordered_map<Tile::ID, std::pair<std::unordered_set<uint32_t>, std::unique_ptr<LiveTile>>, Tile::ID::Hash> tiles;
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 e5eabdac4d..0fb2065cca 100644
--- a/include/mbgl/map/map.hpp
+++ b/include/mbgl/map/map.hpp
@@ -152,13 +152,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);
@@ -198,7 +199,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
@@ -248,7 +249,7 @@ private:
std::unique_ptr<LineAtlas> lineAtlas;
util::ptr<TexturePool> texturePool;
std::unique_ptr<Painter> painter;
- util::ptr<AnnotationManager> annotationManager;
+ std::unique_ptr<AnnotationManager> annotationManager;
const std::unique_ptr<MapData> data;
diff --git a/include/mbgl/map/tile.hpp b/include/mbgl/map/tile.hpp
index bdb127030b..146ebe6ad7 100644
--- a/include/mbgl/map/tile.hpp
+++ b/include/mbgl/map/tile.hpp
@@ -12,6 +12,7 @@
#include <forward_list>
#include <iosfwd>
#include <string>
+#include <functional>
namespace mbgl {
@@ -44,6 +45,12 @@ public:
return ((std::pow(2, z) * y + x) * 32) + z;
}
+ struct Hash {
+ std::size_t operator()(ID const& i) const {
+ return std::hash<uint64_t>()(i.to_uint64());
+ }
+ };
+
inline bool operator==(const ID& rhs) const {
return w == rhs.w && z == rhs.z && x == rhs.x && y == rhs.y;
}
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 {