-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Check for duplicate source IDs #7011
Comments
@jfirebaugh Do you prefer throwing an exception or replacing the source? cc @1ec5 |
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 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 |
If 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. |
Something like this wouldn’t be possible, because let source = style.sourceWithIdentifier("foo") as? MGLVectorSource
source.url = URL(string: "mapbox://something.else")
style.setSource(source, forIdentifier: "foo") On the other hand, MGLGeoJSON does have a writeable |
ATM there is no check on source ID when adding it to the style. This leads to issues like #6612 (comment)
The text was updated successfully, but these errors were encountered: