summaryrefslogtreecommitdiff
path: root/src/mbgl/util/grid_index.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/mbgl/util/grid_index.cpp')
-rw-r--r--src/mbgl/util/grid_index.cpp24
1 files changed, 16 insertions, 8 deletions
diff --git a/src/mbgl/util/grid_index.cpp b/src/mbgl/util/grid_index.cpp
index afd469501d..f6b59b1bac 100644
--- a/src/mbgl/util/grid_index.cpp
+++ b/src/mbgl/util/grid_index.cpp
@@ -82,21 +82,29 @@ std::vector<std::pair<T, typename GridIndex<T>::BBox>> GridIndex<T>::queryWithBo
}
template <class T>
-bool GridIndex<T>::hitTest(const BBox& queryBBox) const {
+bool GridIndex<T>::hitTest(const BBox& queryBBox, optional<std::function<bool(const T&)>> predicate) const {
bool hit = false;
- query(queryBBox, [&](const T&, const BBox&) -> bool {
- hit = true;
- return true;
+ query(queryBBox, [&](const T& t, const BBox&) -> bool {
+ if (!predicate || (*predicate)(t)) {
+ hit = true;
+ return true;
+ } else {
+ return false;
+ }
});
return hit;
}
template <class T>
-bool GridIndex<T>::hitTest(const BCircle& queryBCircle) const {
+bool GridIndex<T>::hitTest(const BCircle& queryBCircle, optional<std::function<bool(const T&)>> predicate) const {
bool hit = false;
- query(queryBCircle, [&](const T&, const BBox&) -> bool {
- hit = true;
- return true;
+ query(queryBCircle, [&](const T& t, const BBox&) -> bool {
+ if (!predicate || (*predicate)(t)) {
+ hit = true;
+ return true;
+ } else {
+ return false;
+ }
});
return hit;
}