diff options
author | Minh Nguyễn <mxn@1ec5.org> | 2017-04-06 08:30:34 -0700 |
---|---|---|
committer | John Firebaugh <john.firebaugh@gmail.com> | 2017-04-06 09:22:51 -0700 |
commit | 83824203143d85b40362317ba76313b34be782e4 (patch) | |
tree | 8291d7dea18b2fb03a5ad8513bc8f8f1251795f7 /platform/ios/src | |
parent | ab6185fdc343448d3b6cbfc5e2bc91b5242fdf9f (diff) | |
download | qtlocation-mapboxgl-83824203143d85b40362317ba76313b34be782e4.tar.gz |
[ios, macos] Fail gracefully on invalid coordinates
Invalid coordinates no longer cause an exception to be raised immediately when used in conversion methods and model objects. Instead, the appropriate invalid values are used, consistent with MapKit. Exceptions are still raised when invalid model objects are used with the map.
Diffstat (limited to 'platform/ios/src')
-rw-r--r-- | platform/ios/src/MGLMapView.mm | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/platform/ios/src/MGLMapView.mm b/platform/ios/src/MGLMapView.mm index f5c3ce3ba6..d80e741c00 100644 --- a/platform/ios/src/MGLMapView.mm +++ b/platform/ios/src/MGLMapView.mm @@ -2843,6 +2843,10 @@ public: - (CGPoint)convertCoordinate:(CLLocationCoordinate2D)coordinate toPointToView:(nullable UIView *)view { + if ( ! CLLocationCoordinate2DIsValid(coordinate)) + { + return CGPointMake(NAN, NAN); + } return [self convertLatLng:MGLLatLngFromLocationCoordinate2D(coordinate) toPointToView:view]; } @@ -2860,6 +2864,10 @@ public: - (CGRect)convertCoordinateBounds:(MGLCoordinateBounds)bounds toRectToView:(nullable UIView *)view { + if ( ! CLLocationCoordinate2DIsValid(bounds.sw) || ! CLLocationCoordinate2DIsValid(bounds.ne)) + { + return CGRectNull; + } return [self convertLatLngBounds:MGLLatLngBoundsFromCoordinateBounds(bounds) toRectToView:view]; } |