diff options
Diffstat (limited to 'platform/darwin/src/MGLPolygon.mm')
-rw-r--r-- | platform/darwin/src/MGLPolygon.mm | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/platform/darwin/src/MGLPolygon.mm b/platform/darwin/src/MGLPolygon.mm index 393bd31d0d..565de017cc 100644 --- a/platform/darwin/src/MGLPolygon.mm +++ b/platform/darwin/src/MGLPolygon.mm @@ -28,6 +28,32 @@ return self; } +- (instancetype)initWithCoder:(NSCoder *)decoder { + self = [super initWithCoder:decoder]; + if (self) { + _interiorPolygons = [decoder decodeObjectOfClass:[NSArray class] forKey:@"interiorPolygons"]; + } + return self; +} + +- (void)encodeWithCoder:(NSCoder *)coder { + [super encodeWithCoder:coder]; + [coder encodeObject:self.interiorPolygons forKey:@"interiorPolygons"]; +} + +- (BOOL)isEqual:(id)other { + if (self == other) return YES; + if (![other isKindOfClass:[MGLPolygon class]]) return NO; + + MGLPolygon *otherPolygon = (MGLPolygon *)other; + return ([super isEqual:otherPolygon] && + [[self geoJSONDictionary] isEqualToDictionary:[otherPolygon geoJSONDictionary]]); +} + +- (NSUInteger)hash { + return [super hash] + [[self geoJSONDictionary] hash]; +} + - (mbgl::LinearRing<double>)ring { NSUInteger count = self.pointCount; CLLocationCoordinate2D *coordinates = self.coordinates; @@ -100,6 +126,35 @@ return self; } +- (instancetype)initWithCoder:(NSCoder *)decoder { + if (self = [super initWithCoder:decoder]) { + _polygons = [decoder decodeObjectOfClass:[NSArray class] forKey:@"polygons"]; + } + return self; +} + +- (void)encodeWithCoder:(NSCoder *)coder { + [super encodeWithCoder:coder]; + [coder encodeObject:_polygons forKey:@"polygons"]; +} + +- (BOOL)isEqual:(id)other { + if (self == other) return YES; + if (![other isKindOfClass:[MGLMultiPolygon class]]) return NO; + + MGLMultiPolygon *otherMultiPolygon = other; + return [super isEqual:other] + && [self.polygons isEqualToArray:otherMultiPolygon.polygons]; +} + +- (NSUInteger)hash { + NSUInteger hash = [super hash]; + for (MGLPolygon *polygon in self.polygons) { + hash += [polygon hash]; + } + return hash; +} + - (BOOL)intersectsOverlayBounds:(MGLCoordinateBounds)overlayBounds { return MGLCoordinateBoundsIntersectsCoordinateBounds(_overlayBounds, overlayBounds); } |