summaryrefslogtreecommitdiff
path: root/src/mbgl/tile/geojson_tile.cpp
diff options
context:
space:
mode:
authorIvo van Dongen <info@ivovandongen.nl>2017-03-04 18:44:33 -0800
committerIvo van Dongen <ivovandongen@users.noreply.github.com>2017-03-09 13:11:23 -0800
commit0d10d2df1c6d246004e7291511f3aab7a8781d59 (patch)
tree3667c583d44c5237380ad7b79498787caa24a322 /src/mbgl/tile/geojson_tile.cpp
parent548675a196f9e55d87cf8fce837b6e60393cb1b9 (diff)
downloadqtlocation-mapboxgl-0d10d2df1c6d246004e7291511f3aab7a8781d59.tar.gz
[core] query source features
Diffstat (limited to 'src/mbgl/tile/geojson_tile.cpp')
-rw-r--r--src/mbgl/tile/geojson_tile.cpp23
1 files changed, 23 insertions, 0 deletions
diff --git a/src/mbgl/tile/geojson_tile.cpp b/src/mbgl/tile/geojson_tile.cpp
index 85d8b75619..5a2a72f50b 100644
--- a/src/mbgl/tile/geojson_tile.cpp
+++ b/src/mbgl/tile/geojson_tile.cpp
@@ -1,5 +1,6 @@
#include <mbgl/tile/geojson_tile.hpp>
#include <mbgl/tile/geometry_tile_data.hpp>
+#include <mbgl/style/query.hpp>
#include <mapbox/geojsonvt.hpp>
#include <supercluster.hpp>
@@ -90,5 +91,27 @@ void GeoJSONTile::updateData(const mapbox::geometry::feature_collection<int16_t>
}
void GeoJSONTile::setNecessity(Necessity) {}
+
+void GeoJSONTile::querySourceFeatures(
+ std::vector<Feature>& result,
+ const style::SourceQueryOptions& options) {
+
+ // Ignore the sourceLayer, there is only one
+ auto layer = getData()->getLayer({});
+
+ if (layer) {
+ auto featureCount = layer->featureCount();
+ for (std::size_t i = 0; i < featureCount; i++) {
+ auto feature = layer->getFeature(i);
+
+ // Apply filter, if any
+ if (options.filter && !(*options.filter)(*feature)) {
+ continue;
+ }
+
+ result.push_back(convertFeature(*feature, id.canonical));
+ }
+ }
+}
} // namespace mbgl