Skip to content

Commit bd8df74

Browse files
committed
Make line a let constant.
1 parent 925e760 commit bd8df74

File tree

1 file changed

+10
-11
lines changed

1 file changed

+10
-11
lines changed

Sources/GeographicLib/GeodesicLine.swift

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import CGeographicLib
1313
/// This struct represents a geodesic starting at a given point with a given azimuth.
1414
/// It allows for efficient computation of points along the geodesic.
1515
public struct GeodesicLine: Sendable {
16-
internal var line: geod_geodesicline
16+
internal let line: geod_geodesicline
1717

1818
// MARK: - Properties
1919

@@ -59,10 +59,15 @@ public struct GeodesicLine: Sendable {
5959
/// - capabilities: Capabilities for calculations (default: standard)
6060
public init(geodesic: Geodesic, latitude: Double, longitude: Double, azimuth: Double,
6161
capabilities: GeodesicCapability = .standard) {
62-
self.line = geod_geodesicline()
62+
var line = geod_geodesicline()
6363
withUnsafePointer(to: geodesic.geod) { geodPtr in
64-
geod_lineinit(&self.line, geodPtr, latitude, longitude, azimuth, capabilities.rawValue)
64+
geod_lineinit(&line, geodPtr, latitude, longitude, azimuth, capabilities.rawValue)
6565
}
66+
self.init(line: line)
67+
}
68+
69+
internal init(line: geod_geodesicline) {
70+
self.line = line
6671
}
6772

6873
// MARK: - Position Methods
@@ -193,10 +198,7 @@ public extension Geodesic {
193198
geod_directline(&line, geodPtr, latitude, longitude, azimuth, distance, capabilities.rawValue)
194199
}
195200

196-
var result = GeodesicLine(geodesic: self, latitude: latitude, longitude: longitude,
197-
azimuth: azimuth, capabilities: capabilities)
198-
result.line = line
199-
return result
201+
return GeodesicLine(line: line)
200202
}
201203

202204
/// Create a geodesic line from an inverse problem.
@@ -220,10 +222,7 @@ public extension Geodesic {
220222
geod_inverseline(&line, geodPtr, startLatitude, startLongitude, endLatitude, endLongitude, capabilities.rawValue)
221223
}
222224

223-
var result = GeodesicLine(geodesic: self, latitude: startLatitude, longitude: startLongitude,
224-
azimuth: 0, capabilities: capabilities)
225-
result.line = line
226-
return result
225+
return GeodesicLine(line: line)
227226
}
228227
}
229228

0 commit comments

Comments
 (0)