diff options
-rw-r--r-- | platform/darwin/src/MGLGeometry.mm | 9 | ||||
-rw-r--r-- | platform/darwin/src/MGLGeometry_Private.h | 16 |
2 files changed, 10 insertions, 15 deletions
diff --git a/platform/darwin/src/MGLGeometry.mm b/platform/darwin/src/MGLGeometry.mm index 8c0c5f9cb7..1540a3a741 100644 --- a/platform/darwin/src/MGLGeometry.mm +++ b/platform/darwin/src/MGLGeometry.mm @@ -32,6 +32,15 @@ CGRect MGLExtendRect(CGRect rect, CGPoint point) { return rect; } +mbgl::LatLng MGLLatLngFromLocationCoordinate2D(CLLocationCoordinate2D coordinate) { + try { + return mbgl::LatLng(coordinate.latitude, coordinate.longitude); + } catch (std::domain_error &error) { + [NSException raise:NSInvalidArgumentException format:@"%s", error.what()]; + return {}; + } +} + MGL_EXPORT CLLocationDistance MGLAltitudeForZoomLevel(double zoomLevel, CGFloat pitch, CLLocationDegrees latitude, CGSize size) { CLLocationDistance metersPerPixel = mbgl::Projection::getMetersPerPixelAtLatitude(latitude, zoomLevel); diff --git a/platform/darwin/src/MGLGeometry_Private.h b/platform/darwin/src/MGLGeometry_Private.h index d72e4959c9..3e029e8ee0 100644 --- a/platform/darwin/src/MGLGeometry_Private.h +++ b/platform/darwin/src/MGLGeometry_Private.h @@ -12,21 +12,7 @@ /// the given point. CGRect MGLExtendRect(CGRect rect, CGPoint point); -NS_INLINE mbgl::LatLng MGLLatLngFromLocationCoordinate2D(CLLocationCoordinate2D coordinate) { - if (std::isnan(coordinate.latitude)) { - [NSException raise:NSInvalidArgumentException format:@"latitude must not be NaN"]; - } - if (std::isnan(coordinate.longitude)) { - [NSException raise:NSInvalidArgumentException format:@"longitude must not be NaN"]; - } - if (std::abs(coordinate.latitude) > 90.0) { - [NSException raise:NSInvalidArgumentException format:@"latitude must be between -90 and 90"]; - } - if (!std::isfinite(coordinate.longitude)) { - [NSException raise:NSInvalidArgumentException format:@"longitude must not be infinite"]; - } - return mbgl::LatLng(coordinate.latitude, coordinate.longitude); -} +mbgl::LatLng MGLLatLngFromLocationCoordinate2D(CLLocationCoordinate2D coordinate); NS_INLINE mbgl::Point<double> MGLPointFromLocationCoordinate2D(CLLocationCoordinate2D coordinate) { return mbgl::Point<double>(coordinate.longitude, coordinate.latitude); |