diff options
m--------- | mapbox-gl-js | 0 | ||||
-rw-r--r-- | src/mbgl/style/conversion/stringify.hpp | 20 | ||||
-rw-r--r-- | src/mbgl/style/expression/interpolate.cpp | 6 | ||||
-rw-r--r-- | test/style/conversion/stringify.test.cpp | 2 |
4 files changed, 21 insertions, 7 deletions
diff --git a/mapbox-gl-js b/mapbox-gl-js -Subproject 8a19f6079933817fd73eed71159130b8ac53a00 +Subproject 34902f8db3f8a3757a465d62a96b8fa731ee146 diff --git a/src/mbgl/style/conversion/stringify.hpp b/src/mbgl/style/conversion/stringify.hpp index 7924a442c4..9e16d8b2c6 100644 --- a/src/mbgl/style/conversion/stringify.hpp +++ b/src/mbgl/style/conversion/stringify.hpp @@ -303,9 +303,13 @@ public: template <class T> void operator()(const ExponentialStops<T>& f) { writer.Key("type"); - writer.String("exponential"); - writer.Key("base"); - writer.Double(f.base); + if (f.base == 1) { + writer.String("linear"); + } else { + writer.String("exponential"); + writer.Key("base"); + writer.Double(f.base); + } writer.Key("stops"); stringifyStops(f.stops); } @@ -335,9 +339,13 @@ public: template <class T> void operator()(const CompositeExponentialStops<T>& f) { writer.Key("type"); - writer.String("exponential"); - writer.Key("base"); - writer.Double(f.base); + if (f.base == 1) { + writer.String("linear"); + } else { + writer.String("exponential"); + writer.Key("base"); + writer.Double(f.base); + } writer.Key("stops"); stringifyCompositeStops(f.stops); } 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 0b2940a0e0..06349c9388 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 })), + "{\"type\":\"linear\",\"stops\":[[0.0,1.0]]}"); ASSERT_EQ(stringify(CameraFunction<float>(ExponentialStops<float> { {{0, 1}}, 2 })), "{\"type\":\"exponential\",\"base\":2.0,\"stops\":[[0.0,1.0]]}"); ASSERT_EQ(stringify(CameraFunction<float>(IntervalStops<float> { {{0, 1}} })), |