Skip to content

Commit 152354d

Browse files
committed
✨ Implement transitive conversions
1 parent be1d47e commit 152354d

File tree

13 files changed

+393
-110
lines changed

13 files changed

+393
-110
lines changed
Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<Scheme
3+
LastUpgradeVersion = "1410"
4+
version = "1.3">
5+
<BuildAction
6+
parallelizeBuildables = "YES"
7+
buildImplicitDependencies = "YES">
8+
<BuildActionEntries>
9+
<BuildActionEntry
10+
buildForTesting = "YES"
11+
buildForRunning = "YES"
12+
buildForProfiling = "YES"
13+
buildForArchiving = "YES"
14+
buildForAnalyzing = "YES">
15+
<BuildableReference
16+
BuildableIdentifier = "primary"
17+
BlueprintIdentifier = "GeodeticConversions"
18+
BuildableName = "GeodeticConversions"
19+
BlueprintName = "GeodeticConversions"
20+
ReferencedContainer = "container:">
21+
</BuildableReference>
22+
</BuildActionEntry>
23+
<BuildActionEntry
24+
buildForTesting = "YES"
25+
buildForRunning = "NO"
26+
buildForProfiling = "NO"
27+
buildForArchiving = "NO"
28+
buildForAnalyzing = "NO">
29+
<BuildableReference
30+
BuildableIdentifier = "primary"
31+
BlueprintIdentifier = "GeodeticConversionsTests"
32+
BuildableName = "GeodeticConversionsTests"
33+
BlueprintName = "GeodeticConversionsTests"
34+
ReferencedContainer = "container:">
35+
</BuildableReference>
36+
</BuildActionEntry>
37+
</BuildActionEntries>
38+
</BuildAction>
39+
<TestAction
40+
buildConfiguration = "Debug"
41+
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
42+
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
43+
shouldUseLaunchSchemeArgsEnv = "YES">
44+
<Testables>
45+
<TestableReference
46+
skipped = "NO">
47+
<BuildableReference
48+
BuildableIdentifier = "primary"
49+
BlueprintIdentifier = "GeodeticConversionsTests"
50+
BuildableName = "GeodeticConversionsTests"
51+
BlueprintName = "GeodeticConversionsTests"
52+
ReferencedContainer = "container:">
53+
</BuildableReference>
54+
</TestableReference>
55+
</Testables>
56+
</TestAction>
57+
<LaunchAction
58+
buildConfiguration = "Debug"
59+
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
60+
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
61+
launchStyle = "0"
62+
useCustomWorkingDirectory = "NO"
63+
ignoresPersistentStateOnLaunch = "NO"
64+
debugDocumentVersioning = "YES"
65+
debugServiceExtension = "internal"
66+
allowLocationSimulation = "YES">
67+
</LaunchAction>
68+
<ProfileAction
69+
buildConfiguration = "Release"
70+
shouldUseLaunchSchemeArgsEnv = "YES"
71+
savedToolIdentifier = ""
72+
useCustomWorkingDirectory = "NO"
73+
debugDocumentVersioning = "YES">
74+
<MacroExpansion>
75+
<BuildableReference
76+
BuildableIdentifier = "primary"
77+
BlueprintIdentifier = "GeodeticConversions"
78+
BuildableName = "GeodeticConversions"
79+
BlueprintName = "GeodeticConversions"
80+
ReferencedContainer = "container:">
81+
</BuildableReference>
82+
</MacroExpansion>
83+
</ProfileAction>
84+
<AnalyzeAction
85+
buildConfiguration = "Debug">
86+
</AnalyzeAction>
87+
<ArchiveAction
88+
buildConfiguration = "Release"
89+
revealArchiveInOrganizer = "YES">
90+
</ArchiveAction>
91+
</Scheme>

.swiftpm/xcode/xcshareddata/xcschemes/swift-geo-Package.xcscheme

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,34 @@
188188
ReferencedContainer = "container:">
189189
</BuildableReference>
190190
</BuildActionEntry>
191+
<BuildActionEntry
192+
buildForTesting = "YES"
193+
buildForRunning = "YES"
194+
buildForProfiling = "YES"
195+
buildForArchiving = "YES"
196+
buildForAnalyzing = "YES">
197+
<BuildableReference
198+
BuildableIdentifier = "primary"
199+
BlueprintIdentifier = "GeodeticConversions"
200+
BuildableName = "GeodeticConversions"
201+
BlueprintName = "GeodeticConversions"
202+
ReferencedContainer = "container:">
203+
</BuildableReference>
204+
</BuildActionEntry>
205+
<BuildActionEntry
206+
buildForTesting = "YES"
207+
buildForRunning = "YES"
208+
buildForProfiling = "YES"
209+
buildForArchiving = "YES"
210+
buildForAnalyzing = "YES">
211+
<BuildableReference
212+
BuildableIdentifier = "primary"
213+
BlueprintIdentifier = "WGS84Conversions"
214+
BuildableName = "WGS84Conversions"
215+
BlueprintName = "WGS84Conversions"
216+
ReferencedContainer = "container:">
217+
</BuildableReference>
218+
</BuildActionEntry>
191219
</BuildActionEntries>
192220
</BuildAction>
193221
<TestAction
@@ -257,6 +285,16 @@
257285
ReferencedContainer = "container:">
258286
</BuildableReference>
259287
</TestableReference>
288+
<TestableReference
289+
skipped = "NO">
290+
<BuildableReference
291+
BuildableIdentifier = "primary"
292+
BlueprintIdentifier = "GeodeticConversionsTests"
293+
BuildableName = "GeodeticConversionsTests"
294+
BlueprintName = "GeodeticConversionsTests"
295+
ReferencedContainer = "container:">
296+
</BuildableReference>
297+
</TestableReference>
260298
</Testables>
261299
</TestAction>
262300
<LaunchAction

Package.swift

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ let package = Package(
1212
// Products define the executables and libraries a package produces,
1313
// and make them visible to other packages.
1414
.library(name: "Geodesy", targets: ["Geodesy"]),
15+
.library(name: "GeodeticConversions", targets: ["GeodeticConversions"]),
1516
.library(name: "WGS84", targets: ["WGS84"]),
1617
.library(name: "GeodeticGeometry", targets: ["GeodeticGeometry"]),
1718
.library(name: "Turf", targets: ["Turf"]),
@@ -113,10 +114,23 @@ let package = Package(
113114
.target(name: "TurfMapKit", dependencies: ["TurfCore", "WGS84Geometry"]),
114115

115116
// 🗺️ World Geodetic System standard
116-
.target(name: "WGS84", dependencies: ["WGS84Core", "WGS84Geometry", "WGS84Turf"]),
117+
.target(name: "WGS84", dependencies: [
118+
"WGS84Core",
119+
"WGS84Conversions",
120+
"WGS84Geometry",
121+
"WGS84Turf",
122+
]),
117123
.testTarget(name: "WGS84Tests", dependencies: ["WGS84"]),
118124
.target(name: "WGS84Core", dependencies: ["Geodesy", "GeodeticDisplay"]),
125+
.target(name: "WGS84Conversions", dependencies: ["WGS84Core", "GeodeticConversions"]),
119126
.target(name: "WGS84Geometry", dependencies: ["WGS84Core", "GeodeticGeometry"]),
120127
.target(name: "WGS84Turf", dependencies: ["WGS84Geometry", "Turf"]),
128+
129+
// 🎭 Conversions from one Coordinate Reference System to another
130+
.target(name: "GeodeticConversions", dependencies: ["Geodesy", "WGS84Core"]),
131+
.testTarget(name: "GeodeticConversionsTests", dependencies: [
132+
"GeodeticConversions",
133+
"WGS84Conversions",
134+
]),
121135
]
122136
)

Sources/Geodesy/Geodesy.swift

Lines changed: 19 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ where CRS: TwoDimensionalCRS
4646
init(x: X, y: Y)
4747
}
4848

49-
public struct Coordinates2D<CRS>: TwoDimensionalCoordinates
49+
public struct Coordinates2DOf<CRS>: TwoDimensionalCoordinates
5050
where CRS: TwoDimensionalCRS
5151
{
5252
public typealias X = CRS.CoordinateSystem.Axis1.Value
@@ -71,12 +71,12 @@ where CRS: TwoDimensionalCRS
7171
}
7272

7373
// Zeroable
74-
public extension Coordinates2D {
74+
public extension Coordinates2DOf {
7575
static var zero: Self { Self.init(x: .zero, y: .zero) }
7676
}
7777

7878
// AdditiveArithmetic
79-
public extension Coordinates2D {
79+
public extension Coordinates2DOf {
8080
static func + (lhs: Self, rhs: Self) -> Self {
8181
Self.init(x: lhs.x + rhs.x, y: lhs.y + rhs.y)
8282
}
@@ -85,7 +85,7 @@ public extension Coordinates2D {
8585
}
8686
}
8787
// MultiplicativeArithmetic
88-
public extension Coordinates2D {
88+
public extension Coordinates2DOf {
8989
static func * (lhs: Self, rhs: Self) -> Self {
9090
Self.init(x: lhs.x * rhs.x, y: lhs.y * rhs.y)
9191
}
@@ -95,33 +95,33 @@ public extension Coordinates2D {
9595
}
9696

9797
// InitializableByInteger
98-
public extension Coordinates2D {
98+
public extension Coordinates2DOf {
9999
init<Source: BinaryInteger>(_ value: Source) {
100100
self.init(x: .init(value), y: .init(value))
101101
}
102102
}
103103
// InitializableByFloatingPoint
104-
public extension Coordinates2D {
104+
public extension Coordinates2DOf {
105105
init<Source: BinaryFloatingPoint>(_ value: Source) {
106106
self.init(x: .init(value), y: .init(value))
107107
}
108108
}
109109

110110
// CustomStringConvertible & CustomDebugStringConvertible
111-
public extension Coordinates2D {
111+
public extension Coordinates2DOf {
112112
var description: String { String(describing: self.components) }
113113
var debugDescription: String { String(reflecting: self.components) }
114114
}
115115

116-
public extension Coordinates2D where CRS: GeographicCRS {
116+
public extension Coordinates2DOf where CRS: GeographicCRS {
117117
var latitude: X { self.x }
118118
var longitude: Y { self.y }
119119
init(latitude: X, longitude: Y) {
120120
self.init(x: latitude, y: longitude)
121121
}
122122
}
123123

124-
public extension Coordinates2D
124+
public extension Coordinates2DOf
125125
where CRS: GeographicCRS,
126126
Self.Y: AngularCoordinateComponent
127127
{
@@ -147,7 +147,7 @@ where CRS: ThreeDimensionalCRS
147147
init(x: X, y: Y, z: Z)
148148
}
149149

150-
public struct Coordinates3D<CRS: ThreeDimensionalCRS>: ThreeDimensionalCoordinates {
150+
public struct Coordinates3DOf<CRS: ThreeDimensionalCRS>: ThreeDimensionalCoordinates {
151151
public typealias X = CRS.CoordinateSystem.Axis1.Value
152152
public typealias Y = CRS.CoordinateSystem.Axis2.Value
153153
public typealias Z = CRS.CoordinateSystem.Axis3.Value
@@ -174,12 +174,12 @@ public struct Coordinates3D<CRS: ThreeDimensionalCRS>: ThreeDimensionalCoordinat
174174
}
175175

176176
// Zeroable
177-
public extension Coordinates3D {
177+
public extension Coordinates3DOf {
178178
static var zero: Self { Self.init(x: .zero, y: .zero, z: .zero) }
179179
}
180180

181181
// AdditiveArithmetic
182-
public extension Coordinates3D {
182+
public extension Coordinates3DOf {
183183
static func + (lhs: Self, rhs: Self) -> Self {
184184
Self.init(x: lhs.x + rhs.x, y: lhs.y + rhs.y, z: lhs.z + rhs.z)
185185
}
@@ -188,7 +188,7 @@ public extension Coordinates3D {
188188
}
189189
}
190190
// MultiplicativeArithmetic
191-
public extension Coordinates3D {
191+
public extension Coordinates3DOf {
192192
static func * (lhs: Self, rhs: Self) -> Self {
193193
Self.init(x: lhs.x * rhs.x, y: lhs.y * rhs.y, z: lhs.z * rhs.z)
194194
}
@@ -198,20 +198,20 @@ public extension Coordinates3D {
198198
}
199199

200200
// InitializableByInteger
201-
public extension Coordinates3D {
201+
public extension Coordinates3DOf {
202202
init<Source: BinaryInteger>(_ value: Source) {
203203
self.init(x: .init(value), y: .init(value), z: .init(value))
204204
}
205205
}
206206
// InitializableByFloatingPoint
207-
public extension Coordinates3D {
207+
public extension Coordinates3DOf {
208208
init<Source: BinaryFloatingPoint>(_ value: Source) {
209209
self.init(x: .init(value), y: .init(value), z: .init(value))
210210
}
211211
}
212212

213213
// CustomStringConvertible & CustomDebugStringConvertible
214-
public extension Coordinates3D {
214+
public extension Coordinates3DOf {
215215
var description: String { String(describing: self.components) }
216216
var debugDescription: String { String(reflecting: self.components) }
217217
}
@@ -344,6 +344,7 @@ public enum GeocentricCartesian3DCS: ThreeDimensionalCS, GeocentricCS {
344344
public static let epsgName: String = "Cartesian 3D CS (geocentric)"
345345
public static let epsgCode: Int = 6500
346346
}
347+
public typealias EPSG6500 = GeocentricCartesian3DCS
347348

348349
public enum Ellipsoidal3DCS: ThreeDimensionalCS, GeographicCS {
349350
public typealias Axis1 = GeodeticLatitude
@@ -352,13 +353,15 @@ public enum Ellipsoidal3DCS: ThreeDimensionalCS, GeographicCS {
352353
public static let epsgName: String = "Ellipsoidal 3D CS"
353354
public static let epsgCode: Int = 6423
354355
}
356+
public typealias EPSG6423 = Ellipsoidal3DCS
355357

356358
public enum Ellipsoidal2DCS: TwoDimensionalCS, GeographicCS {
357359
public typealias Axis1 = GeodeticLatitude
358360
public typealias Axis2 = GeodeticLongitude
359361
public static let epsgName: String = "Ellipsoidal 2D CS"
360362
public static let epsgCode: Int = 6422
361363
}
364+
public typealias EPSG6422 = Ellipsoidal2DCS
362365

363366
// MARK: Axes
364367

0 commit comments

Comments
 (0)