greensopinion/dart-vector-tile-renderer

Support interpolate, step and case expressions for color and number values

Closed this issue · 2 comments

Values like these:

'fill-opacity': [
  'interpolate',
  ['linear'],
  ['zoom'],
  0,
  1,
  15.5,
  1,
  16,
  0,
  22,
  0
],

currently just return null because they are nether a map nor a number:

DoubleZoomFunction _toDouble(doubleSpec) {
if (doubleSpec is num) {
final value = doubleSpec.toDouble();
return (zoom) => value;
}
if (doubleSpec is Map) {
final model = DoubleFunctionModelFactory().create(doubleSpec);
if (model != null) {
return (zoom) => DoubleThemeFunction().exponential(model, zoom);
}
}
return (_) => null;
}

Color values are handled in the same way.

I am willing to work on this (and already started fiddling around a bit), if you don't mind!

Disclaimer: I am doing this for one of our client projects and will likely only cover the things we "need" (like linear interpolation, while not implementing exponential) but also try my best to create groundwork that makes adding more functionality easier.

Fantastic - feel free to contribute via a pull request!

I am doing this for one of our client projects and will likely only cover the things we "need"

Of course, I wouldn't expect to contribute anything that I didn't need either. :D

Closing this one off since it's stale. Feel free to open a PR if/when it makes sense.