From 343df18954be90c26ace7bcf1c21cf434737693a Mon Sep 17 00:00:00 2001 From: Ander Conselvan de Oliveira Date: Tue, 2 Apr 2019 12:32:29 +0300 Subject: [PATCH] [core] Fix some of the legacy interval function expression tests The tests for conversion of legacy interval functions to expressions expects that the first stop in the "step" expression be omitted. --- platform/node/test/ignores.json | 7 ------- src/mbgl/style/conversion/function.cpp | 12 ++++++++++++ 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/platform/node/test/ignores.json b/platform/node/test/ignores.json index d7cbe0782..4cdd7795e 100644 --- a/platform/node/test/ignores.json +++ b/platform/node/test/ignores.json @@ -23,19 +23,12 @@ "expression-tests/legacy/exponential/number-default": "https://github.com/mapbox/mapbox-gl-native/issues/12747", "expression-tests/legacy/identity/color-default": "https://github.com/mapbox/mapbox-gl-native/issues/12747", "expression-tests/legacy/identity/enum-default": "https://github.com/mapbox/mapbox-gl-native/issues/12747", - "expression-tests/legacy/interval/array": "https://github.com/mapbox/mapbox-gl-native/issues/12747", "expression-tests/legacy/interval/array-default": "https://github.com/mapbox/mapbox-gl-native/issues/12747", - "expression-tests/legacy/interval/color": "https://github.com/mapbox/mapbox-gl-native/issues/12747", "expression-tests/legacy/interval/color-default": "https://github.com/mapbox/mapbox-gl-native/issues/12747", "expression-tests/legacy/interval/composite": "https://github.com/mapbox/mapbox-gl-native/issues/12747", "expression-tests/legacy/interval/composite-default": "https://github.com/mapbox/mapbox-gl-native/issues/12747", - "expression-tests/legacy/interval/duplicate-stops": "https://github.com/mapbox/mapbox-gl-native/issues/12747", - "expression-tests/legacy/interval/implicit": "https://github.com/mapbox/mapbox-gl-native/issues/12747", - "expression-tests/legacy/interval/number": "https://github.com/mapbox/mapbox-gl-native/issues/12747", "expression-tests/legacy/interval/number-default": "https://github.com/mapbox/mapbox-gl-native/issues/12747", - "expression-tests/legacy/interval/string": "https://github.com/mapbox/mapbox-gl-native/issues/12747", "expression-tests/legacy/interval/string-default": "https://github.com/mapbox/mapbox-gl-native/issues/12747", - "expression-tests/legacy/interval/tokens-property": "https://github.com/mapbox/mapbox-gl-native/issues/12747", "expression-tests/legacy/interval/tokens-zoom": "https://github.com/mapbox/mapbox-gl-native/issues/12747", "query-tests/geometry/multilinestring": "needs investigation", "query-tests/geometry/multipolygon": "needs investigation", diff --git a/src/mbgl/style/conversion/function.cpp b/src/mbgl/style/conversion/function.cpp index 179ad0e43..33ed7c985 100644 --- a/src/mbgl/style/conversion/function.cpp +++ b/src/mbgl/style/conversion/function.cpp @@ -356,6 +356,17 @@ static optional>> convertStops(type return { std::move(stops) }; } +static void omitFirstStop(std::map>& stops) { + double min = std::numeric_limits::max(); + for (auto& s : stops) { + if (s.first < min) { + min = s.first; + } + } + stops.emplace(-std::numeric_limits::infinity(), std::move(stops[min])); + stops.erase(min); +} + template optional>> convertBranches(type::Type type, const Convertible& value, @@ -472,6 +483,7 @@ static optional> convertIntervalFunction(type::Type if (!stops) { return nullopt; } + omitFirstStop(*stops); return step(type, std::move(input), std::move(*stops)); }