stamen / chartographer

https://stamen.github.io/chartographer/
MIT License
19 stars 4 forks source link

Parse conditionals more reliably #30

Open aparlato opened 2 years ago

aparlato commented 2 years ago

See https://github.com/stamen/mapbox-gl-style-design-system/blob/main/src/styles/expandLayers.js#L76-L94 and https://github.com/stamen/mapbox-gl-style-design-system/blob/main/src/styles/expandLayers.js#L131-L137

There's logic in expandLayers that finds properties and property values within the conditions of match and case expressions. It does this fairly naively right now which means it's fragile.

For case, it finds the property through finding a lookup expression, then the property values by filtering down to everything that's not a property and not an expression. For match it's more reliable to find properties, but we have some naive handling to parse through instances where we look at the length of a property (eg [length, [get, ref]]).

We should see if we can parse these expressions more reliably. It would be worth diving deeper into the style spec to see if there's functionality there we can pull out, but otherwise, we might expand these functions to account for more scenarios.

mulloverit commented 1 year ago

Acceptance criteria