summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBruno de Oliveira Abinader <bruno@mapbox.com>2016-10-12 09:54:25 +0300
committerBruno de Oliveira Abinader <bruno@mapbox.com>2016-10-12 18:58:22 +0300
commit436a22efe97500cb314ca8d9848fa405e6cb9af7 (patch)
tree19fcda0cf8d2780dcda5da8681c50dee4ae3e700
parent0fc7fd11d9b158751561eb1ac8f67fe8c1fda93f (diff)
downloadqtlocation-mapboxgl-436a22efe97500cb314ca8d9848fa405e6cb9af7.tar.gz
[core] Skip duplicated IDs when querying point annotations
-rw-r--r--src/mbgl/map/map.cpp8
-rw-r--r--test/api/annotations.test.cpp10
2 files changed, 15 insertions, 3 deletions
diff --git a/src/mbgl/map/map.cpp b/src/mbgl/map/map.cpp
index 95958602bc..bf2462e2ab 100644
--- a/src/mbgl/map/map.cpp
+++ b/src/mbgl/map/map.cpp
@@ -750,13 +750,15 @@ std::vector<Feature> Map::queryRenderedFeatures(const ScreenBox& box, const opti
AnnotationIDs Map::queryPointAnnotations(const ScreenBox& box) {
auto features = queryRenderedFeatures(box, {{ AnnotationManager::PointLayerID }});
- AnnotationIDs ids;
- ids.reserve(features.size());
+ std::set<AnnotationID> set;
for (auto &feature : features) {
assert(feature.id);
assert(*feature.id <= std::numeric_limits<AnnotationID>::max());
- ids.push_back(static_cast<AnnotationID>(feature.id->get<uint64_t>()));
+ set.insert(static_cast<AnnotationID>(feature.id->get<uint64_t>()));
}
+ AnnotationIDs ids;
+ ids.reserve(set.size());
+ std::move(set.begin(), set.end(), std::back_inserter(ids));
return ids;
}
diff --git a/test/api/annotations.test.cpp b/test/api/annotations.test.cpp
index dbe538024f..dc4b00170a 100644
--- a/test/api/annotations.test.cpp
+++ b/test/api/annotations.test.cpp
@@ -43,9 +43,19 @@ TEST(Annotations, SymbolAnnotation) {
test.map.addAnnotation(SymbolAnnotation { Point<double>(0, 0), "default_marker" });
test.checkRendering("point_annotation");
+ auto size = test.view.getSize();
+ auto screenBox = ScreenBox { {}, { double(size[0]), double(size[1]) } };
+ auto features = test.map.queryPointAnnotations(screenBox);
+ EXPECT_EQ(features.size(), 1u);
+
+ test.map.setZoom(test.map.getMaxZoom());
// FIXME: https://github.com/mapbox/mapbox-gl-native/issues/5419
//test.map.setZoom(test.map.getMaxZoom());
//test.checkRendering("point_annotation");
+ test::render(test.map);
+
+ features = test.map.queryPointAnnotations(screenBox);
+ EXPECT_EQ(features.size(), 1u);
}
TEST(Annotations, LineAnnotation) {