summaryrefslogtreecommitdiff
path: root/include/mbgl/map
diff options
context:
space:
mode:
authorJustin R. Miller <incanus@codesorcery.net>2015-03-23 20:49:02 -0700
committerJustin R. Miller <incanus@codesorcery.net>2015-03-23 20:49:02 -0700
commitc5597ad6f1b5140406d8059d27c7a5ca90ba40de (patch)
tree271c96fa408d7fa2d5b9816c75c7041f87f8ae04 /include/mbgl/map
parent77c386251e3c3a361fe8d145b4f3b15208ab9d47 (diff)
downloadqtlocation-mapboxgl-c5597ad6f1b5140406d8059d27c7a5ca90ba40de.tar.gz
annotations perf improvements & iOS app testing
squash of #1061
Diffstat (limited to 'include/mbgl/map')
-rw-r--r--include/mbgl/map/annotation.hpp9
-rw-r--r--include/mbgl/map/tile.hpp7
2 files changed, 12 insertions, 4 deletions
diff --git a/include/mbgl/map/annotation.hpp b/include/mbgl/map/annotation.hpp
index 2eb0509d9a..efd91d9087 100644
--- a/include/mbgl/map/annotation.hpp
+++ b/include/mbgl/map/annotation.hpp
@@ -9,9 +9,10 @@
#include <string>
#include <vector>
-#include <map>
#include <mutex>
#include <memory>
+#include <unordered_map>
+#include <unordered_set>
namespace mbgl {
@@ -29,7 +30,7 @@ public:
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&);
+ std::vector<Tile::ID> removeAnnotations(const AnnotationIDs&, const Map&);
AnnotationIDs getAnnotationsInBounds(const LatLngBounds&, const Map&) const;
LatLngBounds getBoundsForAnnotations(const AnnotationIDs&) const;
@@ -44,8 +45,8 @@ private:
private:
mutable std::mutex mtx;
std::string defaultPointAnnotationSymbol;
- std::map<uint32_t, std::unique_ptr<Annotation>> annotations;
- std::map<Tile::ID, std::pair<AnnotationIDs, std::unique_ptr<LiveTile>>> annotationTiles;
+ 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;
};
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;
}