Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix metric measurements in CarPlay #1854

Merged
merged 1 commit into from
Nov 22, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
* `CarPlayManager(styles:directions:eventsManager:)` also allows you to pass in a custom `Directions` object to use when calculating routes. ([#1834](https://github.com/mapbox/mapbox-navigation-ios/pull/1834/))
* Removed the `StyleManager(_:)` initializer. After initializing a `StyleManager` object, set the `StyleManager.delegate` property to ensure that the style manager’s settings take effect. ([#1836](https://github.com/mapbox/mapbox-navigation-ios/pull/1836))
* Some additional members of `CarPlayManager` are now accessible in Objective-C code. ([#1836](https://github.com/mapbox/mapbox-navigation-ios/pull/1836))
* Fixed an issue where distances are incorrectly displayed as “0 m” in regions that use the metric system. ([#1854](https://github.com/mapbox/mapbox-navigation-ios/pull/1854))
* Fixed an issue where the user puck pointed away from the route line during turn-by-turn navigation in CarPlay. The map’s vanishing point now accounts for safe area insets, including the side maneuver view. ([#1845](https://github.com/mapbox/mapbox-navigation-ios/pull/1845))

### Other changes
Expand Down
6 changes: 3 additions & 3 deletions MapboxCoreNavigation/DistanceFormatter.swift
Original file line number Diff line number Diff line change
Expand Up @@ -68,11 +68,11 @@ struct RoundingTable {
func measurement(for distance: CLLocationDistance) -> Measurement<UnitLength> {
switch unit {
case .millimeter:
return Measurement(value: distance.kilometers / 1e6, unit: .millimeters)
return Measurement(value: distance * 1_000, unit: .millimeters)
case .centimeter:
return Measurement(value: distance.kilometers / 1e5, unit: .centimeters)
return Measurement(value: distance * 100, unit: .centimeters)
case .meter:
return Measurement(value: distance.kilometers / 1e3, unit: .meters)
return Measurement(value: distance, unit: .meters)
case .kilometer:
return Measurement(value: distance.kilometers, unit: .kilometers)
case .inch:
Expand Down
7 changes: 7 additions & 0 deletions MapboxCoreNavigationTests/DistanceFormatterTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,13 @@ class DistanceFormatterTests: XCTestCase {
assertDistance(384_400_000, displayed: "३,८४,४०० कि॰मी॰", quantity: "३,८४,४००")
}

@available(iOS 10.0, *)
func testMeters() {
let oneMeter: CLLocationDistance = 1
let measurement = DistanceFormatter().roundingTableMetric.thresholds.first?.measurement(for: oneMeter)
XCTAssertEqual(measurement?.value, oneMeter)
}

func testInches() {
let oneMeter: CLLocationDistance = 1
let oneMeterInInches = oneMeter.converted(to: .inch)
Expand Down