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

Commit 8ed540e

Browse files
authored
Port fix for "at" expression off-by-1 error (#11375)
* Port fix for "at" expression off-by-1 error Refs mapbox/mapbox-gl-js#6269 * Consistency * Add ignores for symbol positiong differences in real-world tests
1 parent 4919099 commit 8ed540e

File tree

3 files changed

+14
-5
lines changed

3 files changed

+14
-5
lines changed

mapbox-gl-js

Submodule mapbox-gl-js updated 37 files

platform/node/test/ignores.json

+3
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,9 @@
2525
"render-tests/geojson/inline-polygon-symbol": "behavior needs reconciliation with gl-js",
2626
"render-tests/mixed-zoom/z10-z11": "https://github.com/mapbox/mapbox-gl-native/issues/10397",
2727
"render-tests/raster-masking/overlapping-zoom": "https://github.com/mapbox/mapbox-gl-native/issues/10195",
28+
"render-tests/real-world/bangkok": "https://github.com/mapbox/mapbox-gl-native/issues/10412",
29+
"render-tests/real-world/chicago": "https://github.com/mapbox/mapbox-gl-native/issues/10412",
30+
"render-tests/real-world/sanfrancisco": "https://github.com/mapbox/mapbox-gl-native/issues/10412",
2831
"render-tests/regressions/mapbox-gl-js#2305": "https://github.com/mapbox/mapbox-gl-native/issues/6927",
2932
"render-tests/regressions/mapbox-gl-js#2467": "https://github.com/mapbox/mapbox-gl-native/issues/10619",
3033
"render-tests/regressions/mapbox-gl-js#2762": "https://github.com/mapbox/mapbox-gl-native/issues/10619",

src/mbgl/style/expression/at.cpp

+10-4
Original file line numberDiff line numberDiff line change
@@ -19,15 +19,21 @@ EvaluationResult At::evaluate(const EvaluationContext& params) const {
1919
const auto i = evaluatedIndex->get<double>();
2020
const auto inputArray = evaluatedInput->get<std::vector<Value>>();
2121

22-
if (i < 0 || i >= inputArray.size()) {
22+
if (i < 0) {
2323
return EvaluationError {
24-
"Array index out of bounds: " + stringify(i) +
25-
" > " + util::toString(inputArray.size()) + "."
24+
"Array index out of bounds: " + util::toString(i) + " < 0."
25+
};
26+
}
27+
28+
if (i >= inputArray.size()) {
29+
return EvaluationError {
30+
"Array index out of bounds: " + util::toString(i) +
31+
" > " + util::toString(inputArray.size() - 1) + "."
2632
};
2733
}
2834
if (i != std::floor(i)) {
2935
return EvaluationError {
30-
"Array index must be an integer, but found " + stringify(i) + " instead."
36+
"Array index must be an integer, but found " + util::toString(i) + " instead."
3137
};
3238
}
3339
return inputArray[static_cast<std::size_t>(i)];

0 commit comments

Comments
 (0)