Skip to content

Commit 5f1e6ad

Browse files
committed
Fix parameter names in GeodesicLine.
1 parent ee14af2 commit 5f1e6ad

File tree

3 files changed

+37
-23
lines changed

3 files changed

+37
-23
lines changed

README.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,8 +111,10 @@ For efficient calculations of multiple points along a geodesic:
111111
```swift
112112
// Create a geodesic line
113113
let line = geodesic.inverseLine(
114-
latitude1: 40.64, longitude1: -73.78, // JFK
115-
latitude2: 1.36, longitude2: 103.99 // Singapore
114+
startLatitude: 40.64,
115+
startLongitude: -73.78, // JFK
116+
endlatitude: 1.36,
117+
endLongitude: 103.99 // Singapore
116118
)
117119

118120
// Calculate waypoints

Sources/GeographicLib/GeodesicLine.swift

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -202,20 +202,25 @@ public extension Geodesic {
202202
/// Create a geodesic line from an inverse problem.
203203
///
204204
/// - Parameters:
205-
/// - latitude1: First point latitude in degrees [-90, 90]
206-
/// - longitude1: First point longitude in degrees [-180, 180]
207-
/// - latitude2: Second point latitude in degrees [-90, 90]
208-
/// - longitude2: Second point longitude in degrees [-180, 180]
205+
/// - startLatitude: First point latitude in degrees [-90, 90]
206+
/// - startLongitude: First point longitude in degrees [-180, 180]
207+
/// - endLatitude: Second point latitude in degrees [-90, 90]
208+
/// - endLongitude: Second point longitude in degrees [-180, 180]
209209
/// - capabilities: Capabilities for calculations
210210
/// - Returns: A geodesic line connecting the two points
211-
func inverseLine(latitude1: Double, longitude1: Double, latitude2: Double, longitude2: Double,
212-
capabilities: GeodesicCapability = .standard) -> GeodesicLine {
211+
func inverseLine(
212+
startLatitude: Double,
213+
startLongitude: Double,
214+
endLatitude: Double,
215+
endLongitude: Double,
216+
capabilities: GeodesicCapability = .standard
217+
) -> GeodesicLine {
213218
var line = geod_geodesicline()
214219
withUnsafePointer(to: geod) { geodPtr in
215-
geod_inverseline(&line, geodPtr, latitude1, longitude1, latitude2, longitude2, capabilities.rawValue)
220+
geod_inverseline(&line, geodPtr, startLatitude, startLongitude, endLatitude, endLongitude, capabilities.rawValue)
216221
}
217222

218-
var result = GeodesicLine(geodesic: self, latitude: latitude1, longitude: longitude1,
223+
var result = GeodesicLine(geodesic: self, latitude: startLatitude, longitude: startLongitude,
219224
azimuth: 0, capabilities: capabilities)
220225
result.line = line
221226
return result

Tests/GeographicLibTests/GeodesicLineTests.swift

Lines changed: 20 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -57,22 +57,27 @@ struct GeodesicLineTests {
5757
let geodesic = Geodesic()
5858

5959
// JFK to Singapore
60-
let lat1 = 40.64
61-
let lon1 = -73.78
62-
let lat2 = 1.36
63-
let lon2 = 103.99
60+
let startLatitude = 40.64
61+
let startLongitude = -73.78
62+
let endLatitude = 1.36
63+
let endLongitude = 103.99
6464

65-
let line = geodesic.inverseLine(latitude1: lat1, longitude1: lon1, latitude2: lat2, longitude2: lon2)
65+
let line = geodesic.inverseLine(
66+
startLatitude: startLatitude,
67+
startLongitude: startLongitude,
68+
endLatitude: endLatitude,
69+
endLongitude: endLongitude
70+
)
6671

67-
#expect(line.latitude == lat1)
68-
#expect(line.longitude == lon1)
72+
#expect(line.latitude == startLatitude)
73+
#expect(line.longitude == startLongitude)
6974

7075
// The line should connect the two points
7176
let inverseResult = geodesic.inverse(
72-
startLatitude: lat1,
73-
startLongitude: lon1,
74-
endLatitude: lat2,
75-
endLongitude: lon2
77+
startLatitude: startLatitude,
78+
startLongitude: startLongitude,
79+
endLatitude: endLatitude,
80+
endLongitude: endLongitude
7681
)
7782
#expect(abs(line.distance - inverseResult.distance) < 0.001)
7883
#expect(abs(line.azimuth - inverseResult.startAzimuth) < 1e-10)
@@ -84,8 +89,10 @@ struct GeodesicLineTests {
8489

8590
// Create line from JFK to Singapore
8691
let line = geodesic.inverseLine(
87-
latitude1: 40.64, longitude1: -73.78,
88-
latitude2: 1.36, longitude2: 103.99
92+
startLatitude: 40.64,
93+
startLongitude: -73.78,
94+
endLatitude: 1.36,
95+
endLongitude: 103.99
8996
)
9097

9198
// Generate 11 waypoints (0%, 10%, ..., 100%)

0 commit comments

Comments
 (0)