Skip to content

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

@AbelVM

Description

@AbelVM

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"]]]]

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions