-
Notifications
You must be signed in to change notification settings - Fork 38
Allow arbitrary expressions in functions, filters, and cluster aggregators #47
Comments
Could you go into a little more detail about how these would be represented? Like Fwiw, expressions like this are probably super useful, but I'd be interested in whether the approach we've taken for filters could be applied rather than doing infix like Carto or string like Mapnik - like we would have something like {
"+": ["{{a}}", 2]
} Instead of "{{a}} + 2" |
Can we enumerate some uses cases for this feature? I'm particularly interested in how much it overlaps with #226 (Stop functions based on arbitrary properties). |
hrm. In theory, there are some use cases for this not covered by stop functions based on arbitrary properties. I might not be fully understanding the stop functions, but they seem to mainly be for assigning different values of the same style property for different values of the same field in a data layer. With math operators, you could manipulate values across different properties and different GL layers. A use case that I think would overlap with a use case for #226 is using math operators in conjunction with tokens, e.g. for building heights. The two main non-overlapping use cases I had in mind for this were for creating systems of line widths and font sizes across different GL layers. These could potentially be really useful for creating template styles that are fast to customize. However, these use cases require the ability to use constant values in functions, which you currently can't do in the editor. |
I have a specific use case. I'm generating vector tiles from OSRM that contain speed values on roads, in km/h. It would be nice to show localized values ( I'm ambivalent about the syntax, but I've found this capability in Mapnik hugely useful. Other basic math functions, like |
A use case: Given vector tiles containing polygons which represent sales regions. Each polygon is accompanied with data giving sales totals for a range of months in an attribute list (e.g. Month1:€10000, Month2:€23000 etc). You want to do a visualisation with a double handled time slider, where the user selects the period (e.g. month23-month45) and the polygons are then coloured based on total sales in the month ranges - this lets the user explore which regions are hot over different time ranges. You need to do math across feature attributes to total them up, and they can't be predetermined, as the slider control on the page is not known in advance. As far as I can tell from my (very limited) use, this is not possible using filters. (If this is possible, can you please point me at how - I am trying to find ways around this at the moment) |
@timrobertson100 have you found a solution to this problem? |
@stackTom - I ended up doing server side processing on UI changes as I couldn't find a way in filters. |
See mapbox/DEPRECATED-mapbox-gl#15 for additional syntax proposals. |
Let's continue the conversation from mapbox/mapbox-gl-function#28 here 😄 To summarize so far:
|
@1ec5 Agreed, creating a point & click GUI for this will be a little tricky. I'm not sure that users demand a point and click GUI for this, however. Most computer users are familiar with the notion of editing formulas, in Excel or Numbers for example. |
I have no qualms about an inline, text-based GUI for arithmetic or statistical expressions. But as soon as you introduce the notion of conditionals, you get a mini string language – an outcome that we took #104 on a tangent to avoid. |
Important use cases:
|
This issue was moved to mapbox/mapbox-gl-js#4077 |
Will it be possible to support
+
,-
,*
, and/
?The text was updated successfully, but these errors were encountered: