Skip to content
This repository has been archived by the owner on Aug 8, 2023. It is now read-only.

Add "Linear" MGLInterpolationMode #8457

Closed
ericrwolfe opened this issue Mar 17, 2017 · 5 comments
Closed

Add "Linear" MGLInterpolationMode #8457

ericrwolfe opened this issue Mar 17, 2017 · 5 comments
Labels
feature iOS Mapbox Maps SDK for iOS runtime styling

Comments

@ericrwolfe
Copy link
Contributor

MGLInterpolationMode is rather confusing, particularly since only one of the options actually deals with interpolation:

  • exponential (values interpolated)
  • interval (not interpolated)
  • categorical (not interpolated)
  • identity (not interpolated)

90% of developers are going to be using +[MGLStyleValue valueWithInterpolationMode:cameraStops:options:] and will be looking for linear interpolation as the default. Right now, I naturally reach for interval given the options, so I propose adding another linear option for clarity:

  • linear (values interpolated; alias for exponential)
  • exponential (values interpolated)
  • interval (not interpolated)
  • categorical (not interpolated)
  • identity (not interpolated)

This could be a simple alias for exponential, with the default MGLStyleFunctionOptionInterpolationBase value of 1.

/cc @boundsj @jmkiley @friedbunny

@ericrwolfe ericrwolfe added the iOS Mapbox Maps SDK for iOS label Mar 17, 2017
@boundsj boundsj added this to the ios-v3.6.0 milestone Mar 17, 2017
@boundsj
Copy link
Contributor

boundsj commented May 17, 2017

@ericrwolfe I wanted to check in again here to see how much of a pain point this still is now that the API has existed for awhile and documentation and examples have improved.

I think what is proposed here would lead to an API that allows for something like:

circleStyleLayer.circleColor = MGLStyleValue<MGLColor>(
  interpolationMode: .linear,
  cameraStops: stops
)

as an alias for:

// using an interpolation mode of exponential and passing no options results in linear interpolation
circleStyleLayer.circleColor = MGLStyleValue<MGLColor>(
  interpolationMode: .exponential,
  cameraStops: stops
)

Implementing this API would be trivial. Updating the tests, manual docs, and generated docs would not take that much longer. However, this API would be in addition to the style spec and exist only on one platform. So, I think it is worth checking in again to see if this is really required just on iOS and macOS.

Would it be possible to solve this problem by adding something to the relevant existing docs or add some new documentation?

cc @friedbunny @jmkiley

@ericrwolfe
Copy link
Contributor Author

However, this API would be in addition to the style spec and exist only on one platform. So, I think it is worth checking in again to see if this is really required just on iOS and macOS.

@boundsj I'd be okay with revisiting this in a future API redesign if cross-platform inconsistency is a concern.

I'm not sure I'm aware of any written issues with developers getting tripped up on this (cc @jmkiley), though I'd be interested in user testing some of the more complex APIs with developers at some point.

@1ec5
Copy link
Contributor

1ec5 commented Jun 22, 2017

Taking off the v3.6.0 milestone since this isn’t going to get fixed in time. Additionally, the entire style function API will be redesigned as part of the expressions feature: #8074.

@1ec5 1ec5 removed this from the ios-v3.6.0 milestone Jun 22, 2017
@1ec5
Copy link
Contributor

1ec5 commented Sep 10, 2017

As part of the expressions implementation in mapbox/mapbox-gl-js#4777, the curve operator accepts a linear interpolation type equivalent to exponential with a base of 1. Therefore, the suggestion above will be implemented in the course of implementing #8074.

/cc @anandthakker

@1ec5
Copy link
Contributor

1ec5 commented Mar 27, 2018

Implemented in #8074 for iOS SDK v4.0.0 and macOS SDK v0.7.0.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
feature iOS Mapbox Maps SDK for iOS runtime styling
Projects
None yet
Development

No branches or pull requests

3 participants