Use static_cast<float> to convert from CGfloat when creating PropertyValue<float> and avoid breaking backwards-compatibility.
71 lines
2.1 KiB
Plaintext
71 lines
2.1 KiB
Plaintext
#import "MGLPolyline.h"
|
|
|
|
#import "MGLMultiPoint_Private.h"
|
|
#import "MGLGeometry_Private.h"
|
|
|
|
@implementation MGLPolyline
|
|
|
|
@dynamic overlayBounds;
|
|
|
|
+ (instancetype)polylineWithCoordinates:(CLLocationCoordinate2D *)coords
|
|
count:(NSUInteger)count
|
|
{
|
|
return [[self alloc] initWithCoordinates:coords count:count];
|
|
}
|
|
|
|
- (mbgl::Annotation)annotationObjectWithDelegate:(id <MGLMultiPointDelegate>)delegate {
|
|
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));
|
|
}
|
|
|
|
mbgl::LineAnnotation annotation { geometry };
|
|
annotation.opacity = { static_cast<float>([delegate alphaForShapeAnnotation:self]) };
|
|
annotation.color = { [delegate strokeColorForShapeAnnotation:self] };
|
|
annotation.width = { static_cast<float>([delegate lineWidthForPolylineAnnotation:self]) };
|
|
|
|
return annotation;
|
|
}
|
|
|
|
@end
|
|
|
|
@interface MGLMultiPolyline ()
|
|
|
|
@property (nonatomic, copy, readwrite) NS_ARRAY_OF(MGLPolyline *) *polylines;
|
|
|
|
@end
|
|
|
|
@implementation MGLMultiPolyline {
|
|
MGLCoordinateBounds _overlayBounds;
|
|
}
|
|
|
|
@synthesize overlayBounds = _overlayBounds;
|
|
|
|
+ (instancetype)multiPolylineWithPolylines:(NS_ARRAY_OF(MGLPolyline *) *)polylines {
|
|
return [[self alloc] initWithPolylines:polylines];
|
|
}
|
|
|
|
- (instancetype)initWithPolylines:(NS_ARRAY_OF(MGLPolyline *) *)polylines {
|
|
if (self = [super init]) {
|
|
_polylines = polylines;
|
|
|
|
mbgl::LatLngBounds bounds = mbgl::LatLngBounds::empty();
|
|
|
|
for (MGLPolyline *polyline in _polylines) {
|
|
bounds.extend(MGLLatLngBoundsFromCoordinateBounds(polyline.overlayBounds));
|
|
}
|
|
_overlayBounds = MGLCoordinateBoundsFromLatLngBounds(bounds);
|
|
}
|
|
return self;
|
|
}
|
|
|
|
- (BOOL)intersectsOverlayBounds:(MGLCoordinateBounds)overlayBounds {
|
|
return MGLLatLngBoundsFromCoordinateBounds(_overlayBounds).intersects(MGLLatLngBoundsFromCoordinateBounds(overlayBounds));
|
|
}
|
|
|
|
@end
|