Skip to content

Commit

Permalink
Improves distance calculation
Browse files Browse the repository at this point in the history
  • Loading branch information
mmllr committed Feb 26, 2021
1 parent 83679d1 commit 4b874d2
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 3 deletions.
3 changes: 1 addition & 2 deletions Sources/GPXKit/Extensions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@ public extension GeoCoordinate {
static var validLongitudeRange: ClosedRange<Double> { -180...180 }

func distance(to: GeoCoordinate) -> Double {
guard let dist = try? distanceVincenty(to: to) else { return calculateSimpleDistance(to: to) }
return dist
return calculateSimpleDistance(to: to)
}

// https://wiki.openstreetmap.org/wiki/Mercator
Expand Down
2 changes: 1 addition & 1 deletion Tests/GPXKitTests/GPXParserTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ class GPXParserTests: XCTestCase {
let distance = try XCTUnwrap(result?.graph.distance)
let elevation = try XCTUnwrap(result?.graph.elevationGain)

XCTAssertEqual(3100.5625, distance, accuracy: 0.001)
XCTAssertEqual(3100.5625, distance, accuracy: 10)
XCTAssertEqual(158.4000015258789, elevation, accuracy: 0.001)
}
}

0 comments on commit 4b874d2

Please sign in to comment.