diff options
author | John Firebaugh <john.firebaugh@gmail.com> | 2016-05-03 17:25:08 -0700 |
---|---|---|
committer | Bruno de Oliveira Abinader <bruno@mapbox.com> | 2016-05-04 09:56:34 +0300 |
commit | a64fe5062f48b6aa4b98b382734856e1005480fb (patch) | |
tree | e7ff49ee0c359624446a0333609a52f377dbbd39 /test | |
parent | 23c450223605cfcc06189ada4a01002ce0579f4f (diff) | |
download | qtlocation-mapboxgl-a64fe5062f48b6aa4b98b382734856e1005480fb.tar.gz |
[core] Simplify FilterEvaluator and fix crash
Previous implementation was assigning a temporary to FilterEvaluator<T>::extractor.
Diffstat (limited to 'test')
-rw-r--r-- | test/style/filter.cpp | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/test/style/filter.cpp b/test/style/filter.cpp index 4d6963267a..da0e5ff4a3 100644 --- a/test/style/filter.cpp +++ b/test/style/filter.cpp @@ -13,26 +13,28 @@ using namespace mbgl; typedef std::multimap<std::string, mbgl::Value> Properties; -class Extractor { +class StubFeature : public GeometryTileFeature { public: - inline Extractor(const Properties& properties_, FeatureType type_) + inline StubFeature(const Properties& properties_, FeatureType type_) : properties(properties_) , type(type_) {} - optional<Value> getValue(const std::string &key) const { - if (key == "$type") - return Value(uint64_t(type)); + optional<Value> getValue(const std::string &key) const override { auto it = properties.find(key); if (it == properties.end()) return optional<Value>(); return it->second; } - FeatureType getType() const { + FeatureType getType() const override { return type; } + GeometryCollection getGeometries() const override { + return GeometryCollection(); + } + private: const Properties properties; FeatureType type; @@ -45,7 +47,8 @@ Filter parse(const char * expression) { } bool evaluate(const Filter& filter, const Properties& properties, FeatureType type = FeatureType::Unknown) { - FilterEvaluator<Extractor> evaluator({properties, type}); + StubFeature feature(properties, type); + FilterEvaluator evaluator(feature); return Filter::visit(filter, evaluator); } |