From c8391729c7af8edc142f0319ccffe2720cfb6c18 Mon Sep 17 00:00:00 2001 From: John Firebaugh Date: Fri, 29 Apr 2016 18:28:34 -0700 Subject: [core] Use geometry.hpp feature type --- .mason | 2 +- bin/offline.gypi | 1 + bin/render.gypi | 1 + binding.gyp | 2 + configure | 1 + include/mbgl/map/map.hpp | 5 +- include/mbgl/util/feature.hpp | 19 ++++ mbgl.gypi | 3 + platform/android/scripts/configure.sh | 1 + platform/darwin/src/MGLGeometry_Private.h | 1 - platform/ios/ios.xcodeproj/project.pbxproj | 4 + platform/ios/scripts/configure.sh | 1 + platform/linux/scripts/configure.sh | 1 + platform/node/src/node_feature.cpp | 172 +++++++++++++++++++++++++++++ platform/node/src/node_feature.hpp | 18 +++ platform/node/src/node_map.cpp | 5 +- platform/node/test/suite_implementation.js | 3 +- platform/osx/osx.xcodeproj/project.pbxproj | 2 + platform/osx/scripts/configure.sh | 1 + platform/qt/scripts/configure.sh | 1 + src/mbgl/geometry/feature_index.cpp | 52 ++------- src/mbgl/geometry/feature_index.hpp | 5 +- src/mbgl/map/map.cpp | 4 +- src/mbgl/source/source.cpp | 4 +- src/mbgl/source/source.hpp | 3 +- src/mbgl/style/filter.hpp | 2 +- src/mbgl/style/filter_evaluator.hpp | 10 ++ src/mbgl/style/style.cpp | 7 +- src/mbgl/style/style.hpp | 3 +- src/mbgl/tile/geometry_tile.hpp | 6 +- src/mbgl/tile/tile_data.cpp | 2 +- src/mbgl/tile/tile_data.hpp | 3 +- src/mbgl/tile/vector_tile.cpp | 2 +- src/mbgl/tile/vector_tile.hpp | 4 +- src/mbgl/tile/vector_tile_data.cpp | 2 +- src/mbgl/tile/vector_tile_data.hpp | 3 +- src/mbgl/util/value.hpp | 9 -- 37 files changed, 283 insertions(+), 82 deletions(-) create mode 100644 include/mbgl/util/feature.hpp create mode 100644 platform/node/src/node_feature.cpp create mode 100644 platform/node/src/node_feature.hpp delete mode 100644 src/mbgl/util/value.hpp diff --git a/.mason b/.mason index ce43228028..2d75da369d 160000 --- a/.mason +++ b/.mason @@ -1 +1 @@ -Subproject commit ce432280285b3bb6a3b0fd042e7833acbfddf9e2 +Subproject commit 2d75da369d1ebc7c5dd4139cde89410743665248 diff --git a/bin/offline.gypi b/bin/offline.gypi index acdd17a749..295cbd0a01 100644 --- a/bin/offline.gypi +++ b/bin/offline.gypi @@ -6,6 +6,7 @@ 'type': 'executable', 'dependencies': [ + 'core', 'platform-lib', 'copy_certificate_bundle', ], diff --git a/bin/render.gypi b/bin/render.gypi index 31815d3c44..b6ae668981 100644 --- a/bin/render.gypi +++ b/bin/render.gypi @@ -6,6 +6,7 @@ 'type': 'executable', 'dependencies': [ + 'core', 'platform-lib', 'copy_certificate_bundle', ], diff --git a/binding.gyp b/binding.gyp index 3e7f9a452a..acd8129260 100644 --- a/binding.gyp +++ b/binding.gyp @@ -35,6 +35,8 @@ 'platform/node/src/node_map.cpp', 'platform/node/src/node_request.hpp', 'platform/node/src/node_request.cpp', + 'platform/node/src/node_feature.hpp', + 'platform/node/src/node_feature.cpp', 'platform/node/src/util/async_queue.hpp', ], diff --git a/configure b/configure index 3290899498..d276cb7ace 100755 --- a/configure +++ b/configure @@ -110,6 +110,7 @@ print_flags libuv static_libs cflags ldflags print_flags zlib static_libs cflags ldflags print_flags nunicode static_libs cflags ldflags print_flags libzip static_libs cflags ldflags +print_flags geometry static_libs cflags ldflags print_flags geojsonvt static_libs cflags ldflags print_flags variant static_libs cflags ldflags print_flags rapidjson static_libs cflags ldflags diff --git a/include/mbgl/map/map.hpp b/include/mbgl/map/map.hpp index 41f34c102b..3200484ec1 100644 --- a/include/mbgl/map/map.hpp +++ b/include/mbgl/map/map.hpp @@ -7,6 +7,7 @@ #include #include #include +#include #include #include #include @@ -159,8 +160,8 @@ public: void removeCustomLayer(const std::string& id); // Feature queries - std::vector queryRenderedFeatures(const ScreenCoordinate&, const optional>& layerIDs = {}); - std::vector queryRenderedFeatures(const std::array&, const optional>& layerIDs = {}); + std::vector queryRenderedFeatures(const ScreenCoordinate&, const optional>& layerIDs = {}); + std::vector queryRenderedFeatures(const std::array&, const optional>& layerIDs = {}); // Memory void setSourceTileCacheSize(size_t); diff --git a/include/mbgl/util/feature.hpp b/include/mbgl/util/feature.hpp new file mode 100644 index 0000000000..c9dbc31769 --- /dev/null +++ b/include/mbgl/util/feature.hpp @@ -0,0 +1,19 @@ +#pragma once + +#include + +#include + +namespace mbgl { + +using Value = mapbox::geometry::value; + +class Feature : public mapbox::geometry::feature { +public: + Feature(geometry_type&& geometry_) + : mapbox::geometry::feature { std::move(geometry_) } {} + + optional id {}; +}; + +} // namespace mbgl diff --git a/mbgl.gypi b/mbgl.gypi index 6619e0011f..e4d2474dfd 100644 --- a/mbgl.gypi +++ b/mbgl.gypi @@ -174,6 +174,7 @@ '<@(opengl_cflags)', '<@(protozero_cflags)', '<@(boost_cflags)', + '<@(geometry_cflags)', '<@(geojsonvt_cflags)', '<@(rapidjson_cflags)', '<@(variant_cflags)', @@ -288,10 +289,12 @@ 'direct_dependent_settings': { 'cflags_cc': [ '<@(variant_cflags)', + '<@(geometry_cflags)', ], 'xcode_settings': { 'OTHER_CPLUSPLUSFLAGS': [ '<@(variant_cflags)', + '<@(geometry_cflags)', ], }, }, diff --git a/platform/android/scripts/configure.sh b/platform/android/scripts/configure.sh index cf20f4a99e..30913aaf92 100644 --- a/platform/android/scripts/configure.sh +++ b/platform/android/scripts/configure.sh @@ -8,6 +8,7 @@ SQLITE_VERSION=3.9.1 ZLIB_VERSION=system NUNICODE_VERSION=1.6 LIBZIP_VERSION=0.11.2 +GEOMETRY_VERSION=0.1.0 GEOJSONVT_VERSION=4.1.2 VARIANT_VERSION=1.1.0 RAPIDJSON_VERSION=1.0.2 diff --git a/platform/darwin/src/MGLGeometry_Private.h b/platform/darwin/src/MGLGeometry_Private.h index 72123827df..71a083e588 100644 --- a/platform/darwin/src/MGLGeometry_Private.h +++ b/platform/darwin/src/MGLGeometry_Private.h @@ -5,7 +5,6 @@ #import #endif -#import #import /// Returns the smallest rectangle that contains both the given rectangle and diff --git a/platform/ios/ios.xcodeproj/project.pbxproj b/platform/ios/ios.xcodeproj/project.pbxproj index 80f73adbbb..f97263f2cd 100644 --- a/platform/ios/ios.xcodeproj/project.pbxproj +++ b/platform/ios/ios.xcodeproj/project.pbxproj @@ -1591,6 +1591,7 @@ "$(zlib_cflags)", "$(rapidjson_cflags)", "$(variant_cflags)", + "$(geometry_cflags)", ); OTHER_LDFLAGS = ( "$(sqlite_ldflags)", @@ -1630,6 +1631,7 @@ "$(zlib_cflags)", "$(rapidjson_cflags)", "$(variant_cflags)", + "$(geometry_cflags)", ); OTHER_LDFLAGS = ( "$(sqlite_ldflags)", @@ -1682,6 +1684,7 @@ "$(zlib_cflags)", "$(rapidjson_cflags)", "$(variant_cflags)", + "$(geometry_cflags)", ); OTHER_LDFLAGS = ( "-ObjC", @@ -1711,6 +1714,7 @@ "$(zlib_cflags)", "$(rapidjson_cflags)", "$(variant_cflags)", + "$(geometry_cflags)", ); OTHER_LDFLAGS = ( "-ObjC", diff --git a/platform/ios/scripts/configure.sh b/platform/ios/scripts/configure.sh index 769407445a..c92e58c7d2 100644 --- a/platform/ios/scripts/configure.sh +++ b/platform/ios/scripts/configure.sh @@ -4,6 +4,7 @@ PROTOZERO_VERSION=1.3.0 BOOST_VERSION=1.60.0 SQLITE_VERSION=system ZLIB_VERSION=system +GEOMETRY_VERSION=0.1.0 GEOJSONVT_VERSION=4.1.2 VARIANT_VERSION=1.1.0 RAPIDJSON_VERSION=1.0.2 diff --git a/platform/linux/scripts/configure.sh b/platform/linux/scripts/configure.sh index 4d1b26fc9b..5f7edf7f8a 100644 --- a/platform/linux/scripts/configure.sh +++ b/platform/linux/scripts/configure.sh @@ -11,6 +11,7 @@ SQLITE_VERSION=3.9.1 LIBUV_VERSION=1.7.5 ZLIB_VERSION=system NUNICODE_VERSION=1.6 +GEOMETRY_VERSION=0.1.0 GEOJSONVT_VERSION=4.1.2 VARIANT_VERSION=1.1.0 RAPIDJSON_VERSION=1.0.2 diff --git a/platform/node/src/node_feature.cpp b/platform/node/src/node_feature.cpp new file mode 100644 index 0000000000..0a9e70cc2b --- /dev/null +++ b/platform/node/src/node_feature.cpp @@ -0,0 +1,172 @@ +#include "node_feature.hpp" + +namespace node_mbgl { + +using namespace mapbox::geometry; + +using Value = mbgl::Value; +using Feature = mbgl::Feature; +using Geometry = mbgl::Feature::geometry_type; +using Properties = mbgl::Feature::property_map; + +template +struct ToType { +public: + v8::Local operator()(const point&) { + return type("Point"); + } + + v8::Local operator()(const line_string&) { + return type("LineString"); + } + + v8::Local operator()(const polygon&) { + return type("Polygon"); + } + + v8::Local operator()(const multi_point&) { + return type("MultiPoint"); + } + + v8::Local operator()(const multi_line_string&) { + return type("MultiLineString"); + } + + v8::Local operator()(const multi_polygon&) { + return type("MultiPolygon"); + } + + v8::Local operator()(const geometry_collection&) { + return type("GeometryCollection"); + } + +private: + v8::Local type(const char* type) { + Nan::EscapableHandleScope scope; + return scope.Escape(Nan::New(type).ToLocalChecked()); + } +}; + +template +struct ToCoordinates { +public: + // Handles line_string, multi_point, multi_line_string, and multi_polygon. + template + v8::Local operator()(const std::vector& vector) { + Nan::EscapableHandleScope scope; + v8::Local result = Nan::New(vector.size()); + for (std::size_t i = 0; i < vector.size(); ++i) { + Nan::Set(result, i, operator()(vector[i])); + } + return scope.Escape(result); + } + + v8::Local operator()(const point& point) { + Nan::EscapableHandleScope scope; + v8::Local result = Nan::New(2); + Nan::Set(result, 0, Nan::New(point.x)); + Nan::Set(result, 1, Nan::New(point.y)); + return scope.Escape(result); + } + + v8::Local operator()(const polygon& polygon) { + Nan::EscapableHandleScope scope; + v8::Local result = Nan::New(1 + polygon.interior_rings.size()); + Nan::Set(result, 0, operator()(polygon.exterior_ring)); + for (std::size_t i = 0; i < polygon.interior_rings.size(); ++i) { + Nan::Set(result, i + 1, operator()(polygon.interior_rings[i])); + } + return scope.Escape(result); + } + + v8::Local operator()(const geometry_collection& collection) { + Nan::EscapableHandleScope scope; + v8::Local result = Nan::New(collection.size()); + for (std::size_t i = 0; i < collection.size(); ++i) { + Nan::Set(result, i, toJS(collection[i])); + } + return scope.Escape(result); + } +}; + +struct ToValue { + v8::Local operator()(bool t) { + Nan::EscapableHandleScope scope; + return scope.Escape(Nan::New(t)); + } + + v8::Local operator()(int64_t t) { + return operator()(double(t)); + } + + v8::Local operator()(uint64_t t) { + return operator()(double(t)); + } + + v8::Local operator()(double t) { + Nan::EscapableHandleScope scope; + return scope.Escape(Nan::New(t)); + } + + v8::Local operator()(const std::string& t) { + Nan::EscapableHandleScope scope; + return scope.Escape(Nan::New(t).ToLocalChecked()); + } + + v8::Local operator()(const std::vector& array) { + Nan::EscapableHandleScope scope; + v8::Local result = Nan::New(); + for (unsigned int i = 0; i < array.size(); i++) { + result->Set(i, toJS(array[i])); + } + return scope.Escape(result); + } + + v8::Local operator()(const std::unordered_map& map) { + return toJS(map); + } +}; + +v8::Local toJS(const Geometry& geometry) { + Nan::EscapableHandleScope scope; + + v8::Local result = Nan::New(); + + Nan::Set(result, Nan::New("type").ToLocalChecked(), Geometry::visit(geometry, ToType())); + Nan::Set(result, Nan::New("coordinates").ToLocalChecked(), Geometry::visit(geometry, ToCoordinates())); + + return scope.Escape(result); +} + +v8::Local toJS(const Value& value) { + return Value::visit(value, ToValue()); +} + +v8::Local toJS(const Properties& properties) { + Nan::EscapableHandleScope scope; + + v8::Local result = Nan::New(); + for (const auto& property : properties) { + Nan::Set(result, Nan::New(property.first).ToLocalChecked(), toJS(property.second)); + } + + return scope.Escape(result); +} + +v8::Local toJS(const Feature& feature) { + Nan::EscapableHandleScope scope; + + v8::Local result = Nan::New(); + + Nan::Set(result, Nan::New("type").ToLocalChecked(), Nan::New("Feature").ToLocalChecked()); + Nan::Set(result, Nan::New("geometry").ToLocalChecked(), toJS(feature.geometry)); + Nan::Set(result, Nan::New("properties").ToLocalChecked(), toJS(feature.properties)); + + if (feature.id) { + Nan::Set(result, Nan::New("id").ToLocalChecked(), toJS(*feature.id)); + } + + return scope.Escape(result); +} + +} diff --git a/platform/node/src/node_feature.hpp b/platform/node/src/node_feature.hpp new file mode 100644 index 0000000000..7973ee19d4 --- /dev/null +++ b/platform/node/src/node_feature.hpp @@ -0,0 +1,18 @@ +#pragma once + +#include + +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wunused-parameter" +#pragma GCC diagnostic ignored "-Wshadow" +#include +#pragma GCC diagnostic pop + +namespace node_mbgl { + +v8::Local toJS(const mbgl::Value&); +v8::Local toJS(const mbgl::Feature&); +v8::Local toJS(const mbgl::Feature::geometry_type&); +v8::Local toJS(const mbgl::Feature::property_map&); + +} diff --git a/platform/node/src/node_map.cpp b/platform/node/src/node_map.cpp index cf828782f5..b139e4252c 100644 --- a/platform/node/src/node_map.cpp +++ b/platform/node/src/node_map.cpp @@ -1,5 +1,6 @@ #include "node_map.hpp" #include "node_request.hpp" +#include "node_feature.hpp" #include #include @@ -465,7 +466,7 @@ NAN_METHOD(NodeMap::QueryRenderedFeatures) { } try { - std::vector result; + std::vector result; if (Nan::Get(posOrBox, 0).ToLocalChecked()->IsArray()) { @@ -490,7 +491,7 @@ NAN_METHOD(NodeMap::QueryRenderedFeatures) { auto array = Nan::New(); for (unsigned int i = 0; i < result.size(); i++) { - array->Set(i, Nan::New(result[i]).ToLocalChecked()); + array->Set(i, toJS(result[i])); } info.GetReturnValue().Set(array); } catch (const std::exception &ex) { diff --git a/platform/node/test/suite_implementation.js b/platform/node/test/suite_implementation.js index a5c70ab802..05b86f379f 100644 --- a/platform/node/test/suite_implementation.js +++ b/platform/node/test/suite_implementation.js @@ -51,8 +51,7 @@ module.exports = function (style, options, callback) { callback(err, pixels, results.map(prepareFeatures)); }); - function prepareFeatures(json) { - var r = JSON.parse(json); + function prepareFeatures(r) { delete r.layer; r.geometry = null; return r; diff --git a/platform/osx/osx.xcodeproj/project.pbxproj b/platform/osx/osx.xcodeproj/project.pbxproj index 1174d5ef46..61c028bf8f 100644 --- a/platform/osx/osx.xcodeproj/project.pbxproj +++ b/platform/osx/osx.xcodeproj/project.pbxproj @@ -943,6 +943,7 @@ "$(zlib_cflags)", "$(rapidjson_cflags)", "$(variant_cflags)", + "$(geometry_cflags)", ); OTHER_LDFLAGS = ( "$(zlib_ldflags)", @@ -981,6 +982,7 @@ "$(zlib_cflags)", "$(rapidjson_cflags)", "$(variant_cflags)", + "$(geometry_cflags)", ); OTHER_LDFLAGS = ( "$(zlib_ldflags)", diff --git a/platform/osx/scripts/configure.sh b/platform/osx/scripts/configure.sh index 6d2eef03c4..44e0c618e9 100644 --- a/platform/osx/scripts/configure.sh +++ b/platform/osx/scripts/configure.sh @@ -7,6 +7,7 @@ GLFW_VERSION=3.1.2 SQLITE_VERSION=3.9.1 ZLIB_VERSION=system NUNICODE_VERSION=1.6 +GEOMETRY_VERSION=0.1.0 GEOJSONVT_VERSION=4.1.2 VARIANT_VERSION=1.1.0 RAPIDJSON_VERSION=1.0.2 diff --git a/platform/qt/scripts/configure.sh b/platform/qt/scripts/configure.sh index d9a8f15cc2..b7807bd469 100644 --- a/platform/qt/scripts/configure.sh +++ b/platform/qt/scripts/configure.sh @@ -2,6 +2,7 @@ PROTOZERO_VERSION=1.3.0 BOOST_VERSION=1.60.0 +GEOMETRY_VERSION=0.1.0 GEOJSONVT_VERSION=4.1.2 GTEST_VERSION=1.7.0 LIBJPEG_TURBO_VERSION=1.4.2 diff --git a/src/mbgl/geometry/feature_index.cpp b/src/mbgl/geometry/feature_index.cpp index d6e19c1932..3e345fe817 100644 --- a/src/mbgl/geometry/feature_index.cpp +++ b/src/mbgl/geometry/feature_index.cpp @@ -5,8 +5,6 @@ #include #include #include -#include -#include #include #include @@ -61,7 +59,7 @@ bool topDownSymbols(const IndexedSubfeature& a, const IndexedSubfeature& b) { } void FeatureIndex::query( - std::unordered_map>& result, + std::unordered_map>& result, const GeometryCollection& queryGeometry, const float bearing, const double tileSize, @@ -116,7 +114,7 @@ void FeatureIndex::query( } void FeatureIndex::addFeature( - std::unordered_map>& result, + std::unordered_map>& result, const IndexedSubfeature& indexedFeature, const GeometryCollection& queryGeometry, const optional>& filterLayerIDs, @@ -131,8 +129,8 @@ void FeatureIndex::addFeature( auto sourceLayer = geometryTile.getLayer(indexedFeature.sourceLayerName); assert(sourceLayer); - auto feature = sourceLayer->getFeature(indexedFeature.index); - assert(feature); + auto geometryTileFeature = sourceLayer->getFeature(indexedFeature.index); + assert(geometryTileFeature); for (auto& layerID : layerIDs) { @@ -142,49 +140,19 @@ void FeatureIndex::addFeature( if (!styleLayer) continue; if (!styleLayer->is()) { - auto geometries = getGeometries(*feature); + auto geometries = getGeometries(*geometryTileFeature); if (!styleLayer->queryIntersectsGeometry(queryGeometry, geometries, bearing, pixelsToTileUnits)) continue; } - auto& layerResult = result[layerID]; + Feature feature { mapbox::geometry::point() }; + feature.properties = geometryTileFeature->getProperties(); - auto properties = feature->getProperties(); - rapidjson::StringBuffer buffer; - buffer.Clear(); - rapidjson::Writer writer(buffer); - - writer.StartObject(); - writer.Key("type"); - writer.String("Feature"); - auto id = feature->getID(); + optional id = geometryTileFeature->getID(); if (id) { - writer.Key("id"); - writer.Double(feature->getID()); - } - writer.Key("properties"); - writer.StartObject(); - for (auto& prop : properties) { - std::string key = prop.first; - Value& value = prop.second; - - writer.Key(key.c_str()); - - if (value.is()) { - writer.String(value.get().c_str()); - } else if (value.is()) { - writer.Bool(value.get()); - } else if (value.is()) { - writer.Int64(value.get()); - } else if (value.is()) { - writer.Uint64(value.get()); - } else if (value.is()) { - writer.Double(value.get()); - } + feature.id = Value(*id); } - writer.EndObject(); - writer.EndObject(); - layerResult.push_back(buffer.GetString()); + result[layerID].push_back(std::move(feature)); } } diff --git a/src/mbgl/geometry/feature_index.hpp b/src/mbgl/geometry/feature_index.hpp index 0b520a841a..5d78df2138 100644 --- a/src/mbgl/geometry/feature_index.hpp +++ b/src/mbgl/geometry/feature_index.hpp @@ -3,6 +3,7 @@ #include #include +#include #include #include @@ -29,7 +30,7 @@ class FeatureIndex { void insert(const GeometryCollection&, std::size_t index, const std::string& sourceLayerName, const std::string& bucketName); void query( - std::unordered_map>& result, + std::unordered_map>& result, const GeometryCollection& queryGeometry, const float bearing, const double tileSize, @@ -52,7 +53,7 @@ class FeatureIndex { private: void addFeature( - std::unordered_map>& result, + std::unordered_map>& result, const IndexedSubfeature &indexedFeature, const GeometryCollection& queryGeometry, const optional>& filterLayerIDs, diff --git a/src/mbgl/map/map.cpp b/src/mbgl/map/map.cpp index 38198d42ec..2a0246b654 100644 --- a/src/mbgl/map/map.cpp +++ b/src/mbgl/map/map.cpp @@ -722,14 +722,14 @@ std::vector pointsToCoordinates(const std::vector Map::queryRenderedFeatures(const ScreenCoordinate& point, const optional>& layerIDs) { +std::vector Map::queryRenderedFeatures(const ScreenCoordinate& point, const optional>& layerIDs) { if (!impl->style) return {}; auto queryGeometry = pointsToCoordinates({ point }, impl->transform.getState()); return impl->style->queryRenderedFeatures(queryGeometry, impl->transform.getZoom(), impl->transform.getAngle(), layerIDs); } -std::vector Map::queryRenderedFeatures(const std::array& box, const optional>& layerIDs) { +std::vector Map::queryRenderedFeatures(const std::array& box, const optional>& layerIDs) { if (!impl->style) return {}; std::vector queryPoints { diff --git a/src/mbgl/source/source.cpp b/src/mbgl/source/source.cpp index 18de7bc093..78bffbb9b3 100644 --- a/src/mbgl/source/source.cpp +++ b/src/mbgl/source/source.cpp @@ -498,13 +498,13 @@ struct TileQuery { double scale; }; -std::unordered_map> Source::queryRenderedFeatures( +std::unordered_map> Source::queryRenderedFeatures( const std::vector& queryGeometry, const double zoom, const double bearing, const optional>& layerIDs) { - std::unordered_map> result; + std::unordered_map> result; double minX = std::numeric_limits::infinity(); double minY = std::numeric_limits::infinity(); diff --git a/src/mbgl/source/source.hpp b/src/mbgl/source/source.hpp index a4b6961245..cc579e11e7 100644 --- a/src/mbgl/source/source.hpp +++ b/src/mbgl/source/source.hpp @@ -7,6 +7,7 @@ #include #include +#include #include #include @@ -72,7 +73,7 @@ public: std::forward_list getLoadedTiles() const; const std::vector& getTiles() const; - std::unordered_map> queryRenderedFeatures( + std::unordered_map> queryRenderedFeatures( const std::vector& queryGeometry, const double zoom, const double bearing, diff --git a/src/mbgl/style/filter.hpp b/src/mbgl/style/filter.hpp index 85878543f8..0a1dcbd17a 100644 --- a/src/mbgl/style/filter.hpp +++ b/src/mbgl/style/filter.hpp @@ -1,7 +1,7 @@ #pragma once #include -#include +#include #include #include diff --git a/src/mbgl/style/filter_evaluator.hpp b/src/mbgl/style/filter_evaluator.hpp index 27402ac211..0f3ee2a424 100644 --- a/src/mbgl/style/filter_evaluator.hpp +++ b/src/mbgl/style/filter_evaluator.hpp @@ -121,6 +121,16 @@ private: !std::is_arithmetic::value || std::is_same::value, bool> { return false; } + + bool operator()(const std::vector&, + const std::vector&) const { + return false; + } + + bool operator()(const std::unordered_map&, + const std::unordered_map&) const { + return false; + } }; template diff --git a/src/mbgl/style/style.cpp b/src/mbgl/style/style.cpp index 4d515b4e60..fc0f1de9c8 100644 --- a/src/mbgl/style/style.cpp +++ b/src/mbgl/style/style.cpp @@ -314,18 +314,17 @@ RenderData Style::getRenderData() const { return result; } -std::vector Style::queryRenderedFeatures( +std::vector Style::queryRenderedFeatures( const std::vector& queryGeometry, const double zoom, const double bearing, const optional>& layerIDs) { - std::vector>> sourceResults; + std::vector>> sourceResults; for (const auto& source : sources) { sourceResults.emplace_back(source->queryRenderedFeatures(queryGeometry, zoom, bearing, layerIDs)); } - - std::vector features; + std::vector features; auto featuresInserter = std::back_inserter(features); // Combine all results based on the style layer order. diff --git a/src/mbgl/style/style.hpp b/src/mbgl/style/style.hpp index 5dac4d4790..bfeebc28d5 100644 --- a/src/mbgl/style/style.hpp +++ b/src/mbgl/style/style.hpp @@ -13,6 +13,7 @@ #include #include #include +#include #include #include @@ -108,7 +109,7 @@ public: RenderData getRenderData() const; - std::vector queryRenderedFeatures( + std::vector queryRenderedFeatures( const std::vector& queryGeometry, const double zoom, const double bearing, diff --git a/src/mbgl/tile/geometry_tile.hpp b/src/mbgl/tile/geometry_tile.hpp index 57d8eab1cc..0bcb92b47b 100644 --- a/src/mbgl/tile/geometry_tile.hpp +++ b/src/mbgl/tile/geometry_tile.hpp @@ -1,7 +1,7 @@ #ifndef MBGL_MAP_GEOMETRY_TILE #define MBGL_MAP_GEOMETRY_TILE -#include +#include #include #include #include @@ -39,8 +39,8 @@ public: virtual ~GeometryTileFeature() = default; virtual FeatureType getType() const = 0; virtual optional getValue(const std::string& key) const = 0; - virtual std::unordered_map getProperties() const { return std::unordered_map{}; }; - virtual uint64_t getID() const { return 0; } + virtual Feature::property_map getProperties() const { return Feature::property_map(); } + virtual optional getID() const { return {}; } virtual GeometryCollection getGeometries() const = 0; virtual uint32_t getExtent() const { return defaultExtent; } }; diff --git a/src/mbgl/tile/tile_data.cpp b/src/mbgl/tile/tile_data.cpp index cb12e301f2..49a426b466 100644 --- a/src/mbgl/tile/tile_data.cpp +++ b/src/mbgl/tile/tile_data.cpp @@ -30,7 +30,7 @@ void TileData::dumpDebugLogs() const { } void TileData::queryRenderedFeatures( - std::unordered_map>&, + std::unordered_map>&, const GeometryCollection&, const double, const double, diff --git a/src/mbgl/tile/tile_data.hpp b/src/mbgl/tile/tile_data.hpp index 26c0032e35..338f246da0 100644 --- a/src/mbgl/tile/tile_data.hpp +++ b/src/mbgl/tile/tile_data.hpp @@ -4,6 +4,7 @@ #include #include #include +#include #include #include #include @@ -85,7 +86,7 @@ public: virtual void redoPlacement(const std::function&) {} virtual void queryRenderedFeatures( - std::unordered_map>& result, + std::unordered_map>& result, const GeometryCollection& queryGeometry, const double bearing, const double tileSize, diff --git a/src/mbgl/tile/vector_tile.cpp b/src/mbgl/tile/vector_tile.cpp index af30fa9986..aedb703898 100644 --- a/src/mbgl/tile/vector_tile.cpp +++ b/src/mbgl/tile/vector_tile.cpp @@ -102,7 +102,7 @@ std::unordered_map VectorTileFeature::getProperties() const { return properties; } -uint64_t VectorTileFeature::getID() const { +optional VectorTileFeature::getID() const { return id; } diff --git a/src/mbgl/tile/vector_tile.hpp b/src/mbgl/tile/vector_tile.hpp index 441d6827ac..153d7dcef4 100644 --- a/src/mbgl/tile/vector_tile.hpp +++ b/src/mbgl/tile/vector_tile.hpp @@ -23,13 +23,13 @@ public: FeatureType getType() const override { return type; } optional getValue(const std::string&) const override; std::unordered_map getProperties() const override; - uint64_t getID() const override; + optional getID() const override; GeometryCollection getGeometries() const override; uint32_t getExtent() const override; private: const VectorTileLayer& layer; - uint64_t id = 0; + optional id; FeatureType type = FeatureType::Unknown; packed_iter_type tags_iter; packed_iter_type geometry_iter; diff --git a/src/mbgl/tile/vector_tile_data.cpp b/src/mbgl/tile/vector_tile_data.cpp index c71b2b733d..1840dca9fe 100644 --- a/src/mbgl/tile/vector_tile_data.cpp +++ b/src/mbgl/tile/vector_tile_data.cpp @@ -191,7 +191,7 @@ void VectorTileData::redoPlacement(const std::function& callback) { } void VectorTileData::queryRenderedFeatures( - std::unordered_map>& result, + std::unordered_map>& result, const GeometryCollection& queryGeometry, const double bearing, const double tileSize, diff --git a/src/mbgl/tile/vector_tile_data.hpp b/src/mbgl/tile/vector_tile_data.hpp index 303fe343fe..52cef71d1b 100644 --- a/src/mbgl/tile/vector_tile_data.hpp +++ b/src/mbgl/tile/vector_tile_data.hpp @@ -4,6 +4,7 @@ #include #include #include +#include #include #include @@ -37,7 +38,7 @@ public: bool hasData() const override; void queryRenderedFeatures( - std::unordered_map>& result, + std::unordered_map>& result, const GeometryCollection& queryGeometry, const double bearing, const double tileSize, diff --git a/src/mbgl/util/value.hpp b/src/mbgl/util/value.hpp deleted file mode 100644 index 78507c7f25..0000000000 --- a/src/mbgl/util/value.hpp +++ /dev/null @@ -1,9 +0,0 @@ -#pragma once - -#include - -namespace mbgl { - -typedef variant Value; - -} // namespace mbgl -- cgit v1.2.1