summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMinh Nguyễn <mxn@1ec5.org>2015-06-15 15:58:22 -0700
committerMinh Nguyễn <mxn@1ec5.org>2015-06-15 15:58:22 -0700
commit714b68f7b325c30d0646c8b237d65b013fb12f04 (patch)
tree7e8105e4a081879fba37e5fd6725ed0148ec9adf /src
parenta08bcb6d0ee71d6709f6cc0c019b346155d49c0b (diff)
downloadqtlocation-mapboxgl-714b68f7b325c30d0646c8b237d65b013fb12f04.tar.gz
Revert "use array of structs rather than parallel arrays for annotations"
This reverts commit 2435c1ad2603432186ee61eb4c423244a088bc51 (#1710), which needs to be revisited in light of #1655, which is a much higher priority at the moment.
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 481d19cd50..6df49ec647 100644
--- a/src/mbgl/map/annotation.cpp
+++ b/src/mbgl/map/annotation.cpp
@@ -85,7 +85,8 @@ vec2<double> AnnotationManager::projectPoint(const LatLng& point) {
}
std::pair<std::vector<TileID>, AnnotationIDs>
-AnnotationManager::addPointAnnotations(const std::vector<PointAnnotation>& points,
+AnnotationManager::addPointAnnotations(const std::vector<LatLng>& points,
+ const std::vector<std::string>& symbols,
const MapData& data) {
std::lock_guard<std::mutex> lock(mtx);
@@ -102,14 +103,14 @@ AnnotationManager::addPointAnnotations(const std::vector<PointAnnotation>& point
std::vector<TileID> affectedTiles;
- for (const PointAnnotation& point : points) {
+ for (size_t i = 0; i < points.size(); ++i) {
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({ { point.position } })));
+ AnnotationSegments({ { points[i] } })));
const uint8_t maxZoom = data.transform.getMaxZoom();
@@ -117,7 +118,7 @@ AnnotationManager::addPointAnnotations(const std::vector<PointAnnotation>& point
uint32_t z2 = 1 << maxZoom;
// projection conversion into unit space
- const vec2<double> p = projectPoint(point.position);
+ const vec2<double> p = projectPoint(points[i]);
uint32_t x = p.x * z2;
uint32_t y = p.y * z2;
@@ -133,7 +134,7 @@ AnnotationManager::addPointAnnotations(const std::vector<PointAnnotation>& point
// at render time we style the annotation according to its {sprite} field
const std::map<std::string, std::string> properties = {
- { "sprite", (point.icon.length() ? point.icon : defaultPointAnnotationSymbol) }
+ { "sprite", (symbols[i].length() ? symbols[i] : defaultPointAnnotationSymbol) }
};
auto feature =
diff --git a/src/mbgl/map/annotation.hpp b/src/mbgl/map/annotation.hpp
index fb78a832c9..0c9a078e57 100644
--- a/src/mbgl/map/annotation.hpp
+++ b/src/mbgl/map/annotation.hpp
@@ -2,7 +2,6 @@
#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>
@@ -30,7 +29,7 @@ public:
void setDefaultPointAnnotationSymbol(const std::string& symbol);
std::pair<std::vector<TileID>, AnnotationIDs> addPointAnnotations(
- const std::vector<PointAnnotation>&, const MapData&);
+ const std::vector<LatLng>&, const std::vector<std::string>& symbols, 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 70194152d9..47c9472d59 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 PointAnnotation& annotation) {
- return addPointAnnotations({ annotation }).front();
+uint32_t Map::addPointAnnotation(const LatLng& point, const std::string& symbol) {
+ return addPointAnnotations({ point }, { symbol }).front();
}
-std::vector<uint32_t> Map::addPointAnnotations(const std::vector<PointAnnotation>& annotations) {
- auto result = data->annotationManager.addPointAnnotations(annotations, *data);
+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);
context->invoke(&MapContext::updateAnnotationTiles, result.first);
return result.second;
}