Revert "use array of structs rather than parallel arrays for annotations"
This reverts commit 2435c1ad26 (#1710), which needs to be revisited in light of #1655, which is a much higher priority at the moment.
This commit is contained in:
@@ -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 =
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user