summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLucas Wojciechowski <lucas@mapbox.com>2018-02-13 16:00:22 -0800
committerLucas Wojciechowski <lucas@mapbox.com>2018-03-07 11:46:16 -0800
commitc9618fd8ecf43b222237d0de9fcabb0e0fa458dc (patch)
treef8bf08a33810d4facf1875816bb5a4d4b3f047ee
parentbbdce800a597ea52abe6db23fa9ecf60ac3df4b3 (diff)
downloadqtlocation-mapboxgl-c9618fd8ecf43b222237d0de9fcabb0e0fa458dc.tar.gz
Remove Filter::operator()(const Feature&)
-rw-r--r--include/mbgl/style/filter.hpp2
-rw-r--r--include/mbgl/style/filter_evaluator.hpp11
-rw-r--r--test/style/filter.test.cpp25
3 files changed, 11 insertions, 27 deletions
diff --git a/include/mbgl/style/filter.hpp b/include/mbgl/style/filter.hpp
index e27c3bfc10..9ab7e2e950 100644
--- a/include/mbgl/style/filter.hpp
+++ b/include/mbgl/style/filter.hpp
@@ -275,8 +275,6 @@ class Filter : public FilterBase {
public:
using FilterBase::FilterBase;
- bool operator()(const Feature&) const;
-
template <class GeometryTileFeature>
bool operator()(const GeometryTileFeature&) const;
diff --git a/include/mbgl/style/filter_evaluator.hpp b/include/mbgl/style/filter_evaluator.hpp
index 747627210d..6d5a7581d9 100644
--- a/include/mbgl/style/filter_evaluator.hpp
+++ b/include/mbgl/style/filter_evaluator.hpp
@@ -241,17 +241,6 @@ private:
}
};
-inline bool Filter::operator()(const Feature& feature) const {
- return operator()(apply_visitor(ToFeatureType(), feature.geometry), feature.id, [&] (const std::string& key) -> optional<Value> {
- auto it = feature.properties.find(key);
- if (it == feature.properties.end())
- return {};
- return it->second;
-
- // TODO include GeoJSONFeature-wrapped feature
- }, expression::EvaluationContext { 0.0 } );
-}
-
template <class GeometryTileFeature>
bool Filter::operator()(const GeometryTileFeature& feature) const {
return operator()(feature.getType(), feature.getID(), [&] (const auto& key) { return feature.getValue(key); }, expression::EvaluationContext { &feature });
diff --git a/test/style/filter.test.cpp b/test/style/filter.test.cpp
index 73f8e7626d..a67e418456 100644
--- a/test/style/filter.test.cpp
+++ b/test/style/filter.test.cpp
@@ -1,6 +1,7 @@
#include <mbgl/test/util.hpp>
#include <mbgl/util/feature.hpp>
#include <mbgl/util/geometry.hpp>
+#include <mbgl/test/stub_geometry_tile_feature.hpp>
#include <mbgl/style/filter.hpp>
#include <mbgl/style/filter_evaluator.hpp>
@@ -17,10 +18,8 @@ Filter parse(const char * expression) {
return *filter;
}
-Feature feature(const PropertyMap& properties, const Geometry<double>& geometry = Point<double>()) {
- Feature result { geometry };
- result.properties = properties;
- return result;
+StubGeometryTileFeature feature(const PropertyMap& properties) {
+ return StubGeometryTileFeature { properties };
}
TEST(Filter, EqualsString) {
@@ -46,15 +45,15 @@ TEST(Filter, EqualsNumber) {
TEST(Filter, EqualsType) {
Filter f = parse(R"(["==", "$type", "LineString"])");
- ASSERT_FALSE(f(feature({{}}, Point<double>())));
- ASSERT_TRUE(f(feature({{}}, LineString<double>())));
+ ASSERT_FALSE(f(StubGeometryTileFeature({}, FeatureType::Point, {}, {})));
+ ASSERT_TRUE(f(StubGeometryTileFeature({}, FeatureType::LineString, {}, {})));
}
TEST(Filter, InType) {
Filter f = parse(R"(["in", "$type", "LineString", "Polygon"])");
- ASSERT_FALSE(f(feature({{}}, Point<double>())));
- ASSERT_TRUE(f(feature({{}}, LineString<double>())));
- ASSERT_TRUE(f(feature({{}}, Polygon<double>())));
+ ASSERT_FALSE(f(StubGeometryTileFeature({}, FeatureType::Point, {}, {})));
+ ASSERT_TRUE(f(StubGeometryTileFeature({}, FeatureType::LineString, {}, {})));
+ ASSERT_TRUE(f(StubGeometryTileFeature({}, FeatureType::Polygon, {}, {})));
}
TEST(Filter, Any) {
@@ -110,14 +109,12 @@ TEST(Filter, NotHas) {
}
TEST(Filter, ID) {
- Feature feature1 { Point<double>() };
- feature1.id = { uint64_t(1234) };
+ StubGeometryTileFeature feature1 { FeatureIdentifier{ int64_t{ 1234 } }, {}, {}, {} };
ASSERT_TRUE(parse("[\"==\", \"$id\", 1234]")(feature1));
ASSERT_FALSE(parse("[\"==\", \"$id\", \"1234\"]")(feature1));
-
- Feature feature2 { Point<double>() };
- feature2.properties["id"] = { uint64_t(1234) };
+
+ StubGeometryTileFeature feature2 { {{ "id", uint64_t(1234) }} };
ASSERT_FALSE(parse("[\"==\", \"$id\", 1234]")(feature2));
}