diff options
-rw-r--r-- | platform/darwin/src/MGLGeometry.h | 13 | ||||
-rw-r--r-- | platform/darwin/src/MGLGeometry.mm | 8 | ||||
-rw-r--r-- | 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 @@ -36,6 +36,17 @@ NS_INLINE MGLCoordinateSpan MGLCoordinateSpanMake(CLLocationDegrees latitudeDelt } /** + 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<double> 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); |