summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/mbgl/style/filter.hpp2
-rw-r--r--include/mbgl/style/filter_evaluator.hpp9
-rw-r--r--test/style/filter.test.cpp35
3 files changed, 20 insertions, 26 deletions
diff --git a/include/mbgl/style/filter.hpp b/include/mbgl/style/filter.hpp
index a204a2b17a..d90fdb93ed 100644
--- a/include/mbgl/style/filter.hpp
+++ b/include/mbgl/style/filter.hpp
@@ -264,8 +264,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 66223d7282..c4c9d926de 100644
--- a/include/mbgl/style/filter_evaluator.hpp
+++ b/include/mbgl/style/filter_evaluator.hpp
@@ -237,15 +237,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;
- });
-}
-
template <class GeometryTileFeature>
bool Filter::operator()(const GeometryTileFeature& feature) const {
return operator()(feature.getType(), feature.getID(), [&] (const auto& key) { return feature.getValue(key); });
diff --git a/test/style/filter.test.cpp b/test/style/filter.test.cpp
index 73f8e7626d..78b04e4265 100644
--- a/test/style/filter.test.cpp
+++ b/test/style/filter.test.cpp
@@ -1,6 +1,5 @@
#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 +16,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, FeatureType type = FeatureType::Unknown) {
+ return StubGeometryTileFeature({}, type, {}, properties);
}
TEST(Filter, EqualsString) {
@@ -46,15 +43,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(feature({{}}, FeatureType::Point)));
+ ASSERT_TRUE(f(feature({{}}, 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(feature({{}}, FeatureType::Point)));
+ ASSERT_TRUE(f(feature({{}}, FeatureType::LineString)));
+ ASSERT_TRUE(f(feature({{}}, FeatureType::Polygon)));
}
TEST(Filter, Any) {
@@ -110,14 +107,22 @@ TEST(Filter, NotHas) {
}
TEST(Filter, ID) {
- Feature feature1 { Point<double>() };
- feature1.id = { uint64_t(1234) };
+ StubGeometryTileFeature feature1 {
+ FeatureIdentifier(uint64_t(1234)),
+ FeatureType::Point,
+ {},
+ {}
+ };
ASSERT_TRUE(parse("[\"==\", \"$id\", 1234]")(feature1));
ASSERT_FALSE(parse("[\"==\", \"$id\", \"1234\"]")(feature1));
- Feature feature2 { Point<double>() };
- feature2.properties["id"] = { uint64_t(1234) };
+ StubGeometryTileFeature feature2 {
+ {},
+ FeatureType::Point,
+ {},
+ {{ "id", uint64_t(1234) }}
+ };
ASSERT_FALSE(parse("[\"==\", \"$id\", 1234]")(feature2));
}