summaryrefslogtreecommitdiff
path: root/platform/darwin/src/NSDictionary+MGLAdditions.h
diff options
context:
space:
mode:
authorJesse Bounds <jesse@rebounds.net>2016-10-07 15:58:51 -0700
committerJesse Bounds <jesse@rebounds.net>2016-10-14 14:59:28 -0700
commit0a8858f2da4f637fbf8ae7d3f5ffe4640d3e0c80 (patch)
tree07afe5efdc678ad58e405d728b65710d50928dff /platform/darwin/src/NSDictionary+MGLAdditions.h
parentf558f6bc4a12fc621589c0b0f50d42c18e00453c (diff)
downloadqtlocation-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/NSDictionary+MGLAdditions.h')
-rw-r--r--platform/darwin/src/NSDictionary+MGLAdditions.h13
1 files changed, 13 insertions, 0 deletions
diff --git a/platform/darwin/src/NSDictionary+MGLAdditions.h b/platform/darwin/src/NSDictionary+MGLAdditions.h
new file mode 100644
index 0000000000..556f21992b
--- /dev/null
+++ b/platform/darwin/src/NSDictionary+MGLAdditions.h
@@ -0,0 +1,13 @@
+#import <Foundation/Foundation.h>
+
+#import <mbgl/util/feature.hpp>
+
+NS_ASSUME_NONNULL_BEGIN
+
+@interface NSDictionary (MGLAdditions)
+
+- (mbgl::PropertyMap)mgl_propertyMap;
+
+@end
+
+NS_ASSUME_NONNULL_END