[core] Add support for queryRenderedFeatures filter

This commit is contained in:
Asheem Mamoowala
2017-02-21 18:34:45 -08:00
committed by Ivo van Dongen
parent ac4e13416a
commit 60d10dd27d
27 changed files with 195 additions and 82 deletions

View File

@@ -12,7 +12,6 @@
#include <mbgl/style/observer.hpp>
#include <mbgl/style/transition_options.hpp>
#include <mbgl/style/update_parameters.hpp>
#include <mbgl/style/query_parameters.hpp>
#include <mbgl/renderer/painter.hpp>
#include <mbgl/storage/file_source.hpp>
#include <mbgl/storage/resource.hpp>
@@ -810,20 +809,20 @@ void Map::removeAnnotation(AnnotationID annotation) {
#pragma mark - Feature query api
std::vector<Feature> Map::queryRenderedFeatures(const ScreenCoordinate& point, const optional<std::vector<std::string>>& layerIDs) {
std::vector<Feature> Map::queryRenderedFeatures(const ScreenCoordinate& point, const QueryOptions& options) {
if (!impl->style) return {};
return impl->style->queryRenderedFeatures({
return impl->style->queryRenderedFeatures(
{ point },
impl->transform.getState(),
layerIDs
});
options
);
}
std::vector<Feature> Map::queryRenderedFeatures(const ScreenBox& box, const optional<std::vector<std::string>>& layerIDs) {
std::vector<Feature> Map::queryRenderedFeatures(const ScreenBox& box, const QueryOptions& options) {
if (!impl->style) return {};
return impl->style->queryRenderedFeatures({
return impl->style->queryRenderedFeatures(
{
box.min,
{ box.max.x, box.min.y },
@@ -832,12 +831,14 @@ std::vector<Feature> Map::queryRenderedFeatures(const ScreenBox& box, const opti
box.min
},
impl->transform.getState(),
layerIDs
});
options
);
}
AnnotationIDs Map::queryPointAnnotations(const ScreenBox& box) {
auto features = queryRenderedFeatures(box, {{ AnnotationManager::PointLayerID }});
QueryOptions options;
options.layerIDs = {{ AnnotationManager::PointLayerID }};
auto features = queryRenderedFeatures(box, options);
std::set<AnnotationID> set;
for (auto &feature : features) {
assert(feature.id);