Skip to content
This repository has been archived by the owner on Aug 8, 2023. It is now read-only.

Commit

Permalink
avoid dupes in annotations bounds queries
Browse files Browse the repository at this point in the history
  • Loading branch information
incanus committed Jun 1, 2015
1 parent bf6be3c commit 8626f91
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/mbgl/map/annotation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -386,7 +386,7 @@ AnnotationIDs AnnotationManager::getAnnotationsInBounds(const LatLngBounds& quer
const TileID nwTile(z, swPoint.x * z2, nePoint.y * z2);
const TileID seTile(z, nePoint.x * z2, swPoint.y * z2);

AnnotationIDs matchingAnnotations;
std::unordered_set<uint32_t> matchingAnnotations;

for (auto& tile : tiles) {
TileID id = tile.first;
Expand All @@ -396,12 +396,12 @@ AnnotationIDs AnnotationManager::getAnnotationsInBounds(const LatLngBounds& quer
// Trivial accept; this tile is completely inside the query bounds, so
// we'll return all of its annotations.
std::copy(tile.second.first.begin(), tile.second.first.end(),
std::back_inserter(matchingAnnotations));
std::inserter(matchingAnnotations, matchingAnnotations.begin()));
} else {
// This tile is intersected by the query bounds. We need to check the
// tile's annotations' bounding boxes individually.
std::copy_if(tile.second.first.begin(), tile.second.first.end(),
std::back_inserter(matchingAnnotations),
std::inserter(matchingAnnotations, matchingAnnotations.begin()),
[&](const uint32_t annotationID) -> bool {
const auto it = annotations.find(annotationID);
if (it != annotations.end()) {
Expand All @@ -419,7 +419,7 @@ AnnotationIDs AnnotationManager::getAnnotationsInBounds(const LatLngBounds& quer
}
}

return matchingAnnotations;
return AnnotationIDs(matchingAnnotations.begin(), matchingAnnotations.end());
}

LatLngBounds AnnotationManager::getBoundsForAnnotations(const AnnotationIDs& ids) const {
Expand Down

0 comments on commit 8626f91

Please sign in to comment.