diff options
Diffstat (limited to 'include/mbgl/style/expression/within.hpp')
-rw-r--r-- | include/mbgl/style/expression/within.hpp | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/include/mbgl/style/expression/within.hpp b/include/mbgl/style/expression/within.hpp new file mode 100644 index 0000000000..5e2b5e0671 --- /dev/null +++ b/include/mbgl/style/expression/within.hpp @@ -0,0 +1,43 @@ +#pragma once + +#include <mbgl/style/conversion.hpp> +#include <mbgl/style/expression/expression.hpp> +#include <mbgl/style/expression/parsing_context.hpp> +#include <mbgl/util/geojson.hpp> + +#include <memory> + +namespace mbgl { +namespace style { +namespace expression { + +class Within : public Expression { +public: + Within(GeoJSON& geojson) : Expression(Kind::Within, type::Boolean), geoJSONSource(geojson) {} + + EvaluationResult evaluate(const EvaluationContext&) const override; + + static ParseResult parse(const mbgl::style::conversion::Convertible&, ParsingContext&); + + void eachChild(const std::function<void(const Expression&)>&) const override {} + + bool operator==(const Expression& e) const override { + if (e.getKind() == Kind::Within) { + auto rhs = static_cast<const Within*>(&e); + return geoJSONSource == rhs->geoJSONSource; + } + return false; + } + + std::vector<optional<Value>> possibleOutputs() const override { return {{false}}; } + + mbgl::Value serialize() const override; + std::string getOperator() const override { return "Within"; } + +private: + GeoJSON geoJSONSource; +}; + +} // namespace expression +} // namespace style +} // namespace mbgl |