summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnand Thakker <github@anandthakker.net>2018-04-10 21:05:08 -0400
committerAnand Thakker <github@anandthakker.net>2018-04-10 21:05:08 -0400
commit49364b29cbea987d0be239d7aed2d3523d3f6451 (patch)
treecbcdf13f6c59663c7333bf84b5770c332ce35f4b
parent80474b24f2cbb2a59022b964ed326d6efd20bbe7 (diff)
downloadqtlocation-mapboxgl-49364b29cbea987d0be239d7aed2d3523d3f6451.tar.gz
Add abs, round, floor, ceil operators
Port of https://github.com/mapbox/mapbox-gl-js/pull/6496
m---------mapbox-gl-js0
-rw-r--r--src/mbgl/style/expression/compound_expression.cpp6
2 files changed, 6 insertions, 0 deletions
diff --git a/mapbox-gl-js b/mapbox-gl-js
-Subproject b01859294fec88111601028a539e45be1f08866
+Subproject d9e65d698302da9560cd55feda8247a04af69a5
diff --git a/src/mbgl/style/expression/compound_expression.cpp b/src/mbgl/style/expression/compound_expression.cpp
index 77b294b380..44857cf042 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; });