From e52f23795d130e3a6f19c39d90c61a707c3de46e Mon Sep 17 00:00:00 2001 From: zmiao Date: Tue, 10 Mar 2020 00:01:34 +0200 Subject: [core] Introduce distance expression Add distance unit choices Fix cmake and add license Add support for LineString Features Add template to geometry helper function Only support line and point Rename geometry_within.cpp hpp file to geometry_util.cpp .hpp Remove incorrect indexFilter, fix pointSetsDistance Fix distance expression --- include/mbgl/style/expression/distance.hpp | 38 ++++++++++++++++++++++++++++ include/mbgl/style/expression/expression.hpp | 3 ++- include/mbgl/style/expression/within.hpp | 1 - 3 files changed, 40 insertions(+), 2 deletions(-) create mode 100644 include/mbgl/style/expression/distance.hpp (limited to 'include/mbgl') diff --git a/include/mbgl/style/expression/distance.hpp b/include/mbgl/style/expression/distance.hpp new file mode 100644 index 0000000000..e034b9452f --- /dev/null +++ b/include/mbgl/style/expression/distance.hpp @@ -0,0 +1,38 @@ +#pragma once + +#include +#include +#include + +namespace mbgl { +namespace style { +namespace expression { + +class Distance final : public Expression { +public: + Distance(GeoJSON geoJSONSource_, Feature::geometry_type geometries_, mapbox::cheap_ruler::CheapRuler::Unit unit_); + + ~Distance() override; + + EvaluationResult evaluate(const EvaluationContext&) const override; + + static ParseResult parse(const mbgl::style::conversion::Convertible&, ParsingContext&); + + void eachChild(const std::function&) const override {} + + bool operator==(const Expression& e) const override; + + std::vector> possibleOutputs() const override; + + mbgl::Value serialize() const override; + std::string getOperator() const override; + +private: + GeoJSON geoJSONSource; + Feature::geometry_type geometries; + mapbox::cheap_ruler::CheapRuler::Unit unit; +}; + +} // namespace expression +} // namespace style +} // namespace mbgl diff --git a/include/mbgl/style/expression/expression.hpp b/include/mbgl/style/expression/expression.hpp index e522821185..51cc3b0f15 100644 --- a/include/mbgl/style/expression/expression.hpp +++ b/include/mbgl/style/expression/expression.hpp @@ -169,7 +169,8 @@ enum class Kind : int32_t { NumberFormat, ImageExpression, In, - Within + Within, + Distance }; class Expression { diff --git a/include/mbgl/style/expression/within.hpp b/include/mbgl/style/expression/within.hpp index a8e45f9bf0..37e27f4940 100644 --- a/include/mbgl/style/expression/within.hpp +++ b/include/mbgl/style/expression/within.hpp @@ -2,7 +2,6 @@ #include #include -#include #include namespace mbgl { -- cgit v1.2.1