[ios] Meters per point at latitude

Renamed -metersPerPixelAtLatitude: to -metersPerPointAtLatitude:, leaving the old name as a deprecated alias. In Cocoa Touch terminology, “point” is the visual unit backed by pixels.
This commit is contained in:
Minh Nguyễn
2015-12-22 17:06:43 -08:00
committed by Minh Nguyễn
parent 35aeb06fe2
commit d745ff0923
3 changed files with 14 additions and 7 deletions

View File

@@ -261,13 +261,15 @@ IB_DESIGNABLE
* @return The point (in the appropriate view or window coordinate system) corresponding to the specified latitude and longitude value. */
- (CGPoint)convertCoordinate:(CLLocationCoordinate2D)coordinate toPointToView:(nullable UIView *)view;
/** Returns the distance spanned by one pixel at the specified latitude and current zoom level.
/** Returns the distance spanned by one point in the map view’s coordinate system at the given latitude and current zoom level.
*
* The distance between pixels decreases as the latitude approaches the poles. This relationship parallels the relationship between longitudinal coordinates at different latitudes.
* The distance between points decreases as the latitude approaches the poles. This relationship parallels the relationship between longitudinal coordinates at different latitudes.
*
* @param latitude The latitude for which to return the value.
* @return The distance (in meters) spanned by a single pixel. */
- (CLLocationDistance)metersPerPixelAtLatitude:(CLLocationDegrees)latitude;
* @param latitude The latitude of the geographic coordinate represented by the point.
* @return The distance in meters spanned by a single point. */
- (CLLocationDistance)metersPerPointAtLatitude:(CLLocationDegrees)latitude;
- (CLLocationDistance)metersPerPixelAtLatitude:(CLLocationDegrees)latitude __attribute__((deprecated("Call -metersPerPointAtLatitude: instead.")));
#pragma mark - Styling the Map

View File

@@ -1915,11 +1915,16 @@ std::chrono::steady_clock::duration MGLDurationInSeconds(float duration)
return bounds;
}
- (CLLocationDistance)metersPerPixelAtLatitude:(CLLocationDegrees)latitude
- (CLLocationDistance)metersPerPointAtLatitude:(CLLocationDegrees)latitude
{
return _mbglMap->getMetersPerPixelAtLatitude(latitude, self.zoomLevel);
}
- (CLLocationDistance)metersPerPixelAtLatitude:(CLLocationDegrees)latitude
{
return [self metersPerPointAtLatitude:latitude];
}
#pragma mark - Styling -
- (NS_ARRAY_OF(NSURL *) *)bundledStyleURLs

View File

@@ -436,7 +436,7 @@ const CGFloat MGLUserLocationAnnotationArrowSize = MGLUserLocationAnnotationPuck
- (CGFloat)calculateAccuracyRingSize
{
CGFloat latRadians = self.annotation.coordinate.latitude * M_PI / 180.0f;
CGFloat pixelRadius = self.annotation.location.horizontalAccuracy / cos(latRadians) / [self.mapView metersPerPixelAtLatitude:self.annotation.coordinate.latitude];
CGFloat pixelRadius = self.annotation.location.horizontalAccuracy / cos(latRadians) / [self.mapView metersPerPointAtLatitude:self.annotation.coordinate.latitude];
return pixelRadius * 2;
}