diff options
author | Jason Wray <jason@mapbox.com> | 2016-08-23 11:46:53 -0400 |
---|---|---|
committer | Jason Wray <jason@mapbox.com> | 2016-08-24 21:56:52 -0400 |
commit | 9cdbac043d0eac4beaa666e15d34ab49ffb3e183 (patch) | |
tree | 3dc541eae8bfb8c791a31dd8be817e0aa89895e6 /platform | |
parent | cb59589954271d6dbaecba1fe4230c22f5bbab21 (diff) | |
download | qtlocation-mapboxgl-9cdbac043d0eac4beaa666e15d34ab49ffb3e183.tar.gz |
[ios] Clean-up user location annotation heading calculations
- Use MGLRadiansFromDegrees().
- Make indentation more readable.
Diffstat (limited to 'platform')
-rw-r--r-- | platform/ios/src/MGLFaux3DUserLocationAnnotationView.m | 18 |
1 files changed, 11 insertions, 7 deletions
diff --git a/platform/ios/src/MGLFaux3DUserLocationAnnotationView.m b/platform/ios/src/MGLFaux3DUserLocationAnnotationView.m index 2cccc18806..9a3b17a6cd 100644 --- a/platform/ios/src/MGLFaux3DUserLocationAnnotationView.m +++ b/platform/ios/src/MGLFaux3DUserLocationAnnotationView.m @@ -459,10 +459,11 @@ const CGFloat MGLUserLocationAnnotationArrowSize = MGLUserLocationAnnotationPuck - (CGFloat)calculateAccuracyRingSize { - CGFloat latRadians = self.userLocation.coordinate.latitude * M_PI / 180.0f; - CGFloat pixelRadius = self.userLocation.location.horizontalAccuracy / cos(latRadians) / [self.mapView metersPerPointAtLatitude:self.userLocation.coordinate.latitude]; + CGFloat latitudeRadians = MGLRadiansFromDegrees(self.userLocation.coordinate.latitude); + CGFloat metersPerPoint = [self.mapView metersPerPointAtLatitude:self.userLocation.coordinate.latitude]; + CGFloat pixelRadius = self.userLocation.location.horizontalAccuracy / cos(latitudeRadians) / metersPerPoint; - return pixelRadius * 2; + return pixelRadius * 2.0; } - (UIImage *)headingIndicatorTintedGradientImage @@ -479,8 +480,11 @@ const CGFloat MGLUserLocationAnnotationArrowSize = MGLUserLocationAnnotationPuck // gradient from the tint color to no-alpha tint color CGFloat gradientLocations[] = {0.0, 1.0}; CGGradientRef gradient = CGGradientCreateWithColors( - colorSpace, (__bridge CFArrayRef)@[(id)[self.mapView.tintColor CGColor], - (id)[[self.mapView.tintColor colorWithAlphaComponent:0] CGColor]], gradientLocations); + colorSpace, + (__bridge CFArrayRef)@[ + (id)[self.mapView.tintColor CGColor], + (id)[[self.mapView.tintColor colorWithAlphaComponent:0] CGColor]], + gradientLocations); // draw the gradient from the center point to the edge (full halo radius) CGPoint centerPoint = CGPointMake(haloRadius, haloRadius); @@ -513,8 +517,8 @@ const CGFloat MGLUserLocationAnnotationArrowSize = MGLUserLocationAnnotationPuck // clip the oval to ± incoming accuracy degrees (converted to radians), from the top [ovalPath addArcWithCenter:CGPointMake(CGRectGetMidX(ovalRect), CGRectGetMidY(ovalRect)) radius:CGRectGetWidth(ovalRect) / 2.0 - startAngle:(-180 + clippingDegrees) * M_PI / 180 - endAngle:-clippingDegrees * M_PI / 180 + startAngle:MGLRadiansFromDegrees(-180 + clippingDegrees) + endAngle:MGLRadiansFromDegrees(-clippingDegrees) clockwise:YES]; [ovalPath addLineToPoint:CGPointMake(CGRectGetMidX(ovalRect), CGRectGetMidY(ovalRect))]; |