Remove MapData dependency from AnnotationManager
This commit is contained in:
@@ -2,7 +2,6 @@
|
||||
#include <mbgl/map/map.hpp>
|
||||
#include <mbgl/map/tile_id.hpp>
|
||||
#include <mbgl/map/live_tile.hpp>
|
||||
#include <mbgl/map/map_data.hpp>
|
||||
#include <mbgl/util/constants.hpp>
|
||||
#include <mbgl/util/geojsonvt/geojsonvt_convert.hpp>
|
||||
#include <mbgl/util/ptr.hpp>
|
||||
@@ -83,7 +82,7 @@ AnnotationManager::addAnnotations(const AnnotationType type,
|
||||
const std::vector<AnnotationSegments>& segments,
|
||||
const std::vector<StyleProperties>& styleProperties,
|
||||
const AnnotationsProperties& annotationsProperties,
|
||||
const MapData& data) {
|
||||
const uint8_t maxZoom) {
|
||||
std::lock_guard<std::mutex> lock(mtx);
|
||||
|
||||
assert(type != AnnotationType::Any);
|
||||
@@ -101,8 +100,6 @@ AnnotationManager::addAnnotations(const AnnotationType type,
|
||||
|
||||
std::unordered_set<TileID, TileID::Hash> affectedTiles;
|
||||
|
||||
const uint8_t maxZoom = data.transform.getMaxZoom();
|
||||
|
||||
for (size_t s = 0; s < segments.size(); ++s) {
|
||||
|
||||
if (type == AnnotationType::Point) {
|
||||
@@ -351,34 +348,34 @@ AnnotationManager::addTileFeature(const uint32_t annotationID,
|
||||
std::pair<std::unordered_set<TileID, TileID::Hash>, AnnotationIDs>
|
||||
AnnotationManager::addPointAnnotations(const AnnotationSegment& points,
|
||||
const AnnotationsProperties& annotationsProperties,
|
||||
const MapData& data) {
|
||||
const uint8_t maxZoom) {
|
||||
return addAnnotations(AnnotationType::Point,
|
||||
{{ points }},
|
||||
{{ }},
|
||||
annotationsProperties,
|
||||
data);
|
||||
maxZoom);
|
||||
}
|
||||
|
||||
std::pair<std::unordered_set<TileID, TileID::Hash>, AnnotationIDs>
|
||||
AnnotationManager::addShapeAnnotations(const std::vector<AnnotationSegments>& shapes,
|
||||
const std::vector<StyleProperties>& styleProperties,
|
||||
const AnnotationsProperties& annotationsProperties,
|
||||
const MapData& data) {
|
||||
const uint8_t maxZoom) {
|
||||
return addAnnotations(AnnotationType::Shape,
|
||||
shapes,
|
||||
styleProperties,
|
||||
annotationsProperties,
|
||||
data);
|
||||
maxZoom);
|
||||
}
|
||||
|
||||
std::unordered_set<TileID, TileID::Hash> AnnotationManager::removeAnnotations(const AnnotationIDs& ids,
|
||||
const MapData& data) {
|
||||
const uint8_t maxZoom) {
|
||||
std::lock_guard<std::mutex> lock(mtx);
|
||||
|
||||
std::unordered_set<TileID, TileID::Hash> affectedTiles;
|
||||
|
||||
std::vector<uint32_t> z2s;
|
||||
const uint8_t zoomCount = data.transform.getMaxZoom() + 1;
|
||||
const uint8_t zoomCount = maxZoom + 1;
|
||||
z2s.reserve(zoomCount);
|
||||
for (uint8_t z = 0; z < zoomCount; ++z) {
|
||||
z2s.emplace_back(1<< z);
|
||||
@@ -450,11 +447,11 @@ const StyleProperties AnnotationManager::getAnnotationStyleProperties(uint32_t a
|
||||
}
|
||||
|
||||
AnnotationIDs AnnotationManager::getAnnotationsInBounds(const LatLngBounds& queryBounds,
|
||||
const MapData& data,
|
||||
const uint8_t maxZoom,
|
||||
const AnnotationType& type) const {
|
||||
std::lock_guard<std::mutex> lock(mtx);
|
||||
|
||||
const uint8_t z = data.transform.getMaxZoom();
|
||||
const uint8_t z = maxZoom;
|
||||
const uint32_t z2 = 1 << z;
|
||||
const vec2<double> swPoint = projectPoint(queryBounds.sw);
|
||||
const vec2<double> nePoint = projectPoint(queryBounds.ne);
|
||||
|
||||
@@ -24,7 +24,6 @@ class Annotation;
|
||||
class Map;
|
||||
class LiveTile;
|
||||
class LiveTileFeature;
|
||||
class MapData;
|
||||
|
||||
using AnnotationsProperties = std::unordered_map<std::string, std::vector<std::string>>;
|
||||
|
||||
@@ -61,16 +60,16 @@ public:
|
||||
std::pair<std::unordered_set<TileID, TileID::Hash>, AnnotationIDs> addPointAnnotations(
|
||||
const AnnotationSegment&,
|
||||
const AnnotationsProperties&,
|
||||
const MapData&);
|
||||
const uint8_t maxZoom);
|
||||
std::pair<std::unordered_set<TileID, TileID::Hash>, AnnotationIDs> addShapeAnnotations(
|
||||
const std::vector<AnnotationSegments>&,
|
||||
const std::vector<StyleProperties>&,
|
||||
const AnnotationsProperties&,
|
||||
const MapData&);
|
||||
std::unordered_set<TileID, TileID::Hash> removeAnnotations(const AnnotationIDs&, const MapData&);
|
||||
const uint8_t maxZoom);
|
||||
std::unordered_set<TileID, TileID::Hash> removeAnnotations(const AnnotationIDs&, const uint8_t maxZoom);
|
||||
AnnotationIDs getOrderedShapeAnnotations() const { return orderedShapeAnnotations; }
|
||||
const StyleProperties getAnnotationStyleProperties(uint32_t) const;
|
||||
AnnotationIDs getAnnotationsInBounds(const LatLngBounds&, const MapData&, const AnnotationType& = AnnotationType::Any) const;
|
||||
AnnotationIDs getAnnotationsInBounds(const LatLngBounds&, const uint8_t maxZoom, const AnnotationType& = AnnotationType::Any) const;
|
||||
LatLngBounds getBoundsForAnnotations(const AnnotationIDs&) const;
|
||||
|
||||
const LiveTile* getTile(const TileID& id);
|
||||
@@ -86,7 +85,7 @@ private:
|
||||
const std::vector<AnnotationSegments>&,
|
||||
const std::vector<StyleProperties>&,
|
||||
const AnnotationsProperties&,
|
||||
const MapData&);
|
||||
const uint8_t maxZoom);
|
||||
std::unordered_set<TileID, TileID::Hash> addTileFeature(
|
||||
const uint32_t annotationID,
|
||||
const AnnotationSegments&,
|
||||
|
||||
@@ -244,7 +244,7 @@ uint32_t Map::addPointAnnotation(const LatLng& point, const std::string& symbol)
|
||||
AnnotationIDs Map::addPointAnnotations(const AnnotationSegment& points,
|
||||
const std::vector<std::string>& symbols) {
|
||||
AnnotationsProperties properties = { { "symbols", symbols } };
|
||||
auto result = data->annotationManager.addPointAnnotations(points, properties, *data);
|
||||
auto result = data->annotationManager.addPointAnnotations(points, properties, data->transform.getMaxZoom());
|
||||
context->invoke(&MapContext::updateAnnotationTiles, result.first);
|
||||
return result.second;
|
||||
}
|
||||
@@ -256,7 +256,7 @@ uint32_t Map::addShapeAnnotation(const AnnotationSegments& shape,
|
||||
|
||||
AnnotationIDs Map::addShapeAnnotations(const std::vector<AnnotationSegments>& shapes,
|
||||
const std::vector<StyleProperties>& styleProperties) {
|
||||
auto result = data->annotationManager.addShapeAnnotations(shapes, styleProperties, {{}}, *data);
|
||||
auto result = data->annotationManager.addShapeAnnotations(shapes, styleProperties, {{}}, data->transform.getMaxZoom());
|
||||
context->invoke(&MapContext::updateAnnotationTiles, result.first);
|
||||
return result.second;
|
||||
}
|
||||
@@ -266,12 +266,12 @@ void Map::removeAnnotation(uint32_t annotation) {
|
||||
}
|
||||
|
||||
void Map::removeAnnotations(const std::vector<uint32_t>& annotations) {
|
||||
auto result = data->annotationManager.removeAnnotations(annotations, *data);
|
||||
auto result = data->annotationManager.removeAnnotations(annotations, data->transform.getMaxZoom());
|
||||
context->invoke(&MapContext::updateAnnotationTiles, result);
|
||||
}
|
||||
|
||||
std::vector<uint32_t> Map::getAnnotationsInBounds(const LatLngBounds& bounds, const AnnotationType& type) {
|
||||
return data->annotationManager.getAnnotationsInBounds(bounds, *data, type);
|
||||
return data->annotationManager.getAnnotationsInBounds(bounds, data->transform.getMaxZoom(), type);
|
||||
}
|
||||
|
||||
LatLngBounds Map::getBoundsForAnnotations(const std::vector<uint32_t>& annotations) {
|
||||
|
||||
Reference in New Issue
Block a user