-
Notifications
You must be signed in to change notification settings - Fork 38
Specify a default for property functions when property value is undefined #480
Comments
I like the idea. |
|
Could we unify the syntax with the proposals for token defaults in #104? |
@jfirebaugh do you mean something like
? (It feels weird to use a number in a string there…) |
No, I mean something akin to the syntaxes proposed in #362 (comment) or #104 (comment), like I think at this point we need to have a vision that unifies #480, #104, and #47 or the function syntax will wind up becoming a mess of ad hoc additions. |
Interestingly, I realized that because of the way
I don't feel like this is really the intended behavior or a clean solution, buuuut… 💭 |
Actually, my above comment is not true — it was working in my debugging but now I'm creating demos and realizing validation throws out non-number stops in number functions, and non-ascending-order stops (so |
I think there are two distinct cases being discussed in this thread: 1. Specify a function input value when the property is undefinedThis is being discussed in #104. I will weigh in on that ticket. 2. Specify a function output value when the property is undefined"extrusion-height": {
stops: [[0, 0], [1000, 3000]],
type: "exponential",
property: "levels",
default: 20
}
In some cases, we can take care of case 2 with a carefully constructed value and the case 1 feature. In other cases, doing so is impossible or mathematically tricky. For example:
We should have a primitive for this case. @lbud's syntax proposal is 👍 |
@lucaswoj Good clarification -- let's focus this issue on adding the ability to provide an output value for inputs which are not otherwise in the domain of the function. An input value of "undefined", when the property is not present on a given feature, is a common special case. But a categorical function which doesn't wish to specify a stop for every possible value is another use case. Then to go back to @mourner's first comment:
If we are talking about |
A clarification question: By "undefined" are we referring to both |
We're not referring to either a literal
|
This issue was moved to mapbox/mapbox-gl-js#4124 |
In the mapbox-gl-function
feature-defaults
branch I'm addingreference
as an argument so that when an input to a property function is undefined, it defaults to the spec default. However, it seems to me there should also be a way to specify a user-defined default for this behavior. Does it seem reasonable to add an optional key in a property function fordefault
, like(so any extrusion without a
levels
property will have a height of 20, rather than the spec-defined default of 10)?cc @lucaswoj @mollymerp @mourner
The text was updated successfully, but these errors were encountered: