diff options
author | Anand Thakker <anandthakker@users.noreply.github.com> | 2018-04-11 12:03:56 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-04-11 12:03:56 -0400 |
commit | f0f67b4788f967ee34f307312db302cecb68dd0b (patch) | |
tree | 90f207635e1c6a67aed11655e9e03b058c556665 /src | |
parent | 797486bc5f4d064821865c72425911994fa9fe22 (diff) | |
download | qtlocation-mapboxgl-f0f67b4788f967ee34f307312db302cecb68dd0b.tar.gz |
Add abs, round, floor, ceil operators (#11653)
* Add abs, round, floor, ceil operators
Port of https://github.com/mapbox/mapbox-gl-js/pull/6496
* [ios, macos] Simplified abs, ceiling, floor expressions
* [ios, macos] Added rounding expression function
* [android] - binding integration for round, ceil, floor and abs expressions
* Update mapbox-gl-js to include non-integer rounding test
* Drop extra braces
* mapbox-gl-js -> master
* Update style-spec docs -> PropertyFactory.java
Diffstat (limited to 'src')
-rw-r--r-- | src/mbgl/style/expression/compound_expression.cpp | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/src/mbgl/style/expression/compound_expression.cpp b/src/mbgl/style/expression/compound_expression.cpp index 77b294b380..c36ffa33e3 100644 --- a/src/mbgl/style/expression/compound_expression.cpp +++ b/src/mbgl/style/expression/compound_expression.cpp @@ -6,6 +6,7 @@ #include <mbgl/util/ignore.hpp> #include <mbgl/util/string.hpp> #include <mbgl/util/platform.hpp> +#include <cmath> namespace mbgl { namespace style { @@ -362,6 +363,11 @@ std::unordered_map<std::string, CompoundExpressionRegistry::Definition> initiali return result; }); + define("round", [](double x) -> Result<double> { return std::round(x); }); + define("floor", [](double x) -> Result<double> { return std::floor(x); }); + define("ceil", [](double x) -> Result<double> { return std::ceil(x); }); + define("abs", [](double x) -> Result<double> { return std::abs(x); }); + define(">", [](double lhs, double rhs) -> Result<bool> { return lhs > rhs; }); define(">", [](const std::string& lhs, const std::string& rhs) -> Result<bool> { return lhs > rhs; }); define(">=", [](double lhs, double rhs) -> Result<bool> { return lhs >= rhs; }); |