diff options
Diffstat (limited to 'platform/darwin/src/MGLFeature.mm')
-rw-r--r-- | platform/darwin/src/MGLFeature.mm | 41 |
1 files changed, 40 insertions, 1 deletions
diff --git a/platform/darwin/src/MGLFeature.mm b/platform/darwin/src/MGLFeature.mm index 02f67dca6e..fde2d58ada 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); |