Skip to content

Add identity function #20

Closed
Closed

Description

@lucaswoj

It is often useful to define an identity property-function. For example, when styling a 3d building, users might have a feature property called height which maps directly to the pixel height of the building. Presently a user might define such a function like:

{
    property: 'height',
    steps: [[0, 0], [1000, 1000]]
}

We could make this use case more ergonomic and safe by adding an identity function type

{
    property: 'height',
    type: 'identity'
}

The identity function may also allow using colors in property functions, which was previously impossible

{
    property: 'color',
    type: 'identity'
}

cc @andreasviglakis @scothis

Activity

  1. lbud commented on Aug 19, 2016

    @lbud

    👍 . This also takes the work out of having to figure out or guess at the max value to include in the highest stop (currently if the stops are [[0, 0], [1000, 1000]] and there are buildings higher than 1000, that highest stop will chop them all off at 1000).

  2. lbud commented on Aug 19, 2016

    @lbud

    I'm hesitant to even make the following suggestion, because it may be a bit of a slippery slope, but we may also consider something like a multiplier property, which would turn

    {
        "property": "height",
        "type": "exponential",
        "steps": [[0, 0], [1000, 3000]]
    }

    into

    {
        "property": "height",
        "type": "identity",
        "multiplier": 3
    }
  3. scothis commented on Aug 19, 2016

    @scothis

    lucaswoj and I have been batting around the idea of derived values, they would address your use case and a lot more @lbud.

    The exact syntax is tbd, but you could do something like:

    {
        "property": ["*", { "$ref": "height" }, 3],
        "type": "identity"
    }

    ... or convert celsius to fahrenheit.

    {
        "property": ["+", ["*", { "$ref": "temperature" }, ["/", 9, 5], 32]],
        "type": "identity"
    }

    As more functions are introduced, the power of the concept grows. To select the the red channel of a color

    {
        "property": ["rgba", ["red", { "$ref": "color" }], 0, 0, 0.5],
        "type": "identity"
    }

    Slippery slope archived.

  4. lbud commented on Aug 19, 2016

    @lbud

    👀

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions