Skip to content
This repository has been archived by the owner on Aug 8, 2023. It is now read-only.

Add abs, round, floor, ceil operators #11653

Merged
merged 8 commits into from
Apr 11, 2018
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion mapbox-gl-js
Submodule mapbox-gl-js updated 36 files
+6 −0 CHANGELOG.md
+1 −0 docs/components/example.js
+7 −0 docs/components/expression-metadata.js
+1 −1 docs/pages/example/animate-point-along-route.html
+0 −1 docs/pages/example/check-for-support.html
+2 −2 docs/pages/example/filter-features-within-map-view.html
+1 −1 docs/pages/example/mapbox-gl-geocoder-limit-region.js
+7 −4 docs/pages/example/mapbox-gl-geocoder-local-geocoder.html
+1 −1 docs/pages/example/mapbox-gl-geocoder-local-geocoder.js
+1 −1 docs/pages/example/mapbox-gl-geocoder-outside-the-map.js
+1 −1 docs/pages/example/mapbox-gl-geocoder-proximity-bias.js
+1 −0 docs/pages/example/mapbox-gl-geocoder.js
+1 −1 docs/pages/example/mapbox-gl-rtl-text.html
+12 −2 docs/pages/example/popup-on-click.html
+12 −2 docs/pages/example/popup-on-hover.html
+28 −31 docs/pages/example/third-party.html
+1 −1 docs/pages/example/third-party.js
+16 −14 docs/pages/style-spec.js
+2 −2 package.json
+1 −1 src/index.js
+26 −0 src/style-spec/expression/definitions/index.js
+42 −6 src/style-spec/reference/v8.json
+18 −5 src/ui/control/geolocate_control.js
+33 −4 src/ui/map.js
+15 −1 src/ui/marker.js
+17 −0 test/integration/expression-tests/abs/basic/test.json
+23 −0 test/integration/expression-tests/ceil/basic/test.json
+23 −0 test/integration/expression-tests/floor/basic/test.json
+23 −0 test/integration/expression-tests/round/basic/test.json
+7 −2 test/integration/lib/expression.js
+25 −0 test/unit/ui/control/geolocate.test.js
+77 −0 test/unit/ui/marker.test.js
+1 −1 vendor/dotcom-page-shell/page-shell-script.js
+22 −2 vendor/dotcom-page-shell/page-shell-styles.css
+482 −424 vendor/dotcom-page-shell/react-page-shell.js
+1 −1 yarn.lock
6 changes: 6 additions & 0 deletions src/mbgl/style/expression/compound_expression.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -362,6 +363,11 @@ std::unordered_map<std::string, CompoundExpressionRegistry::Definition> initiali
return result;
});

define("round", [](double x) -> Result<double> { return { std::round(x) }; });
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The extra brackets in the return expression should be unnecessary.

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; });
Expand Down