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/src/MGLFeature.mm | |
parent | 4e15a0c8cd7c906908d97da10f75b35a3bc2ed9e (diff) | |
download | qtlocation-mapboxgl-bf8b24fa8d30df374ee36be781b6a572036187b9.tar.gz |
[build] Update to geometry v1.0.0
Diffstat (limited to 'platform/darwin/src/MGLFeature.mm')
-rw-r--r-- | platform/darwin/src/MGLFeature.mm | 45 |
1 files changed, 42 insertions, 3 deletions
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; |