summaryrefslogtreecommitdiff
path: root/platform/darwin/src
diff options
context:
space:
mode:
authorJason Wray <friedbunny@users.noreply.github.com>2016-05-17 11:02:22 -0400
committerJason Wray <friedbunny@users.noreply.github.com>2016-05-17 11:02:22 -0400
commit22447373ae9f975a11a809d1384e72be0d1889cf (patch)
tree169b19218144e9b4a3b2b6b32cdc1c1e540b0279 /platform/darwin/src
parent4434c0438a75e9c5bf0a36229b73ffc352c02639 (diff)
downloadqtlocation-mapboxgl-22447373ae9f975a11a809d1384e72be0d1889cf.tar.gz
[ios] Make MGLCoordinateInCoordinateBounds() public (#5053)
Bounds should always be in NE, SW order — any other coordinate order (e.g., NW, SE) will give false results.
Diffstat (limited to 'platform/darwin/src')
-rw-r--r--platform/darwin/src/MGLGeometry.h8
-rw-r--r--platform/darwin/src/MGLGeometry_Private.h5
2 files changed, 8 insertions, 5 deletions
diff --git a/platform/darwin/src/MGLGeometry.h b/platform/darwin/src/MGLGeometry.h
index af54d7b391..ca99eaf16f 100644
--- a/platform/darwin/src/MGLGeometry.h
+++ b/platform/darwin/src/MGLGeometry.h
@@ -64,6 +64,14 @@ NS_INLINE BOOL MGLCoordinateBoundsEqualToCoordinateBounds(MGLCoordinateBounds bo
bounds1.ne.longitude == bounds2.ne.longitude);
}
+/** Returns `YES` if the coordinate is within the coordinate bounds. */
+NS_INLINE BOOL MGLCoordinateInCoordinateBounds(CLLocationCoordinate2D coordinate, MGLCoordinateBounds bounds) {
+ return (coordinate.latitude >= bounds.sw.latitude &&
+ coordinate.latitude <= bounds.ne.latitude &&
+ coordinate.longitude >= bounds.sw.longitude &&
+ coordinate.longitude <= bounds.ne.longitude);
+}
+
/** Returns the area spanned by the coordinate bounds. */
NS_INLINE MGLCoordinateSpan MGLCoordinateBoundsGetCoordinateSpan(MGLCoordinateBounds bounds) {
return MGLCoordinateSpanMake(bounds.ne.latitude - bounds.sw.latitude,
diff --git a/platform/darwin/src/MGLGeometry_Private.h b/platform/darwin/src/MGLGeometry_Private.h
index 71a083e588..0538cd94ea 100644
--- a/platform/darwin/src/MGLGeometry_Private.h
+++ b/platform/darwin/src/MGLGeometry_Private.h
@@ -29,11 +29,6 @@ NS_INLINE mbgl::LatLngBounds MGLLatLngBoundsFromCoordinateBounds(MGLCoordinateBo
MGLLatLngFromLocationCoordinate2D(coordinateBounds.ne));
}
-NS_INLINE BOOL MGLCoordinateInCoordinateBounds(CLLocationCoordinate2D coordinate, MGLCoordinateBounds coordinateBounds) {
- mbgl::LatLngBounds bounds = MGLLatLngBoundsFromCoordinateBounds(coordinateBounds);
- return bounds.contains(MGLLatLngFromLocationCoordinate2D(coordinate));
-}
-
#if TARGET_OS_IPHONE
NS_INLINE mbgl::EdgeInsets MGLEdgeInsetsFromNSEdgeInsets(UIEdgeInsets insets) {
return { insets.top, insets.left, insets.bottom, insets.right };