diff options
author | John Firebaugh <john.firebaugh@gmail.com> | 2016-05-26 16:35:55 -0700 |
---|---|---|
committer | John Firebaugh <john.firebaugh@gmail.com> | 2016-06-01 17:36:50 -0700 |
commit | 8985b1311b7d00cf761752bd9291566325ae207a (patch) | |
tree | aa42e0a0f5e0dc592d6dcafdf5ff54013ccc7a25 /platform/darwin | |
parent | aa1a54c577a95082824f2a5a6bdf4948506fcaa9 (diff) | |
download | qtlocation-mapboxgl-8985b1311b7d00cf761752bd9291566325ae207a.tar.gz |
[core] Use geometry.hpp types for shape annotations
Diffstat (limited to 'platform/darwin')
-rw-r--r-- | platform/darwin/src/MGLMultiPoint.mm | 16 | ||||
-rw-r--r-- | platform/darwin/src/MGLMultiPoint_Private.h | 7 | ||||
-rw-r--r-- | platform/darwin/src/MGLPolygon.mm | 31 | ||||
-rw-r--r-- | platform/darwin/src/MGLPolyline.mm | 19 |
4 files changed, 32 insertions, 41 deletions
diff --git a/platform/darwin/src/MGLMultiPoint.mm b/platform/darwin/src/MGLMultiPoint.mm index aaf8447274..b75cd68e7b 100644 --- a/platform/darwin/src/MGLMultiPoint.mm +++ b/platform/darwin/src/MGLMultiPoint.mm @@ -103,22 +103,6 @@ mbgl::Color MGLColorObjectFromCGColorRef(CGColorRef cgColor) { return MGLLatLngBoundsFromCoordinateBounds(_bounds).intersects(MGLLatLngBoundsFromCoordinateBounds(overlayBounds)); } -- (mbgl::AnnotationSegments)annotationSegments { - NSUInteger count = self.pointCount; - CLLocationCoordinate2D *coordinates = self.coordinates; - - mbgl::AnnotationSegment segment; - segment.reserve(count); - for (NSUInteger i = 0; i < count; i++) { - segment.push_back(MGLLatLngFromLocationCoordinate2D(coordinates[i])); - } - return { segment }; -} - -- (mbgl::ShapeAnnotation::Properties)shapeAnnotationPropertiesObjectWithDelegate:(__unused id <MGLMultiPointDelegate>)delegate { - return mbgl::ShapeAnnotation::Properties(); -} - - (NSString *)description { return [NSString stringWithFormat:@"<%@: %p; count = %lu; bounds = %@>", diff --git a/platform/darwin/src/MGLMultiPoint_Private.h b/platform/darwin/src/MGLMultiPoint_Private.h index 2c1e0b7222..f7a7bd4ffd 100644 --- a/platform/darwin/src/MGLMultiPoint_Private.h +++ b/platform/darwin/src/MGLMultiPoint_Private.h @@ -21,11 +21,8 @@ NS_ASSUME_NONNULL_BEGIN - (instancetype)initWithCoordinates:(CLLocationCoordinate2D *)coords count:(NSUInteger)count; - (BOOL)intersectsOverlayBounds:(MGLCoordinateBounds)overlayBounds; -/** Returns the shape’s annotation segments. */ -- (mbgl::AnnotationSegments)annotationSegments; - -/** Constructs a shape annotation properties object by asking the delegate for style values. */ -- (mbgl::ShapeAnnotation::Properties)shapeAnnotationPropertiesObjectWithDelegate:(id <MGLMultiPointDelegate>)delegate; +/** Constructs a shape annotation object, asking the delegate for style values. */ +- (mbgl::ShapeAnnotation)shapeAnnotationObjectWithDelegate:(id <MGLMultiPointDelegate>)delegate; @end diff --git a/platform/darwin/src/MGLPolygon.mm b/platform/darwin/src/MGLPolygon.mm index 5a24cb0791..47be070246 100644 --- a/platform/darwin/src/MGLPolygon.mm +++ b/platform/darwin/src/MGLPolygon.mm @@ -24,26 +24,31 @@ return self; } -- (mbgl::AnnotationSegments)annotationSegments { - auto segments = super.annotationSegments; - for (MGLPolygon *polygon in self.interiorPolygons) { - auto interiorSegments = polygon.annotationSegments; - segments.push_back(interiorSegments.front()); +- (mbgl::LinearRing<double>)ring { + NSUInteger count = self.pointCount; + CLLocationCoordinate2D *coordinates = self.coordinates; + + mbgl::LinearRing<double> result; + result.reserve(self.pointCount); + for (NSUInteger i = 0; i < count; i++) { + result.push_back(mbgl::Point<double>(coordinates[i].longitude, coordinates[i].latitude)); } - return segments; + return result; } -- (mbgl::ShapeAnnotation::Properties)shapeAnnotationPropertiesObjectWithDelegate:(id <MGLMultiPointDelegate>)delegate { - mbgl::ShapeAnnotation::Properties shapeProperties = [super shapeAnnotationPropertiesObjectWithDelegate:delegate]; - +- (mbgl::ShapeAnnotation)shapeAnnotationObjectWithDelegate:(id <MGLMultiPointDelegate>)delegate { mbgl::FillAnnotationProperties fillProperties; fillProperties.opacity = [delegate alphaForShapeAnnotation:self]; fillProperties.outlineColor = [delegate strokeColorForShapeAnnotation:self]; fillProperties.color = [delegate fillColorForPolygonAnnotation:self]; - - shapeProperties.set<mbgl::FillAnnotationProperties>(fillProperties); - - return shapeProperties; + + mbgl::Polygon<double> geometry; + geometry.push_back(self.ring); + for (MGLPolygon *polygon in self.interiorPolygons) { + geometry.push_back(polygon.ring); + } + + return mbgl::ShapeAnnotation(geometry, fillProperties); } @end diff --git a/platform/darwin/src/MGLPolyline.mm b/platform/darwin/src/MGLPolyline.mm index 810b359bb0..ebba5c862e 100644 --- a/platform/darwin/src/MGLPolyline.mm +++ b/platform/darwin/src/MGLPolyline.mm @@ -13,17 +13,22 @@ return [[self alloc] initWithCoordinates:coords count:count]; } -- (mbgl::ShapeAnnotation::Properties)shapeAnnotationPropertiesObjectWithDelegate:(id <MGLMultiPointDelegate>)delegate { - mbgl::ShapeAnnotation::Properties shapeProperties = [super shapeAnnotationPropertiesObjectWithDelegate:delegate]; - +- (mbgl::ShapeAnnotation)shapeAnnotationObjectWithDelegate:(id <MGLMultiPointDelegate>)delegate { mbgl::LineAnnotationProperties lineProperties; lineProperties.opacity = [delegate alphaForShapeAnnotation:self]; lineProperties.color = [delegate strokeColorForShapeAnnotation:self]; lineProperties.width = [delegate lineWidthForPolylineAnnotation:self]; - - shapeProperties.set<mbgl::LineAnnotationProperties>(lineProperties); - - return shapeProperties; + + NSUInteger count = self.pointCount; + CLLocationCoordinate2D *coordinates = self.coordinates; + + mbgl::LineString<double> geometry; + geometry.reserve(self.pointCount); + for (NSUInteger i = 0; i < count; i++) { + geometry.push_back(mbgl::Point<double>(coordinates[i].longitude, coordinates[i].latitude)); + } + + return mbgl::ShapeAnnotation(geometry, lineProperties); } @end |