summaryrefslogtreecommitdiff
path: root/platform/darwin/include
diff options
context:
space:
mode:
authorMinh Nguyễn <mxn@1ec5.org>2016-04-22 11:12:27 -0700
committerMinh Nguyễn <mxn@1ec5.org>2016-04-22 11:29:10 -0700
commit2a1a5f088564b2d6c2e3765d0d741edf1886fc81 (patch)
tree4f58085117a42213db7b70e21cc16a535fe3ff34 /platform/darwin/include
parente5c6cfde4b4f36cadeadfcb320bd641c4517f366 (diff)
downloadqtlocation-mapboxgl-2a1a5f088564b2d6c2e3765d0d741edf1886fc81.tar.gz
[ios, osx] Split MGLDirectionFormatter in two
Split MGLDirectionFormatter into MGLClockDirectionFormatter, which specializes in clock positions, and MGLCompassDirectionFormatter, which boxes the compass. This neatly avoids any confusion that might arise if the developer fails to read the documentation and thinks the original unified formatter can convert between the two types of directions.
Diffstat (limited to 'platform/darwin/include')
-rw-r--r--platform/darwin/include/MGLClockDirectionFormatter.h52
-rw-r--r--platform/darwin/include/MGLCompassDirectionFormatter.h42
-rw-r--r--platform/darwin/include/MGLDirectionFormatter.h77
3 files changed, 94 insertions, 77 deletions
diff --git a/platform/darwin/include/MGLClockDirectionFormatter.h b/platform/darwin/include/MGLClockDirectionFormatter.h
new file mode 100644
index 0000000000..e748a15847
--- /dev/null
+++ b/platform/darwin/include/MGLClockDirectionFormatter.h
@@ -0,0 +1,52 @@
+#import <Foundation/Foundation.h>
+#import <CoreLocation/CoreLocation.h>
+
+#import "MGLTypes.h"
+
+NS_ASSUME_NONNULL_BEGIN
+
+/**
+ The `MGLClockDirectionFormatter` class provides properly formatted descriptions
+ of headings relative to the user, known as <i>clock positions</i>. For
+ example, a value of `90` may be formatted as “3 o’clock”, depending on the
+ locale.
+
+ Use this class to create localized heading strings when displaying directions
+ relative to the user’s current location and heading. To format a direction
+ irrespective of the user’s orientation, use `MGLCompassDirectionFormatter`
+ instead.
+ */
+@interface MGLClockDirectionFormatter : NSFormatter
+
+/**
+ The unit style used by this formatter.
+
+ This property defaults to `NSFormattingUnitStyleMedium`.
+ */
+@property (nonatomic) NSFormattingUnitStyle unitStyle;
+
+/**
+ The locale of the receiver.
+
+ The locale determines the output language and numeral system of the output.
+ */
+@property (copy) NSLocale *locale;
+
+/**
+ Returns a clock position string for the provided value.
+
+ @param direction The heading, measured in degrees, where 0° means “straight
+ ahead” and 90° means “directly to your right”.
+ @return The clock position string appropriately formatted for the receiver’s
+ locale.
+ */
+- (NSString *)stringFromDirection:(CLLocationDirection)direction;
+
+/**
+ This method is not supported for the `MGLDirectionFormatter` class.
+ */
+- (BOOL)getObjectValue:(out id __nullable * __nullable)obj forString:(NSString *)string errorDescription:(out NSString * __nullable * __nullable)error;
+
+@end
+
+NS_ASSUME_NONNULL_END
diff --git a/platform/darwin/include/MGLCompassDirectionFormatter.h b/platform/darwin/include/MGLCompassDirectionFormatter.h
new file mode 100644
index 0000000000..d7c3113291
--- /dev/null
+++ b/platform/darwin/include/MGLCompassDirectionFormatter.h
@@ -0,0 +1,42 @@
+#import <Foundation/Foundation.h>
+#import <CoreLocation/CoreLocation.h>
+
+#import "MGLTypes.h"
+
+NS_ASSUME_NONNULL_BEGIN
+
+/**
+ The `MGLCompassDirectionFormatter` class provides properly formatted
+ descriptions of absolute headings. For example, a value of `90` may be
+ formatted as “east”, depending on the locale.
+
+ Use this class to create localized heading strings when displaying directions
+ irrespective of the user’s current location. To format a direction relative to
+ the user’s current location, use `MGLCompassDirectionFormatter` instead.
+ */
+@interface MGLCompassDirectionFormatter : NSFormatter
+
+/**
+ The unit style used by this formatter.
+
+ This property defaults to `NSFormattingUnitStyleMedium`.
+ */
+@property (nonatomic) NSFormattingUnitStyle unitStyle;
+
+/**
+ Returns a heading string for the provided value.
+
+ @param direction The heading, measured in degrees, where 0° means “due north”
+ and 90° means “due east”.
+ @return The heading string appropriately formatted for the formatter’s locale.
+ */
+- (NSString *)stringFromDirection:(CLLocationDirection)direction;
+
+/**
+ This method is not supported for the `MGLDirectionFormatter` class.
+ */
+- (BOOL)getObjectValue:(out id __nullable * __nullable)obj forString:(NSString *)string errorDescription:(out NSString * __nullable * __nullable)error;
+
+@end
+
+NS_ASSUME_NONNULL_END
diff --git a/platform/darwin/include/MGLDirectionFormatter.h b/platform/darwin/include/MGLDirectionFormatter.h
deleted file mode 100644
index 9091292e22..0000000000
--- a/platform/darwin/include/MGLDirectionFormatter.h
+++ /dev/null
@@ -1,77 +0,0 @@
-#import <Foundation/Foundation.h>
-#import <CoreLocation/CoreLocation.h>
-
-#import "MGLTypes.h"
-
-NS_ASSUME_NONNULL_BEGIN
-
-/**
- The reference point for an `MGLDirectionFormatter`.
- */
-typedef NS_ENUM(NSUInteger, MGLDirectionFormatterOrigin) {
- /**
- Directions are assumed to be relative to true north and are given as
- compass directions, such as “south” for a value of `90`.
- */
- MGLDirectionFormatterOriginNorth = 0,
- /**
- Directions are assumed to be relative to the direction in which the user is
- facing and are given as “clock directions”, such as “6 o’clock” for a value
- of `90`.
- */
- MGLDirectionFormatterOriginStraightAhead,
-};
-
-/**
- The `MGLDirectionFormatter` class provides properly formatted descriptions of
- absolute or relative headings. Use this class to create localized heading
- strings when displaying directional information to users.
- */
-@interface MGLDirectionFormatter : NSFormatter
-
-/**
- The receiver’s reference point. The receiver’s input is assumed to be relative
- to this reference point, and its output is given in the conventional form for
- directions with this reference point.
-
- This class does not convert between different reference points. To convert an
- `CLLocationDirection` with respect to true north into a `CLLocationDirection`
- with respect to the direction in which the user is currently facing, use Core
- Location to determine the user’s current heading.
-
- The default value of this property is `MGLDirectionFormatterOriginNorth`, which
- means a value of `0` is formatted as “north” in the receiver’s locale.
- */
-@property (nonatomic) MGLDirectionFormatterOrigin origin;
-
-/**
- The unit style used by this formatter.
-
- This property defaults to `NSFormattingUnitStyleMedium`.
- */
-@property (nonatomic) NSFormattingUnitStyle unitStyle;
-
-/**
- The locale of the receiver.
-
- The locale determines the output language as well as the numeral system used
- when the `relativeToUser` property is set to `YES`.
- */
-@property (copy) NSLocale *locale;
-
-/**
- Returns a heading string for the provided value.
-
- @param direction The heading, measured in degrees.
- @return The heading string appropriately formatted for the formatter’s locale.
- */
-- (NSString *)stringFromDirection:(CLLocationDirection)direction;
-
-/**
- This method is not supported for the `MGLDirectionFormatter` class.
- */
-- (BOOL)getObjectValue:(out id __nullable * __nullable)obj forString:(NSString *)string errorDescription:(out NSString * __nullable * __nullable)error;
-
-@end
-
-NS_ASSUME_NONNULL_END