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

Mutable geojson source #6777

Closed
wants to merge 4 commits into from

Conversation

boundsj
Copy link
Contributor

@boundsj boundsj commented Oct 20, 2016

Fixes #6159

This adds support for updating a MGLGeoJSONSource's geoJSONData, URL, and features properties and having that update trigger a refresh of the map with the new source data.

boundsj and others added 3 commits October 20, 2016 14:57
URL example does not work as of this commit since a change in
core still needs to happen to trigger an update.
@boundsj boundsj added iOS Mapbox Maps SDK for iOS macOS Mapbox Maps SDK for macOS ⚠️ DO NOT MERGE Work in progress, proof of concept, or on hold runtime styling labels Oct 20, 2016
@boundsj boundsj added this to the ios-v3.4.0 milestone Oct 20, 2016
@boundsj boundsj self-assigned this Oct 20, 2016
@mention-bot
Copy link

@boundsj, thanks for your PR! By analyzing the history of the files in this pull request, we identified @1ec5, @incanus and @friedbunny to be potential reviewers.

@boundsj
Copy link
Contributor Author

boundsj commented Oct 20, 2016

This is a WIP to make the data properties of MGLGeoJSONSource mutable.

Note: I cherry picked #6770 to make this work for URLs. However I see that PR has an open question regarding the resetting of a request. I will monitor to see if additional changes should get pulled in here.

cc @ivovandongen @jfirebaugh @1ec5 @incanus

NSString *string = [[NSString alloc] initWithData:_geoJSONData encoding:NSUTF8StringEncoding];
const auto geojson = mapbox::geojson::parse(string.UTF8String).get<mapbox::geojson::feature_collection>();

const auto geoJSONSource = reinterpret_cast<mbgl::style::GeoJSONSource *>(self.source);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These reinterpret_casts would be unnecessary if this class instead has a class extension that redefines the source property to be of type mbgl::style::GeoJSONSource *. We follow this covariant pattern in a few places, notably the style layer classes.


NSURL *url = self.URL.mgl_URLByStandardizingScheme;
const auto geoJSONSource = reinterpret_cast<mbgl::style::GeoJSONSource *>(self.source);
geoJSONSource->setURL(url.absoluteString.UTF8String);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Either update features or nil it out.

@boundsj
Copy link
Contributor Author

boundsj commented Oct 21, 2016

For consistency, I also cherry picked @ivovandongen's 19a707d

@ivovandongen
Copy link
Contributor

@boundsj One final fixup (after review): #6798

@boundsj
Copy link
Contributor Author

boundsj commented Oct 24, 2016

This will continue in #6793. I will address the change requests there.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
⚠️ DO NOT MERGE Work in progress, proof of concept, or on hold iOS Mapbox Maps SDK for iOS macOS Mapbox Maps SDK for macOS runtime styling
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants