diff options
author | Minh Nguyễn <mxn@1ec5.org> | 2017-02-21 22:47:15 -0800 |
---|---|---|
committer | Minh Nguyễn <mxn@1ec5.org> | 2017-02-21 22:47:15 -0800 |
commit | 2f388d663505255e967597c52656cc076e20d95c (patch) | |
tree | 157ec4c96a5d6f7c67367f96b73957870ee78edb /platform/darwin/src/MGLMapCamera.mm | |
parent | b512af6a6682bf133d8d580cccb309f671f287f6 (diff) | |
parent | df6a06bd07bda3207b31d86dd66a7468cc33c440 (diff) | |
download | qtlocation-mapboxgl-2f388d663505255e967597c52656cc076e20d95c.tar.gz |
Merge branch 'release-ios-v3.4.0' into 1ec5-release-ios-v3.4.2
Diffstat (limited to 'platform/darwin/src/MGLMapCamera.mm')
-rw-r--r-- | platform/darwin/src/MGLMapCamera.mm | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/platform/darwin/src/MGLMapCamera.mm b/platform/darwin/src/MGLMapCamera.mm index 260ea31bbd..613124da66 100644 --- a/platform/darwin/src/MGLMapCamera.mm +++ b/platform/darwin/src/MGLMapCamera.mm @@ -2,6 +2,11 @@ #include <mbgl/util/projection.hpp> +BOOL MGLEqualFloatWithAccuracy(CGFloat left, CGFloat right, CGFloat accuracy) +{ + return MAX(left, right) - MIN(left, right) <= accuracy; +} + @implementation MGLMapCamera + (BOOL)supportsSecureCoding @@ -116,6 +121,20 @@ && _pitch == otherCamera.pitch && _heading == otherCamera.heading); } +- (BOOL)isEqualToMapCamera:(MGLMapCamera *)otherCamera +{ + if (otherCamera == self) + { + return YES; + } + + return (MGLEqualFloatWithAccuracy(_centerCoordinate.latitude, otherCamera.centerCoordinate.latitude, 1e-6) + && MGLEqualFloatWithAccuracy(_centerCoordinate.longitude, otherCamera.centerCoordinate.longitude, 1e-6) + && MGLEqualFloatWithAccuracy(_altitude, otherCamera.altitude, 1e-6) + && MGLEqualFloatWithAccuracy(_pitch, otherCamera.pitch, 1) + && MGLEqualFloatWithAccuracy(_heading, otherCamera.heading, 1)); +} + - (NSUInteger)hash { return (@(_centerCoordinate.latitude).hash + @(_centerCoordinate.longitude).hash |