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 identity function #20

Closed
lucaswoj opened this issue Aug 18, 2016 · 4 comments · Fixed by #25
Closed

Add identity function #20

lucaswoj opened this issue Aug 18, 2016 · 4 comments · Fixed by #25

Comments

@lucaswoj
Copy link
Contributor

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

@lbud
Copy link

lbud commented Aug 19, 2016

👍 . 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).

@lbud
Copy link

lbud commented Aug 19, 2016

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
}

@scothis
Copy link

scothis commented Aug 19, 2016

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.

@lbud
Copy link

lbud commented Aug 19, 2016

👀

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

Successfully merging a pull request may close this issue.

3 participants