diff options
author | Jesse Bounds <jesse@rebounds.net> | 2016-10-07 15:58:51 -0700 |
---|---|---|
committer | Jesse Bounds <jesse@rebounds.net> | 2016-10-14 14:59:28 -0700 |
commit | 0a8858f2da4f637fbf8ae7d3f5ffe4640d3e0c80 (patch) | |
tree | 07afe5efdc678ad58e405d728b65710d50928dff /platform/darwin/src/MGLFeature.h | |
parent | f558f6bc4a12fc621589c0b0f50d42c18e00453c (diff) | |
download | qtlocation-mapboxgl-0a8858f2da4f637fbf8ae7d3f5ffe4640d3e0c80.tar.gz |
[ios, macos] Teach features and shapes about GeoJSON and mbgl types
MGLShape subclasses can now return NSDictionaries that represent the shapes' GeoJSON geometries. MGLFeature classes can now return NSDictionaries that represent the features as GeoJSON features. This makes it trivial to serialize iOS and macOS shapes and features into GeoJSON.
MGLFeature instances can also return a representation of themselves as an mbgl::Feature. This capability is used in a refactoring of the implementations of MGLGeoJSONSource to more efficiently transform MGLFeatures into mbgl::Features so they can be fed directly into mbgl::GeoJSONSource without having to round trip through NSJSONSerialization. The MGLFeature identifier is converted into the mbgl::identifier type based on the type of the identifier. The MGLFeature attributes are recursively converted into an mbgl::PropertyMap and each value is converted into one of the types that the PropertyMap's Value variant supports.
Diffstat (limited to 'platform/darwin/src/MGLFeature.h')
-rw-r--r-- | platform/darwin/src/MGLFeature.h | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/platform/darwin/src/MGLFeature.h b/platform/darwin/src/MGLFeature.h index d187e9cf06..239a338f67 100644 --- a/platform/darwin/src/MGLFeature.h +++ b/platform/darwin/src/MGLFeature.h @@ -83,10 +83,6 @@ NS_ASSUME_NONNULL_BEGIN */ @property (nonatomic, copy, readonly) NS_DICTIONARY_OF(NSString *, id) *attributes; - - -- (NS_DICTIONARY_OF(NSString *, id) *)featureDictionary; - /** Returns the feature attribute for the given attribute name. @@ -95,6 +91,17 @@ NS_ASSUME_NONNULL_BEGIN */ - (nullable id)attributeForKey:(NSString *)key; +/** + Returns a dictionary that can be serialized as a GeoJSON Feature representation + of an instance of an `MGLFeature` subclass. + + The dictionary includes a `geometry` key corresponding to the receiver’s + underlying geometry data, a `properties` key corresponding to the receiver’s + `attributes` property, and an `id` key corresponding to the receiver’s + `identifier` property. + */ +- (NS_DICTIONARY_OF(NSString *, id) *)geoJSONDictionary; + @end /** |