diff options
Diffstat (limited to 'src/mbgl/style/expression/compound_expression.cpp')
-rw-r--r-- | src/mbgl/style/expression/compound_expression.cpp | 25 |
1 files changed, 12 insertions, 13 deletions
diff --git a/src/mbgl/style/expression/compound_expression.cpp b/src/mbgl/style/expression/compound_expression.cpp index 86d968c521..c257dbf2bb 100644 --- a/src/mbgl/style/expression/compound_expression.cpp +++ b/src/mbgl/style/expression/compound_expression.cpp @@ -3,9 +3,11 @@ #include <mbgl/style/expression/util.hpp> #include <mbgl/tile/geometry_tile_data.hpp> #include <mbgl/math/log2.hpp> +#include <mbgl/util/i18n.hpp> #include <mbgl/util/ignore.hpp> #include <mbgl/util/string.hpp> #include <mbgl/util/platform.hpp> +#include <cmath> namespace mbgl { namespace style { @@ -209,12 +211,7 @@ std::unordered_map<std::string, CompoundExpressionRegistry::Definition> initiali ); }); define("to-rgba", [](const Color& color) -> Result<std::array<double, 4>> { - return std::array<double, 4> {{ - 255 * color.r / color.a, - 255 * color.g / color.a, - 255 * color.b / color.a, - color.a - }}; + return color.toArray(); }); define("rgba", rgba); @@ -271,13 +268,6 @@ std::unordered_map<std::string, CompoundExpressionRegistry::Definition> initiali return object.at(key); }); - define("length", [](const std::vector<Value>& arr) -> Result<double> { - return arr.size(); - }); - define("length", [] (const std::string s) -> Result<double> { - return s.size(); - }); - define("properties", [](const EvaluationContext& params) -> Result<std::unordered_map<std::string, Value>> { if (!params.feature) { return EvaluationError { @@ -374,6 +364,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; }); @@ -385,6 +380,10 @@ std::unordered_map<std::string, CompoundExpressionRegistry::Definition> initiali define("!", [](bool e) -> Result<bool> { return !e; }); + define("is-supported-script", [](const std::string& x) -> Result<bool> { + return util::i18n::isStringInSupportedScript(x); + }); + define("upcase", [](const std::string& input) -> Result<std::string> { return platform::uppercase(input); }); |