summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMinh Nguyễn <mxn@1ec5.org>2018-03-29 12:55:29 -0700
committerMinh Nguyễn <mxn@1ec5.org>2018-03-30 15:36:30 -0700
commitf4d9fb816d4a22bcc17a07452a926f4f06e75d3b (patch)
treee4b08eb47a1425b01d18c9e0676a1c6b982940b1
parentcf5d2ca4efc6e00798f03aebaa1c6902f0330230 (diff)
downloadqtlocation-mapboxgl-f4d9fb816d4a22bcc17a07452a926f4f06e75d3b.tar.gz
[core] Round-trip linear interpolators
m---------mapbox-gl-js0
-rw-r--r--src/mbgl/style/expression/interpolate.cpp6
-rw-r--r--test/style/conversion/stringify.test.cpp4
3 files changed, 8 insertions, 2 deletions
diff --git a/mapbox-gl-js b/mapbox-gl-js
-Subproject 3c07b72a59d78bc6240a8e3d77a54bec7619af5
+Subproject 34902f8db3f8a3757a465d62a96b8fa731ee146
diff --git a/src/mbgl/style/expression/interpolate.cpp b/src/mbgl/style/expression/interpolate.cpp
index 30b2cba81b..daad8523f2 100644
--- a/src/mbgl/style/expression/interpolate.cpp
+++ b/src/mbgl/style/expression/interpolate.cpp
@@ -223,7 +223,11 @@ mbgl::Value Interpolate<T>::serialize() const {
interpolator.match(
[&](const ExponentialInterpolator& exponential) {
- serialized.emplace_back(std::vector<mbgl::Value>{{ std::string("exponential"), exponential.base }});
+ if (exponential.base == 1) {
+ serialized.emplace_back(std::vector<mbgl::Value>{{ std::string("linear") }});
+ } else {
+ serialized.emplace_back(std::vector<mbgl::Value>{{ std::string("exponential"), exponential.base }});
+ }
},
[&](const CubicBezierInterpolator& cubicBezier) {
static const std::string cubicBezierTag("cubic-bezier");
diff --git a/test/style/conversion/stringify.test.cpp b/test/style/conversion/stringify.test.cpp
index cb3b62dc62..136f276aaf 100644
--- a/test/style/conversion/stringify.test.cpp
+++ b/test/style/conversion/stringify.test.cpp
@@ -80,6 +80,8 @@ TEST(Stringify, Filter) {
}
TEST(Stringify, CameraFunction) {
+ ASSERT_EQ(stringify(CameraFunction<float>(ExponentialStops<float> { {{0, 1}}, 1 })),
+ "[\"interpolate\",[\"linear\"],[\"zoom\"],0.0,1.0]");
ASSERT_EQ(stringify(CameraFunction<float>(ExponentialStops<float> { {{0, 1}}, 2 })),
"[\"interpolate\",[\"exponential\",2.0],[\"zoom\"],0.0,1.0]");
ASSERT_EQ(stringify(CameraFunction<float>(IntervalStops<float> { {{0, 1}} })),
@@ -109,7 +111,7 @@ TEST(Stringify, CompositeFunction) {
2
}, 0.0f)),
"[\"interpolate\","
- "[\"exponential\",1.0],"
+ "[\"linear\"],"
"[\"zoom\"],"
"0.0,[\"interpolate\",[\"exponential\",2.0],[\"number\",[\"get\",\"property\"]],0.0,1.0],"
"1.0,[\"interpolate\",[\"exponential\",2.0],[\"number\",[\"get\",\"property\"]],0.0,1.0]]");