From e32a0586f2097ad29496636453837f215612ad7b Mon Sep 17 00:00:00 2001 From: Asheem Mamoowala Date: Thu, 5 Apr 2018 18:57:54 -0700 Subject: Change MGLMapPointMake to MGLMapPointForCoordinate --- platform/darwin/src/MGLGeometry.h | 13 ++++++++++++- platform/darwin/src/MGLGeometry.mm | 8 ++------ platform/darwin/test/MGLGeometryTests.mm | 2 +- 3 files changed, 15 insertions(+), 8 deletions(-) diff --git a/platform/darwin/src/MGLGeometry.h b/platform/darwin/src/MGLGeometry.h index 5d8e7eccd5..6d1a373cca 100644 --- a/platform/darwin/src/MGLGeometry.h +++ b/platform/darwin/src/MGLGeometry.h @@ -35,6 +35,17 @@ NS_INLINE MGLCoordinateSpan MGLCoordinateSpanMake(CLLocationDegrees latitudeDelt return span; } +/** + Creates a new `MGLMapPoint` from the given X and Y coordinates, and zoom level. + */ +NS_INLINE MGLMapPoint MGLMapPointMake(CGFloat x, CGFloat y, CGFloat zoomLevel) { + MGLMapPoint point; + point.x = x; + point.y = y; + point.zoomLevel = zoomLevel; + return point; +} + /** Returns `YES` if the two coordinate spans represent the same latitudinal change and the same longitudinal change. @@ -192,6 +203,6 @@ NS_INLINE CLLocationDegrees MGLDegreesFromRadians(CGFloat radians) { } /** Returns Mercator projection of a WGS84 coordinate at the specified zoom level. */ -extern MGL_EXPORT MGLMapPoint MGLMapPointMake(CLLocationCoordinate2D coordinate, double zoomLevel); +extern MGL_EXPORT MGLMapPoint MGLMapPointForCoordinate(CLLocationCoordinate2D coordinate, double zoomLevel); NS_ASSUME_NONNULL_END diff --git a/platform/darwin/src/MGLGeometry.mm b/platform/darwin/src/MGLGeometry.mm index 63886b6474..0b044f7521 100644 --- a/platform/darwin/src/MGLGeometry.mm +++ b/platform/darwin/src/MGLGeometry.mm @@ -107,11 +107,7 @@ CGPoint MGLPointRounded(CGPoint point) { return CGPointMake(round(point.x * scaleFactor) / scaleFactor, round(point.y * scaleFactor) / scaleFactor); } -MGLMapPoint MGLMapPointMake(CLLocationCoordinate2D coordinate, double zoomLevel) { +MGLMapPoint MGLMapPointForCoordinate(CLLocationCoordinate2D coordinate, double zoomLevel) { mbgl::Point projectedCoordinate = mbgl::Projection::project(MGLLatLngFromLocationCoordinate2D(coordinate), std::pow(2.0, zoomLevel)); - MGLMapPoint point; - point.x = projectedCoordinate.x; - point.y = projectedCoordinate.y; - point.zoomLevel = zoomLevel; - return point; + return MGLMapPointMake(projectedCoordinate.x, projectedCoordinate.y, zoomLevel); } diff --git a/platform/darwin/test/MGLGeometryTests.mm b/platform/darwin/test/MGLGeometryTests.mm index 57840d9953..a0ddecf77e 100644 --- a/platform/darwin/test/MGLGeometryTests.mm +++ b/platform/darwin/test/MGLGeometryTests.mm @@ -165,7 +165,7 @@ } - (void)testMGLMapPoint { - MGLMapPoint point = MGLMapPointMake(CLLocationCoordinate2DMake(37.936, -80.425), 0.0); + MGLMapPoint point = MGLMapPointForCoordinate(CLLocationCoordinate2DMake(37.936, -80.425), 0.0); MGLMapPoint roundTrippedPoint = [NSValue valueWithMGLMapPoint:point].MGLMapPointValue; XCTAssertEqual(point.x, roundTrippedPoint.x); -- cgit v1.2.1