summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAsheem Mamoowala <asheem.mamoowala@mapbox.com>2018-04-05 18:57:54 -0700
committerAsheem Mamoowala <asheem.mamoowala@mapbox.com>2018-04-05 19:01:45 -0700
commit1052ef3ce82a6f231bdb5cce79ec387437128275 (patch)
tree528dddb10cfe34467d42c499819c7e2b10ac320b
parentcc01781db7281032f8c0c5eae54281187522a861 (diff)
downloadqtlocation-mapboxgl-upstream/changelog-custom-layer.tar.gz
Change MGLMapPointMake to MGLMapPointForCoordinateupstream/changelog-custom-layer
-rw-r--r--platform/darwin/src/MGLGeometry.h13
-rw-r--r--platform/darwin/src/MGLGeometry.mm8
-rw-r--r--platform/darwin/test/MGLGeometryTests.mm2
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);