Skip to content
This repository has been archived by the owner on Apr 10, 2018. It is now read-only.

consolidate functions #96

Closed
ansis opened this issue Jul 10, 2014 · 4 comments
Closed

consolidate functions #96

ansis opened this issue Jul 10, 2014 · 4 comments

Comments

@ansis
Copy link
Contributor

ansis commented Jul 10, 2014

We have three different ways of writing functions. Some of them are pretty complex. I think we can consolidate them into one type:

"line-width": {
    "stops": [[2, 2], [10, 5], [15, 10], [18, 12]],
    "base": 1.75 // optional
}

This is exactly like the current stops function, except the interpolation is exponential. It interpolates based on an curve that goes through the two points and has the given exponential base. Using a small base like 1.01 makes the interpolation linear.

We should do this for v4.

The math:

var a = stops[i];
var b = stops[i + 1];
var zoomDiff = b[0] - a[0];
var valueDiff = b[1] - a[1];
var slope = valueDiff / Math.pow(base, zoomDiff);
return Math.pow(base, currentZoom - a[0]) * slope + a[1];

@nickidlugash @edenh @kkaefer @mourner @yhahn @lbud

@jfirebaugh
Copy link
Contributor

@lbud Want to grab this one next?

@mourner
Copy link
Member

mourner commented Jul 11, 2014

Should we keep the min function? Is it useful?

@lbud
Copy link
Contributor

lbud commented Jul 11, 2014

I'm going to leave this to @ansis to export it from his brain > javascript to see it in action, and then I'll grab migration things once it works

@jfirebaugh
Copy link
Contributor

Done in #99.

kkaefer added a commit to mapbox/mapbox-gl-js that referenced this issue Jul 17, 2014
this avoids a division by 0 and removes the need for awkward 1.01 hacks
refs #543 and mapbox/mapbox-gl-style-spec#96
kkaefer added a commit to mapbox/mapbox-gl-js that referenced this issue Jul 17, 2014
kkaefer added a commit to mapbox/mapbox-gl-native that referenced this issue Jul 17, 2014
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants