It seems that neither Math expressions nor the type conversion expression number are being executed within stops functions.
I couldn't find an explanation for that in the Style Spec so I assume it must be a bug.
Stylesheet (within Symbol layer and Layout property and using data that always comes with a "rank" value):
"text-size": { "stops": [
[["-", ["number", ["get", "rank"]], 1], 0],
[["number", ["get", "rank"]], 10]
]},
The purpose of this code is to use the rank values to display map features later than they appear in the data, based on their rank value.
Note: I also tried "{rank}" instead of ["get", "rank"] and I also tried without the number conversion.
The "rank" value is supposed to be converted to a number. So given the example of rank=16, the text-size should work like this:
"text-size": { "stops": [
[["-",16, 1], 0],
[16, 10]
]},
Also the above code doesn't work.
Which in return using the Math expression should be interpreted as:
"text-size": { "stops": [
[15, 0],
[16, 10]
]},
The above code obviously works.
Instead I get the error message: stop domain value must be a number, string, or boolean
A property value is _either_ a function or an expression -- you can't mix the two.
Wouldn't it be really useful to make this possible, as an enhancement?
And: Couldn't find this information in the spec. Only the sentence "The value for any layout property, paint property, or filter may be specified as an expression. " - which together with your sentence is clear but without it wasn't.
@muesliq expressions are intended as a full replacement for stop functions. See "curve" for an analogue. (Note that "curve" will be replaced with "interpolate" and "step" in the next version, per #5528.)
Thanks for clarification @anandthakker! Is it possible to use expressions within expressions?
In general, it is. However, note that the stop levels for curve expressions
(and, similarly, the keys for "match" expressions) are required to be
literal values rather than sub-expressions. This is a restriction we've
imposed to enable important performance optimizations.
On Thu, Nov 2, 2017 at 9:23 AM Helge Fahrnberger notifications@github.com
wrote:
Thanks for clarification @anandthakker https://github.com/anandthakker!
Is it possible to use expressions within expressions?—
You are receiving this because you were mentioned.Reply to this email directly, view it on GitHub
https://github.com/mapbox/mapbox-gl-js/issues/5566#issuecomment-341419158,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AEvmR2WblxWEsZIOPfZInm_bkzrH4DVrks5sycJSgaJpZM4QMok6
.