diff options
author | Bruno de Oliveira Abinader <bruno@mapbox.com> | 2018-11-06 16:11:47 +0200 |
---|---|---|
committer | Bruno de Oliveira Abinader <bruno@mapbox.com> | 2018-11-13 17:28:26 +0200 |
commit | bf8b24fa8d30df374ee36be781b6a572036187b9 (patch) | |
tree | bdca15eef94898a879e4f3737eee2dc44efa275f /platform/darwin | |
parent | 4e15a0c8cd7c906908d97da10f75b35a3bc2ed9e (diff) | |
download | qtlocation-mapboxgl-bf8b24fa8d30df374ee36be781b6a572036187b9.tar.gz |
[build] Update to geometry v1.0.0
Diffstat (limited to 'platform/darwin')
-rw-r--r-- | platform/darwin/src/MGLFeature.h | 8 | ||||
-rw-r--r-- | platform/darwin/src/MGLFeature.mm | 45 | ||||
-rw-r--r-- | platform/darwin/test/MGLFeatureTests.mm | 2 |
3 files changed, 51 insertions, 4 deletions
diff --git a/platform/darwin/src/MGLFeature.h b/platform/darwin/src/MGLFeature.h index 62471abb16..430bf58f92 100644 --- a/platform/darwin/src/MGLFeature.h +++ b/platform/darwin/src/MGLFeature.h @@ -172,6 +172,14 @@ NS_ASSUME_NONNULL_BEGIN @end /** + An `MGLEmptyFeature` object associates an empty shape with an optional + identifier and attributes. + */ +MGL_EXPORT +@interface MGLEmptyFeature : MGLShape <MGLFeature> +@end + +/** An `MGLPointFeature` object associates a point shape with an optional identifier and attributes. */ diff --git a/platform/darwin/src/MGLFeature.mm b/platform/darwin/src/MGLFeature.mm index 02f67dca6e..be327a23ab 100644 --- a/platform/darwin/src/MGLFeature.mm +++ b/platform/darwin/src/MGLFeature.mm @@ -16,7 +16,41 @@ #import <mbgl/util/geometry.hpp> #import <mbgl/style/conversion/geojson.hpp> -#import <mapbox/geometry/feature.hpp> +#import <mapbox/feature.hpp> + +@interface MGLEmptyFeature () +@end + +@implementation MGLEmptyFeature + +@synthesize identifier; +@synthesize attributes; + +MGL_DEFINE_FEATURE_INIT_WITH_CODER(); +MGL_DEFINE_FEATURE_ENCODE(); +MGL_DEFINE_FEATURE_IS_EQUAL(); + +- (id)attributeForKey:(NSString *)key { + return self.attributes[key]; +} + +- (NSDictionary *)geoJSONDictionary { + return NSDictionaryFeatureForGeometry([super geoJSONDictionary], self.attributes, self.identifier); +} + +- (mbgl::GeoJSON)geoJSONObject { + return mbglFeature({[self geometryObject]}, identifier, self.attributes); +} + +- (NSString *)description +{ + return [NSString stringWithFormat:@"<%@: %p; identifier = %@, attributes = %@>", + NSStringFromClass([self class]), (void *)self, + self.identifier ? [NSString stringWithFormat:@"\"%@\"", self.identifier] : self.identifier, + self.attributes.count ? self.attributes : @"none"]; +} + +@end @interface MGLPointFeature () @end @@ -269,6 +303,11 @@ MGL_DEFINE_FEATURE_IS_EQUAL(); template <typename T> class GeometryEvaluator { public: + MGLShape <MGLFeature> * operator()(const mbgl::EmptyGeometry &) const { + MGLEmptyFeature *feature = [[MGLEmptyFeature alloc] init]; + return feature; + } + MGLShape <MGLFeature> * operator()(const mbgl::Point<T> &geometry) const { MGLPointFeature *feature = [[MGLPointFeature alloc] init]; feature.coordinate = toLocationCoordinate2D(geometry); @@ -390,8 +429,8 @@ id <MGLFeature> MGLFeatureFromMBGLFeature(const mbgl::Feature &feature) { } GeometryEvaluator<double> evaluator; MGLShape <MGLFeature> *shape = mapbox::geometry::geometry<double>::visit(feature.geometry, evaluator); - if (feature.id) { - shape.identifier = mbgl::FeatureIdentifier::visit(*feature.id, ValueEvaluator()); + if (!feature.id.is<mapbox::feature::null_value_t>()) { + shape.identifier = mbgl::FeatureIdentifier::visit(feature.id, ValueEvaluator()); } shape.attributes = attributes; diff --git a/platform/darwin/test/MGLFeatureTests.mm b/platform/darwin/test/MGLFeatureTests.mm index d135b018f4..cf57d0b4b6 100644 --- a/platform/darwin/test/MGLFeatureTests.mm +++ b/platform/darwin/test/MGLFeatureTests.mm @@ -91,7 +91,7 @@ mbgl::Point<double> point = { -90.066667, 29.95 }; mbgl::Feature pointFeature { point }; pointFeature.id = { UINT64_MAX }; - pointFeature.properties["null"] = mapbox::geometry::null_value; + pointFeature.properties["null"] = mapbox::feature::null_value; pointFeature.properties["bool"] = true; pointFeature.properties["unsigned int"] = UINT64_MAX; pointFeature.properties["int"] = INT64_MIN; |