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

Fix style parsing bug for constant expressions #11606

Merged
merged 4 commits into from
Apr 9, 2018
Merged
Show file tree
Hide file tree
Changes from 2 commits
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
14 changes: 11 additions & 3 deletions include/mbgl/style/conversion/data_driven_property_value.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,17 @@ struct Converter<DataDrivenPropertyValue<T>> {
} else {
// If an expression is neither zoom- nor feature-dependent, it
// should have been reduced to a Literal when it was parsed.
auto literal = dynamic_cast<Literal*>(expression->get());
assert(literal);
optional<T> constant = fromExpressionValue<T>(literal->getValue());
optional<T> constant;
if (auto literal = dynamic_cast<Literal*>(expression->get())) {
// cool, it's pre-folded to a literal
constant = fromExpressionValue<T>(literal->getValue());
} else {
// we didn't manage to fold to a literal during parsing, so evaluate it now
EvaluationContext params(nullptr);
EvaluationResult evaluated((*expression)->evaluate(params));
Copy link
Contributor

Choose a reason for hiding this comment

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

Does this need to check for heatmap-density or other computed properties?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah, good question -- heatmap-density is used only in heatmap-color, which isn't data-driven and so isn't parsed as a DataDrivenPropertyValue. Rather, it actually has its own wrapper HeatmapColorPropertyValue

assert(evaluated);
constant = fromExpressionValue<T>(*evaluated);
}
if (!constant) {
return {};
}
Expand Down
2 changes: 2 additions & 0 deletions platform/node/test/ignores.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
{
"query-tests/circle-pitch-scale/viewport-inside-align-map": "https://github.com/mapbox/mapbox-gl-native/issues/10615",
"query-tests/circle-pitch-scale/viewport-inside-align-viewport": "https://github.com/mapbox/mapbox-gl-native/issues/10615",
"query-tests/edge-cases/box-cutting-antimeridian-z0": "https://github.com/mapbox/mapbox-gl-native/issues/11607",
"query-tests/edge-cases/null-island": "https://github.com/mapbox/mapbox-gl-native/issues/11607",
"query-tests/geometry/multilinestring": "needs investigation",
"query-tests/geometry/multipolygon": "needs investigation",
"query-tests/geometry/polygon": "needs investigation",
Expand Down