Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add "to-array" & "to-object" to expresions #6546

Open
AbelVM opened this issue Apr 20, 2018 · 4 comments
Open

Add "to-array" & "to-object" to expresions #6546

AbelVM opened this issue Apr 20, 2018 · 4 comments

Comments

@AbelVM
Copy link

AbelVM commented Apr 20, 2018

Motivation

As MVT spec does not allow passing arrays or objects as features property, the shortcut is to pass them serialized as string, and parse it later if needed.

The problem here is when trying to use one specific element of that specific property for filtering or styling, it looks back to the original info in the tile and it will find a string. So, no way.

Proposal

Adding new casts to expresions

  • to-object (~ JSON.parse(value)):
    • use: ["to-object", my_object_like_value <string>]
    • example:
fill-opacity:["get", "myopacity", ["to-object", ["get", "myproperty"]]]
  • to-array (~ value.split(separator)):
    • use: ["to-array", separator <string>, my_array_like_value <string>]
    • example:
fill-opacity: ["number", ["at", 23, ["to-array", ",", ["get", "myproperty"]]]]
@asheemmamoowala asheemmamoowala changed the title Add "to-string" & "to-object" to expresions Add "to-array" & "to-object" to expresions Apr 24, 2018
@stdmn
Copy link

stdmn commented Dec 4, 2019

Any movement on this? With commit #8876, it really feels as though there should be some mechanism for converting strings to arrays as there is currently no way to do this in the Mapbox Vector Tile spec. Nor is there a way in Tippecanoe to do this.

It could be possible to do this with strings, but this introduces some tricky conditions (specfically for the first or last item in the array).

@jkempe
Copy link

jkempe commented May 19, 2020

Anything new on this?
A to-array would be very useful with the new slice available in 1.10.

The use case I am thinking of is storing a timeserie of data (array of numbers) as attribute in tiles from tippecanoe and then be able get the number at a specific index in that array.
If I am not wrong tippecanoe can only store the array as a string so to be able to use slice-expression on the attribute we need an array again.

@ansis
Copy link
Contributor

ansis commented Mar 10, 2022

proposed implementation: #11003

Unfortunately we can't move it forward right now.

@Jesperpaulsen
Copy link

Any updates on this? This limitation in combination with the MVTs spec to filter out lists, makes it difficult to dynamically filter features on the client without having to filter them from the backend which requires a full reload of the tiles.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants