You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Aug 8, 2023. It is now read-only.
Repository navigation
This repository was archived by the owner on Aug 8, 2023. It is now read-only.
I prefer throwing an exception, on the "fail fast and loud" principle. However, a C++ exception needs special handling and translation to SDK-appropriate error reporting at the SDK boundary.
If mbgl throws an exception but you want the SDK to fail gracefully by replacing the source, you can catch the exception and remove and replace the source yourself.
The way sources are currently structured, the sources have no intrinsic order but each source has an intrinsic identifier. On iOS and macOS, that would support our current, set-like API of -addSource: and -removeSource:, and throwing an exception seems reasonable to me.
On the other hand, I’ve always wanted to think of a style as having sources keyed by their identifiers, which would be more consistent with the style specification’s sources property, which is an object rather than an array. For the iOS and macOS SDKs, that would imply a source API consisting of -setSource:forIdentifier: and -removeSourceForName:, where -setSource:forIdentifier: would silently replace a source if given an identifier twice. This would be consistent with our API for style images (-setImage:forName: and -removeImageForName:) and simplify some of the existing code in mbgl::style::Style. Would you be open to that approach, @jfirebaugh?
If -setSource:forIdentifier: allowed overwrites, it would suggest that you could change otherwise immutable properties of a source -- such as its tile URL or type -- by overwriting with a source where all the other properties are unchanged. And then a follow-on assumption would be that you could do that while there were existing layers using that source identifier, and those layers would automatically update. But you can't (#6612), and the changes required to support that would be complex.
Second, what are the use cases for overwriting an existing source, besides wanting to change properties that are intentionally immutable? I can't think of any. In most cases, you add a source, and then never touch it again. Duplicating a source identifier is likely an error.
If -setSource:forIdentifier: allowed overwrites, it would suggest that you could change otherwise immutable properties of a source -- such as its tile URL or type -- by overwriting with a source where all the other properties are unchanged.
Something like this wouldn’t be possible, because url is read-only:
Activity
ivovandongen commentedon Nov 10, 2016
@jfirebaugh Do you prefer throwing an exception or replacing the source?
cc @1ec5
jfirebaugh commentedon Nov 10, 2016
I prefer throwing an exception, on the "fail fast and loud" principle. However, a C++ exception needs special handling and translation to SDK-appropriate error reporting at the SDK boundary.
1ec5 commentedon Nov 10, 2016
If mbgl throws an exception but you want the SDK to fail gracefully by replacing the source, you can catch the exception and remove and replace the source yourself.
The way sources are currently structured, the sources have no intrinsic order but each source has an intrinsic identifier. On iOS and macOS, that would support our current, set-like API of
-addSource:and-removeSource:, and throwing an exception seems reasonable to me.On the other hand, I’ve always wanted to think of a style as having sources keyed by their identifiers, which would be more consistent with the style specification’s
sourcesproperty, which is an object rather than an array. For the iOS and macOS SDKs, that would imply a source API consisting of-setSource:forIdentifier:and-removeSourceForName:, where-setSource:forIdentifier:would silently replace a source if given an identifier twice. This would be consistent with our API for style images (-setImage:forName:and-removeImageForName:) and simplify some of the existing code inmbgl::style::Style. Would you be open to that approach, @jfirebaugh?jfirebaugh commentedon Nov 10, 2016
If
-setSource:forIdentifier:allowed overwrites, it would suggest that you could change otherwise immutable properties of a source -- such as its tile URL or type -- by overwriting with a source where all the other properties are unchanged. And then a follow-on assumption would be that you could do that while there were existing layers using that source identifier, and those layers would automatically update. But you can't (#6612), and the changes required to support that would be complex.Second, what are the use cases for overwriting an existing source, besides wanting to change properties that are intentionally immutable? I can't think of any. In most cases, you add a source, and then never touch it again. Duplicating a source identifier is likely an error.
1ec5 commentedon Nov 10, 2016
Something like this wouldn’t be possible, because
urlis read-only:On the other hand, MGLGeoJSON does have a writeable
featuresproperty, but that means no call tosetSource(_:forIdentifier:)would be necessary.