-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTranslationTests.swift
42 lines (29 loc) · 1.9 KB
/
TranslationTests.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
31
32
33
34
35
36
37
38
39
40
41
42
//
// TranslationTests.swift
//
//
// Created by Adrian Schönig on 9/12/2022.
//
import XCTest
@testable import GeoProjector
final class TranslationTests: XCTestCase {
#if os(macOS)
let macOS: Bool = true
#else
let macOS: Bool = false
#endif
func testEquirectangularInSquare() throws {
XCTAssertEqual(Projections.Equirectangular().translate(Point(x: 0, y: 0), to: .init(width: 100, height: 100)), .init(x: 50, y: 50))
XCTAssertEqual(Projections.Equirectangular().translate(Point(x: -1 * .pi, y: 0.5 * .pi), to: .init(width: 100, height: 100)), .init(x: 0, y: macOS ? 75 : 25))
XCTAssertEqual(Projections.Equirectangular().translate(Point(x: .pi, y: 0.5 * .pi), to: .init(width: 100, height: 100)), .init(x: 100, y: macOS ? 75 : 25))
XCTAssertEqual(Projections.Equirectangular().translate(Point(x: .pi, y: -0.5 * .pi), to: .init(width: 100, height: 100)), .init(x: 100, y: macOS ? 25 : 75))
XCTAssertEqual(Projections.Equirectangular().translate(Point(x: -1 * .pi, y: -0.5 * .pi), to: .init(width: 100, height: 100)), .init(x: 0, y: macOS ? 25 : 75))
}
func testEquirectangularInWideStripe() throws {
XCTAssertEqual(Projections.Equirectangular().translate(Point(x: 0, y: 0), to: .init(width: 400, height: 100)), .init(x: 200, y: 50))
XCTAssertEqual(Projections.Equirectangular().translate(Point(x: -1 * .pi, y: 0.5 * .pi), to: .init(width: 400, height: 100)), .init(x: 100, y: macOS ? 100 : 0))
XCTAssertEqual(Projections.Equirectangular().translate(Point(x: .pi, y: 0.5 * .pi), to: .init(width: 400, height: 100)), .init(x: 300, y: macOS ? 100 : 0))
XCTAssertEqual(Projections.Equirectangular().translate(Point(x: .pi, y: -0.5 * .pi), to: .init(width: 400, height: 100)), .init(x: 300, y: macOS ? 0 : 100))
XCTAssertEqual(Projections.Equirectangular().translate(Point(x: -1 * .pi, y: -0.5 * .pi), to: .init(width: 400, height: 100)), .init(x: 100, y: macOS ? 0 : 100))
}
}