-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathFrechetDistanceTests.swift
30 lines (23 loc) · 1.28 KB
/
FrechetDistanceTests.swift
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#if !os(Linux)
import CoreLocation
#endif
@testable import GISTools
import XCTest
final class FrechetDistanceTests: XCTestCase {
func testFrechetDistance4326() throws {
let point = Point(Coordinate3D(latitude: 0.0, longitude: 0.0))
let lineArc1 = try XCTUnwrap(point.lineArc(radius: 5000.0, bearing1: 20.0, bearing2: 60.0))
let lineArc2 = try XCTUnwrap(point.lineArc(radius: 6000.0, bearing1: 20.0, bearing2: 60.0))
let distanceHaversine = lineArc1.frechetDistance(from: lineArc2, distanceFunction: .haversine)
let distanceRhumbLine = lineArc1.frechetDistance(from: lineArc2, distanceFunction: .rhumbLine)
XCTAssertEqual(distanceHaversine, 1000.0, accuracy: 0.0001)
XCTAssertEqual(distanceRhumbLine, 1000.0, accuracy: 0.0001)
}
func testFrechetDistance3857() throws {
let point = Point(Coordinate3D(latitude: 0.0, longitude: 0.0)).projected(to: .epsg3857)
let lineArc1 = try XCTUnwrap(point.lineArc(radius: 5000.0, bearing1: 20.0, bearing2: 60.0))
let lineArc2 = try XCTUnwrap(point.lineArc(radius: 6000.0, bearing1: 20.0, bearing2: 60.0))
let distanceEucliden = lineArc1.frechetDistance(from: lineArc2, distanceFunction: .euclidean)
XCTAssertEqual(distanceEucliden, 1000.0, accuracy: 2.0)
}
}