diff options
author | zmiao <miao.zhao@mapbox.com> | 2020-03-10 00:01:34 +0200 |
---|---|---|
committer | zmiao <miao.zhao@mapbox.com> | 2020-04-22 15:53:08 +0300 |
commit | e52f23795d130e3a6f19c39d90c61a707c3de46e (patch) | |
tree | 9693c271c5b390a668eab7ad81a2a21fdb67f3bb /include | |
parent | 78b09885253f534efceab96e93dd66ef0923cd74 (diff) | |
download | qtlocation-mapboxgl-e52f23795d130e3a6f19c39d90c61a707c3de46e.tar.gz |
[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
Diffstat (limited to 'include')
-rw-r--r-- | include/mbgl/style/expression/distance.hpp | 38 | ||||
-rw-r--r-- | include/mbgl/style/expression/expression.hpp | 3 | ||||
-rw-r--r-- | include/mbgl/style/expression/within.hpp | 1 |
3 files changed, 40 insertions, 2 deletions
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 <mapbox/cheap_ruler.hpp> +#include <mbgl/style/expression/expression.hpp> +#include <mbgl/util/geojson.hpp> + +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<void(const Expression&)>&) const override {} + + bool operator==(const Expression& e) const override; + + std::vector<optional<Value>> 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 <mbgl/style/expression/expression.hpp> #include <mbgl/util/geojson.hpp> -#include <mbgl/util/geometry_within.hpp> #include <mbgl/util/optional.hpp> namespace mbgl { |