summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorKonstantin Käfer <mail@kkaefer.com>2015-06-11 13:57:33 -0400
committerKonstantin Käfer <mail@kkaefer.com>2015-06-11 17:26:37 -0400
commit2435c1ad2603432186ee61eb4c423244a088bc51 (patch)
tree2377c2af37ef8c5ed21e1cf94c916141ebd57d7d /src
parentf46328655e027bf490692fcde4aab770912aac8d (diff)
downloadqtlocation-mapboxgl-2435c1ad2603432186ee61eb4c423244a088bc51.tar.gz
use array of structs rather than parallel arrays for annotations
Diffstat (limited to 'src')
-rw-r--r--src/mbgl/map/annotation.cpp11
-rw-r--r--src/mbgl/map/annotation.hpp3
-rw-r--r--src/mbgl/map/map.cpp8
3 files changed, 11 insertions, 11 deletions
diff --git a/src/mbgl/map/annotation.cpp b/src/mbgl/map/annotation.cpp
index 6df49ec647..481d19cd50 100644
--- a/src/mbgl/map/annotation.cpp
+++ b/src/mbgl/map/annotation.cpp
@@ -85,8 +85,7 @@ vec2<double> AnnotationManager::projectPoint(const LatLng& point) {
}
std::pair<std::vector<TileID>, AnnotationIDs>
-AnnotationManager::addPointAnnotations(const std::vector<LatLng>& points,
- const std::vector<std::string>& symbols,
+AnnotationManager::addPointAnnotations(const std::vector<PointAnnotation>& points,
const MapData& data) {
std::lock_guard<std::mutex> lock(mtx);
@@ -103,14 +102,14 @@ AnnotationManager::addPointAnnotations(const std::vector<LatLng>& points,
std::vector<TileID> affectedTiles;
- for (size_t i = 0; i < points.size(); ++i) {
+ for (const PointAnnotation& point : points) {
const uint32_t annotationID = nextID();
// track the annotation global ID and its geometry
auto anno_it = annotations.emplace(
annotationID,
std::make_unique<Annotation>(AnnotationType::Point,
- AnnotationSegments({ { points[i] } })));
+ AnnotationSegments({ { point.position } })));
const uint8_t maxZoom = data.transform.getMaxZoom();
@@ -118,7 +117,7 @@ AnnotationManager::addPointAnnotations(const std::vector<LatLng>& points,
uint32_t z2 = 1 << maxZoom;
// projection conversion into unit space
- const vec2<double> p = projectPoint(points[i]);
+ const vec2<double> p = projectPoint(point.position);
uint32_t x = p.x * z2;
uint32_t y = p.y * z2;
@@ -134,7 +133,7 @@ AnnotationManager::addPointAnnotations(const std::vector<LatLng>& points,
// at render time we style the annotation according to its {sprite} field
const std::map<std::string, std::string> properties = {
- { "sprite", (symbols[i].length() ? symbols[i] : defaultPointAnnotationSymbol) }
+ { "sprite", (point.icon.length() ? point.icon : defaultPointAnnotationSymbol) }
};
auto feature =
diff --git a/src/mbgl/map/annotation.hpp b/src/mbgl/map/annotation.hpp
index 0c9a078e57..fb78a832c9 100644
--- a/src/mbgl/map/annotation.hpp
+++ b/src/mbgl/map/annotation.hpp
@@ -2,6 +2,7 @@
#define MBGL_MAP_ANNOTATIONS
#include <mbgl/map/tile_id.hpp>
+#include <mbgl/annotation/point_annotation.hpp>
#include <mbgl/util/geo.hpp>
#include <mbgl/util/noncopyable.hpp>
#include <mbgl/util/vec.hpp>
@@ -29,7 +30,7 @@ public:
void setDefaultPointAnnotationSymbol(const std::string& symbol);
std::pair<std::vector<TileID>, AnnotationIDs> addPointAnnotations(
- const std::vector<LatLng>&, const std::vector<std::string>& symbols, const MapData&);
+ const std::vector<PointAnnotation>&, const MapData&);
std::vector<TileID> removeAnnotations(const AnnotationIDs&, const MapData&);
AnnotationIDs getAnnotationsInBounds(const LatLngBounds&, const MapData&) const;
LatLngBounds getBoundsForAnnotations(const AnnotationIDs&) const;
diff --git a/src/mbgl/map/map.cpp b/src/mbgl/map/map.cpp
index 47c9472d59..70194152d9 100644
--- a/src/mbgl/map/map.cpp
+++ b/src/mbgl/map/map.cpp
@@ -235,12 +235,12 @@ double Map::getTopOffsetPixelsForAnnotationSymbol(const std::string& symbol) {
return context->invokeSync<double>(&MapContext::getTopOffsetPixelsForAnnotationSymbol, symbol);
}
-uint32_t Map::addPointAnnotation(const LatLng& point, const std::string& symbol) {
- return addPointAnnotations({ point }, { symbol }).front();
+uint32_t Map::addPointAnnotation(const PointAnnotation& annotation) {
+ return addPointAnnotations({ annotation }).front();
}
-std::vector<uint32_t> Map::addPointAnnotations(const std::vector<LatLng>& points, const std::vector<std::string>& symbols) {
- auto result = data->annotationManager.addPointAnnotations(points, symbols, *data);
+std::vector<uint32_t> Map::addPointAnnotations(const std::vector<PointAnnotation>& annotations) {
+ auto result = data->annotationManager.addPointAnnotations(annotations, *data);
context->invoke(&MapContext::updateAnnotationTiles, result.first);
return result.second;
}