diff options
author | John Firebaugh <john.firebaugh@gmail.com> | 2015-06-24 12:01:43 -0700 |
---|---|---|
committer | John Firebaugh <john.firebaugh@gmail.com> | 2015-06-24 13:08:37 -0700 |
commit | a05698fe0623ffce7ad404a03a12d76b3a410b7a (patch) | |
tree | 95828c684b69df4b883e409f7adc13149b2f8d39 /src | |
parent | 4ba78b6bcfea756c274a05cba61352cd4681ae86 (diff) | |
download | qtlocation-mapboxgl-a05698fe0623ffce7ad404a03a12d76b3a410b7a.tar.gz |
Remove MapData dependency from AnnotationManager
Diffstat (limited to 'src')
-rw-r--r-- | src/mbgl/map/annotation.cpp | 21 | ||||
-rw-r--r-- | src/mbgl/map/annotation.hpp | 11 | ||||
-rw-r--r-- | src/mbgl/map/map.cpp | 8 |
3 files changed, 18 insertions, 22 deletions
diff --git a/src/mbgl/map/annotation.cpp b/src/mbgl/map/annotation.cpp index c946264593..68491bb985 100644 --- a/src/mbgl/map/annotation.cpp +++ b/src/mbgl/map/annotation.cpp @@ -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); diff --git a/src/mbgl/map/annotation.hpp b/src/mbgl/map/annotation.hpp index 213ff608a0..4296fea520 100644 --- a/src/mbgl/map/annotation.hpp +++ b/src/mbgl/map/annotation.hpp @@ -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&, diff --git a/src/mbgl/map/map.cpp b/src/mbgl/map/map.cpp index 8d5b544191..17bcd29893 100644 --- a/src/mbgl/map/map.cpp +++ b/src/mbgl/map/map.cpp @@ -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) { |