Repository navigation
Add "default" property for functions - #4175
Conversation
19b4d67 to
a90eaeb
Compare
| definition, and an object defining a style spec property. It handles color parsing and validation of feature values | ||
| internally. | ||
| * Functions now support a "default" property. | ||
| * `parseColor` was promoted from gl-js. |
| const featureDependent = zoomAndFeatureDependent || parameters.property !== undefined; | ||
| const zoomDependent = zoomAndFeatureDependent || !featureDependent; | ||
| const type = parameters.type || defaultType || 'exponential'; | ||
| const type = parameters.type || (propertySpec.function === 'interpolated' ? 'exponential' : 'interval'); |
There was a problem hiding this comment.
Have you thought about renaming the propertySpec.function "enum" values now that this is part of our public API?
There was a problem hiding this comment.
Filed #4194 for what I think we should do there.
| stops: featureFunctionStops, | ||
| base: parameters.base | ||
| }, zoom)(zoom, feature)); | ||
| }, propertySpec, zoom)(zoom, feature)); |
There was a problem hiding this comment.
Why do you need to pass propertySpec to evaluateExponentialFunction both as an argument and embedded within featureFunctionStops?
There was a problem hiding this comment.
Ah. I misread the code. This is 👍
There was a problem hiding this comment.
Where is it embedded within featureFunctionStops?
There was a problem hiding this comment.
Oop, didn't see your followup comment. 👍
| // Special case for fill-outline-color, which has no spec default. | ||
| if (evaluatedLower === undefined || evaluatedUpper === undefined) { | ||
| return undefined; | ||
| } |
| "brfs": "^1.4.0", | ||
| "bubleify": "^0.5.1", | ||
| "csscolorparser": "^1.0.2", | ||
| "csscolorparser": "~1.0.2", |
There was a problem hiding this comment.
We don't currently install the dependencies from js/style-spec/package.json so this may still be needed
There was a problem hiding this comment.
Ah. Yes. The postinstall hook. 🚢
* No more than one level of nesting * Remove nonsensical or redundant tests * Use correct terminology * Test identity functions properly * Complete test coverage
a90eaeb to
90a5d3d
Compare
If the text-field property is data-driven, the value of layout['text-field'] is not defined.
It is used in the following circumstances: * In categorical functions, when the feature value does not match any of the stop domain values. * In property and zoom-and-property functions, when a feature does not contain a value for the specified property. * In identity functions, when the feature value is not valid for the style property (for example, if the function is being used for a `circle-color` property but the feature property value is not a string or not a valid color). * In interval or exponential property and zoom-and-property functions, when the feature value is not numeric. If no default is provided, the style property's default is used in these circumstances. Implementing this required breaking changes to the function API in mapbox-gl-style-spec. The export is now a function which accepts the function definition and the spec JSON for a style property. It handles color parsing and validation of feature values internally.
90a5d3d to
5e61f88
Compare
| const iconImage = layout['icon-image']; | ||
|
|
||
| const hasText = layout['text-field'] && textFont; | ||
| const hasText = textFont && (!layer.isLayoutValueFeatureConstant('text-field') || layout['text-field']); |
There was a problem hiding this comment.
If the text-field property is data-driven, the value of layout['text-field'] is not defined.
@jfirebaugh ah, whoops - I made the bad assumption that layout contained the style JSON.
It is used in the following circumstances:
circle-colorproperty but the feature property value is not a string or not a valid color).If no default is provided, the style property's default is used in these circumstances.
Implementing this required breaking changes to the function API in mapbox-gl-style-spec. The export is now a function which accepts the function definition and the spec JSON for a style property. It handles color parsing and validation of feature values internally.
Fixes #4124
Fixes #4144
Fixes #4146
Fixes #4150
Fixes #4018
Launch Checklist