summaryrefslogtreecommitdiff
path: root/platform/darwin/src/MGLCompassDirectionFormatter.m
diff options
context:
space:
mode:
authorMinh Nguyễn <mxn@1ec5.org>2016-04-24 23:38:49 -0700
committerMinh Nguyễn <mxn@1ec5.org>2016-04-24 23:38:49 -0700
commitbf313b0c5fb17569ba69be63bfc8af41fd5cffa6 (patch)
tree7dbc3229018c01bb036fce0ec8fc75301abb45b0 /platform/darwin/src/MGLCompassDirectionFormatter.m
parent57f0a211251a9378fa004ee22b2c6f4d21e2bd59 (diff)
downloadqtlocation-mapboxgl-bf313b0c5fb17569ba69be63bfc8af41fd5cffa6.tar.gz
[ios, osx] Fixed direction formatter edge cases
Fixed an issue causing angles that are multiples of 360°, such as 720°, to be described as 0 o’clock. Fixed a crash when a compass direction is close enough to 360° to round up to 360°.
Diffstat (limited to 'platform/darwin/src/MGLCompassDirectionFormatter.m')
-rw-r--r--platform/darwin/src/MGLCompassDirectionFormatter.m2
1 files changed, 1 insertions, 1 deletions
diff --git a/platform/darwin/src/MGLCompassDirectionFormatter.m b/platform/darwin/src/MGLCompassDirectionFormatter.m
index 8a4118ba55..c46fe9e4d5 100644
--- a/platform/darwin/src/MGLCompassDirectionFormatter.m
+++ b/platform/darwin/src/MGLCompassDirectionFormatter.m
@@ -98,7 +98,7 @@
NSAssert(shortStrings.count == longStrings.count, @"Long and short compass direction string arrays must have the same size.");
});
- NSInteger cardinalPoint = round(wrap(direction, 0, 360) / 360 * shortStrings.count);
+ NSInteger cardinalPoint = wrap(round(wrap(direction, 0, 360) / 360 * shortStrings.count), 0, shortStrings.count);
switch (self.unitStyle) {
case NSFormattingUnitStyleShort:
return shortStrings[cardinalPoint];