Coverage for pygeodesy/geodsolve.py: 98%

83 statements  

« prev     ^ index     » next       coverage.py v7.6.1, created at 2025-01-06 12:20 -0500

1 

2# -*- coding: utf-8 -*- 

3 

4u'''Wrapper to invoke I{Karney}'s U{GeodSolve 

5<https://GeographicLib.SourceForge.io/C++/doc/GeodSolve.1.html>} utility 

6as an (exact) geodesic, but intended I{for testing purposes only}. 

7 

8Set env variable C{PYGEODESY_GEODSOLVE} to the (fully qualified) path 

9of the C{GeodSolve} executable. 

10''' 

11 

12from pygeodesy.basics import _xinstanceof 

13# from pygeodesy.constants import NAN, _0_0 # from .karney 

14# from pygeodesy.geodesicx import GeodesicAreaExact # _MODS 

15from pygeodesy.interns import NN, _UNDER_ 

16from pygeodesy.karney import Caps, GeodesicError, GeodSolve12Tuple, \ 

17 _sincos2d, _Xables, _0_0, NAN 

18from pygeodesy.lazily import _ALL_DOCS, _ALL_LAZY, _ALL_MODS as _MODS 

19from pygeodesy.named import _name1__ 

20from pygeodesy.namedTuples import Destination3Tuple, Distance3Tuple 

21from pygeodesy.props import Property, Property_RO, property_RO 

22from pygeodesy.solveBase import _SolveGDictBase, _SolveGDictLineBase 

23from pygeodesy.utily import _unrollon, _Wrap, wrap360 

24 

25__all__ = _ALL_LAZY.geodsolve 

26__version__ = '24.11.02' 

27 

28 

29class _GeodesicSolveBase(_SolveGDictBase): 

30 '''(INTERNAL) Base class for L{GeodesicSolve} and L{GeodesicLineSolve}. 

31 ''' 

32 _Error = GeodesicError 

33 _Names_Direct = \ 

34 _Names_Inverse = GeodSolve12Tuple._Names_ 

35 _Xable_name = _Xables.GeodSolve.__name__ 

36 _Xable_path = _Xables.GeodSolve() 

37 

38 @Property_RO 

39 def _b_option(self): 

40 return ('-b',) if self.reverse2 else () 

41 

42 @Property_RO 

43 def _cmdBasic(self): 

44 '''(INTERNAL) Get the basic C{GeodSolve} cmd (C{tuple}). 

45 ''' 

46 return (self.GeodSolve, '-f') + (self._b_option + 

47 self._e_option + 

48 self._E_option + 

49 self._p_option + 

50 self._u_option) 

51 

52 @Property 

53 def GeodSolve(self): 

54 '''Get the U{GeodSolve<https://GeographicLib.SourceForge.io/C++/doc/GeodSolve.1.html>} 

55 executable (C{filename}). 

56 ''' 

57 return self._Xable_path 

58 

59 @GeodSolve.setter # PYCHOK setter! 

60 def GeodSolve(self, path): 

61 '''Set the U{GeodSolve<https://GeographicLib.SourceForge.io/C++/doc/GeodSolve.1.html>} 

62 executable (C{filename}), the (fully qualified) path to the C{GeodSolve} executable. 

63 

64 @raise GeodesicError: Invalid B{C{path}}, B{C{path}} doesn't exist or 

65 isn't the C{GeodSolve} executable. 

66 ''' 

67 self._setXable(path) 

68 

69 def toStr(self, **prec_sep): # PYCHOK signature 

70 '''Return this C{GeodesicSolve} as string. 

71 

72 @kwarg prec_sep: Keyword argumens C{B{prec}=6} and C{B{sep}=", "} 

73 for the C{float} C{prec}ision, number of decimal digits 

74 (0..9) and the C{sep}arator string to join. Trailing 

75 zero decimals are stripped for B{C{prec}} values of 1 

76 and above, but kept for negative B{C{prec}} values. 

77 

78 @return: GeodesicSolve items (C{str}). 

79 ''' 

80 return _SolveGDictBase._toStr(self, GeodSolve=self.GeodSolve, **prec_sep) 

81 

82 @Property_RO 

83 def _u_option(self): 

84 return ('-u',) if self.unroll else () 

85 

86 

87class GeodesicSolve(_GeodesicSolveBase): 

88 '''Wrapper to invoke I{Karney}'s U{GeodSolve<https://GeographicLib.SourceForge.io/C++/doc/GeodSolve.1.html>} 

89 as an C{Exact} version of I{Karney}'s Python class U{Geodesic<https://GeographicLib.SourceForge.io/C++/doc/ 

90 python/code.html#geographiclib.geodesic.Geodesic>}. 

91 

92 @note: Use property C{GeodSolve} or env variable C{PYGEODESY_GEODSOLVE} to specify the (fully 

93 qualified) path to the C{GeodSolve} executable. 

94 

95 @note: This C{geodesic} is intended I{for testing purposes only}, it invokes the C{GeodSolve} 

96 executable for I{every} method call. 

97 ''' 

98 

99 def Area(self, polyline=False, **name): 

100 '''Set up a L{GeodesicAreaExact} to compute area and perimeter 

101 of a polygon. 

102 

103 @kwarg polyline: If C{True}, compute the perimeter only, otherwise 

104 perimeter and area (C{bool}). 

105 @kwarg name: Optional C{B{name}=NN} (C{str}). 

106 

107 @return: A L{GeodesicAreaExact} instance. 

108 

109 @note: The B{C{debug}} setting is passed as C{verbose} 

110 to the returned L{GeodesicAreaExact} instance. 

111 ''' 

112 gaX = _MODS.geodesicx.GeodesicAreaExact(self, polyline=polyline, **name) 

113 if self.verbose or self.debug: # PYCHOK no cover 

114 gaX.verbose = True 

115 return gaX 

116 

117 Polygon = Area # for C{geographiclib} compatibility 

118 

119 def Direct3(self, lat1, lon1, azi1, s12): # PYCHOK outmask 

120 '''Return the destination lat, lon and reverse azimuth (final bearing) 

121 in C{degrees}. 

122 

123 @return: L{Destination3Tuple}C{(lat, lon, final)}. 

124 ''' 

125 r = self._GDictDirect(lat1, lon1, azi1, False, s12, floats=False) 

126 return Destination3Tuple(float(r.lat2), float(r.lon2), wrap360(r.azi2), 

127 iteration=r._iteration) 

128 

129 def _DirectLine(self, ll1, azi12, **caps_name): # PYCHOK no cover 

130 '''(INTERNAL) Short-cut version. 

131 ''' 

132 return self.DirectLine(ll1.lat, ll1.lon, azi12, **caps_name) 

133 

134 def DirectLine(self, lat1, lon1, azi1, **caps_name): 

135 '''Set up a L{GeodesicLineSolve} to compute several points 

136 on a single geodesic. 

137 

138 @arg lat1: Latitude of the first point (C{degrees}). 

139 @arg lon1: Longitude of the first point (C{degrees}). 

140 @arg azi1: Azimuth at the first point (compass C{degrees}). 

141 @kwarg caps_name: Optional C{B{name}=NN} (C{str}) and keyword 

142 argument C{B{caps}=Caps.ALL}, bit-or'ed combination 

143 of L{Caps} values specifying the capabilities the 

144 L{GeodesicLineSolve} instance should possess. 

145 

146 @return: A L{GeodesicLineSolve} instance. 

147 

148 @note: If the point is at a pole, the azimuth is defined by keeping 

149 B{C{lon1}} fixed, writing C{B{lat1} = ±(90 − ε)}, and taking 

150 the limit C{ε → 0+}. 

151 

152 @see: C++ U{GeodesicExact.Line 

153 <https://GeographicLib.SourceForge.io/C++/doc/classGeographicLib_1_1GeodesicExact.html>} 

154 and Python U{Geodesic.Line<https://GeographicLib.SourceForge.io/Python/doc/code.html>}. 

155 ''' 

156 return GeodesicLineSolve(self, lat1, lon1, azi1, **_name1__(caps_name, _or_nameof=self)) 

157 

158 Line = DirectLine 

159 

160 def _Inverse(self, ll1, ll2, wrap, **outmask): # PYCHOK no cover 

161 '''(INTERNAL) Short-cut version, see .ellipsoidalBaseDI.intersecant2. 

162 ''' 

163 if wrap: 

164 ll2 = _unrollon(ll1, _Wrap.point(ll2)) 

165 return self.Inverse(ll1.lat, ll1.lon, ll2.lat, ll2.lon, **outmask) 

166 

167 def Inverse3(self, lat1, lon1, lat2, lon2): # PYCHOK outmask 

168 '''Return the distance in C{meter} and the forward and 

169 reverse azimuths (initial and final bearing) in C{degrees}. 

170 

171 @return: L{Distance3Tuple}C{(distance, initial, final)}. 

172 ''' 

173 r = self._GDictInverse(lat1, lon1, lat2, lon2, floats=False) 

174 return Distance3Tuple(float(r.s12), wrap360(r.azi1), wrap360(r.azi2), 

175 iteration=r._iteration) 

176 

177 def _InverseLine(self, ll1, ll2, wrap, **caps_name): # PYCHOK no cover 

178 '''(INTERNAL) Short-cut version. 

179 ''' 

180 if wrap: 

181 ll2 = _unrollon(ll1, _Wrap.point(ll2)) 

182 return self.InverseLine(ll1.lat, ll1.lon, ll2.lat, ll2.lon, **caps_name) 

183 

184 def InverseLine(self, lat1, lon1, lat2, lon2, **caps_name): # PYCHOK no cover 

185 '''Set up a L{GeodesicLineSolve} to compute several points 

186 on a single geodesic. 

187 

188 @arg lat1: Latitude of the first point (C{degrees}). 

189 @arg lon1: Longitude of the first point (C{degrees}). 

190 @arg lat2: Latitude of the second point (C{degrees}). 

191 @arg lon2: Longitude of the second point (C{degrees}). 

192 @kwarg caps_name: Optional C{B{name}=NN} (C{str}) and keyword 

193 argument C{B{caps}=Caps.ALL}, bit-or'ed combination 

194 of L{Caps} values specifying the capabilities the 

195 L{GeodesicLineSolve} instance should possess. 

196 

197 @return: A L{GeodesicLineSolve} instance. 

198 

199 @note: Both B{C{lat1}} and B{C{lat2}} should in the range C{[-90, +90]}. 

200 

201 @see: C++ U{GeodesicExact.InverseLine 

202 <https://GeographicLib.SourceForge.io/C++/doc/classGeographicLib_1_1GeodesicExact.html>} and 

203 Python U{Geodesic.InverseLine<https://GeographicLib.SourceForge.io/Python/doc/code.html>}. 

204 ''' 

205 r = self.Inverse(lat1, lon1, lat2, lon2) 

206 gl = GeodesicLineSolve(self, lat1, lon1, r.azi1, **_name1__(caps_name, _or_nameof=self)) 

207 gl._a13 = r.a12 # gl.SetArc(r.a12) 

208 gl._s13 = r.s12 # gl.SetDistance(r.s12) 

209 return gl 

210 

211 

212class GeodesicLineSolve(_GeodesicSolveBase, _SolveGDictLineBase): 

213 '''Wrapper to invoke I{Karney}'s U{GeodSolve<https://GeographicLib.SourceForge.io/C++/doc/GeodSolve.1.html>} 

214 as an C{Exact} version of I{Karney}'s Python class U{GeodesicLine<https://GeographicLib.SourceForge.io/C++/doc/ 

215 python/code.html#geographiclib.geodesicline.GeodesicLine>}. 

216 

217 @note: Use property C{GeodSolve} or env variable C{PYGEODESY_GEODSOLVE} to specify the (fully 

218 qualified) path to the C{GeodSolve} executable. 

219 

220 @note: This C{geodesic} is intended I{for testing purposes only}, it invokes the C{GeodSolve} 

221 executable for I{every} method call. 

222 ''' 

223 _a13 = \ 

224 _s13 = NAN # see GeodesicSolve._InverseLine 

225 

226 def __init__(self, geodesic, lat1, lon1, azi1, caps=Caps.ALL, **name): 

227 '''New L{GeodesicLineSolve} instance, allowing points to be found along 

228 a geodesic starting at C{(B{lat1}, B{lon1})} with azimuth B{C{azi1}}. 

229 

230 @arg geodesic: The geodesic to use (L{GeodesicSolve}). 

231 @arg lat1: Latitude of the first point (C{degrees}). 

232 @arg lon1: Longitude of the first point (C{degrees}). 

233 @arg azi1: Azimuth at the first points (compass C{degrees}). 

234 @kwarg caps: Bit-or'ed combination of L{Caps} values specifying the 

235 capabilities the L{GeodesicLineSolve} instance should possess, 

236 C{B{caps}=Caps.ALL} always. Include C{Caps.LINE_OFF} if 

237 updates to the B{C{geodesic}} should I{not} be reflected in 

238 this L{GeodesicLineSolve} instance. 

239 @kwarg name: Optional C{B{name}=NN} (C{str}). 

240 

241 @raise GeodesicError: Invalid path for the C{GeodSolve} executable 

242 or isn't the C{GeodSolve} executable, see 

243 property C{geodesic.GeodSolve}. 

244 

245 @raise TypeError: Invalid B{C{geodesic}}. 

246 ''' 

247 _xinstanceof(GeodesicSolve, geodesic=geodesic) 

248 if (caps & Caps.LINE_OFF): # copy to avoid updates 

249 geodesic = geodesic.copy(deep=False, name=_UNDER_(NN, geodesic.name)) # NOT _under! 

250 _SolveGDictLineBase.__init__(self, geodesic, lat1, lon1, caps, azi1=azi1, **name) 

251 try: 

252 self.GeodSolve = geodesic.GeodSolve # geodesic or copy of geodesic 

253 except GeodesicError: 

254 pass 

255 

256 @Property_RO 

257 def a13(self): 

258 '''Get the arc length to reference point 3 (C{degrees}). 

259 

260 @see: Methods L{Arc} and L{SetArc}. 

261 ''' 

262 return self._a13 

263 

264 def Arc(self): # PYCHOK no cover 

265 '''Return the arc length to reference point 3 (C{degrees} or C{NAN}). 

266 

267 @see: Method L{SetArc} and property L{a13}. 

268 ''' 

269 return self.a13 

270 

271 def ArcPosition(self, a12, outmask=Caps.STANDARD): # PYCHOK no cover 

272 '''Find the position on the line given B{C{a12}}. 

273 

274 @arg a12: Spherical arc length from the first point to the 

275 second point (C{degrees}). 

276 

277 @return: A C{GDict} with 12 items C{lat1, lon1, azi1, lat2, lon2, 

278 azi2, m12, a12, s12, M12, M21, S12}. 

279 ''' 

280 return self._GDictInvoke(self._cmdArc, self._Names_Direct, a12)._unCaps(outmask) 

281 

282 @Property_RO 

283 def azi1(self): 

284 '''Get the azimuth at the first point (compass C{degrees}). 

285 ''' 

286 return self._lla1.azi1 

287 

288 azi12 = azi1 # like RhumbLineSolve 

289 

290 @Property_RO 

291 def azi1_sincos2(self): 

292 '''Get the sine and cosine of the first point's azimuth (2-tuple C{(sin, cos)}). 

293 ''' 

294 return _sincos2d(self.azi1) 

295 

296 azi12_sincos2 = azi1_sincos2 

297 

298 @Property_RO 

299 def _cmdArc(self): 

300 '''(INTERNAL) Get the C{GeodSolve} I{-a -L} cmd (C{tuple}). 

301 ''' 

302 return self._cmdDistance + ('-a',) 

303 

304 def Distance(self): 

305 '''Return the distance to reference point 3 (C{meter} or C{NAN}). 

306 ''' 

307 return self.s13 

308 

309 @property_RO 

310 def geodesic(self): 

311 '''Get the geodesic (L{GeodesicSolve}). 

312 ''' 

313 return self._solve # see .solveBase._SolveLineBase 

314 

315 def Intersecant2(self, lat0, lon0, radius, **kwds): # PYCHOK no cover 

316 '''B{Not implemented}, throws a C{NotImplementedError} always.''' 

317 self._notImplemented(lat0, lon0, radius, **kwds) 

318 

319 def PlumbTo(self, lat0, lon0, **kwds): # PYCHOK no cover 

320 '''B{Not implemented}, throws a C{NotImplementedError} always.''' 

321 self._notImplemented(lat0, lon0, **kwds) 

322 

323 def Position(self, s12, outmask=Caps.STANDARD): 

324 '''Find the position on the line given B{C{s12}}. 

325 

326 @arg s12: Distance from the first point to the second (C{meter}). 

327 

328 @return: A C{GDict} with 12 items C{lat1, lon1, azi1, lat2, lon2, 

329 azi2, m12, a12, s12, M12, M21, S12}, possibly C{a12=NAN}. 

330 ''' 

331 return self._GDictInvoke(self._cmdDistance, self._Names_Direct, s12)._unCaps(outmask) 

332 

333 @Property_RO 

334 def s13(self): 

335 '''Get the distance to reference point 3 (C{meter} or C{NAN}). 

336 

337 @see: Methods L{Distance} and L{SetDistance}. 

338 ''' 

339 return self._s13 

340 

341 def SetArc(self, a13): # PYCHOK no cover 

342 '''Set reference point 3 in terms relative to the first point. 

343 

344 @arg a13: Spherical arc length from the first to the reference 

345 point (C{degrees}). 

346 

347 @return: The distance C{s13} (C{meter}) between the first and 

348 the reference point or C{NAN}. 

349 ''' 

350 if self._a13 != a13: 

351 self._a13 = a13 

352 self._s13 = self.ArcPosition(a13, outmask=Caps.DISTANCE).s12 # if a13 else _0_0 

353# _update_all(self) 

354 return self._s13 

355 

356 def SetDistance(self, s13): # PYCHOK no cover 

357 '''Set reference point 3 in terms relative to the first point. 

358 

359 @arg s13: Distance from the first to the reference point (C{meter}). 

360 

361 @return: The arc length C{a13} (C{degrees}) between the first and 

362 the reference point or C{NAN}. 

363 ''' 

364 if self._s13 != s13: 

365 self._s13 = s13 

366 self._a13 = self.Position(s13, outmask=Caps.DISTANCE).a12 if s13 else _0_0 

367# _update_all(self) 

368 return self._a13 # NAN for GeodesicLineExact without Cap.DISTANCE_IN 

369 

370 def toStr(self, **prec_sep): # PYCHOK signature 

371 '''Return this C{GeodesicLineSolve} as string. 

372 

373 @kwarg prec_sep: Keyword argumens C{B{prec}=6} and C{B{sep}=", "} 

374 for the C{float} C{prec}ision, number of decimal digits 

375 (0..9) and the C{sep}arator string to join. Trailing 

376 zero decimals are stripped for B{C{prec}} values of 1 

377 and above, but kept for negative B{C{prec}} values. 

378 

379 @return: GeodesicLineSolve items (C{str}). 

380 ''' 

381 return _SolveGDictLineBase._toStr(self, azi1=self.azi1, geodesic=self._solve, 

382 GeodSolve=self.GeodSolve, **prec_sep) 

383 

384 

385__all__ += _ALL_DOCS(_GeodesicSolveBase) 

386 

387if __name__ == '__main__': 

388 

389 def _main(): 

390 from pygeodesy import printf 

391 from sys import argv 

392 

393 gS = GeodesicSolve(name='Test') 

394 gS.verbose = '--verbose' in argv # or '-v' in argv 

395 

396 if not _Xables.X_OK(gS.GeodSolve): # not set 

397 gS.GeodSolve = _Xables.GeodSolve(_Xables.bin_) 

398 printf('version: %s', gS.version) 

399 

400 r = gS.Direct(40.6, -73.8, 51, 5.5e6) 

401 printf('Direct: %r', r, nl=1) 

402 printf('Direct3: %r', gS.Direct3(40.6, -73.8, 51, 5.5e6)) 

403 

404 printf('Inverse: %r', gS.Inverse( 40.6, -73.8, 51.6, -0.5), nl=1) 

405 printf('Inverse1: %r', gS.Inverse1(40.6, -73.8, 51.6, -0.5)) 

406 printf('Inverse3: %r', gS.Inverse3(40.6, -73.8, 51.6, -0.5)) 

407 

408 glS = GeodesicLineSolve(gS, 40.6, -73.8, 51, name='LineTest') 

409 p = glS.Position(5.5e6) 

410 printf('Position: %5s %r', p == r, p, nl=1) 

411 p = glS.ArcPosition(49.475527) 

412 printf('ArcPosition: %5s %r', p == r, p) 

413 

414 _main() 

415 

416# % python3 -m pygeodesy.geodsolve 

417 

418# version: /opt/local/bin/GeodSolve: GeographicLib version 2.2 

419 

420# Direct: GDict(a12=49.475527, azi1=51.0, azi2=107.189397, lat1=40.6, lat2=51.884565, lon1=-73.8, lon2=-1.141173, m12=4844148.703101, M12=0.650911, M21=0.651229, s12=5500000.0, S12=39735075134877.09375) 

421# Direct3: Destination3Tuple(lat=51.884565, lon=-1.141173, final=107.189397) 

422 

423# Inverse: GDict(a12=49.94131, azi1=51.198883, azi2=107.821777, lat1=40.6, lat2=51.6, lon1=-73.8, lon2=-0.5, m12=4877684.602706, M12=0.64473, M21=0.645046, s12=5551759.400319, S12=40041368848742.53125) 

424# Inverse1: 49.94131021789904 

425# Inverse3: Distance3Tuple(distance=5551759.400319, initial=51.198883, final=107.821777) 

426 

427# Position: True GDict(a12=49.475527, azi1=51.0, azi2=107.189397, lat1=40.6, lat2=51.884565, lon1=-73.8, lon2=-1.141173, m12=4844148.703101, M12=0.650911, M21=0.651229, s12=5500000.0, S12=39735075134877.09375) 

428# ArcPosition: False GDict(a12=49.475527, azi1=51.0, azi2=107.189397, lat1=40.6, lat2=51.884565, lon1=-73.8, lon2=-1.141174, m12=4844148.669561, M12=0.650911, M21=0.651229, s12=5499999.948497, S12=39735074737272.734375) 

429 

430 

431# % python3 -m pygeodesy.geodsolve 

432 

433# version: /opt/local/bin/GeodSolve: GeographicLib version 2.3 

434 

435# Direct: GDict(a12=49.475527, azi1=51.0, azi2=107.189397, lat1=40.6, lat2=51.884565, lon1=-73.8, lon2=-1.141173, m12=4844148.703101, M12=0.650911, M21=0.651229, s12=5500000.0, S12=39735075134877.078125) 

436# Direct3: Destination3Tuple(lat=51.884565, lon=-1.141173, final=107.189397) 

437 

438# Inverse: GDict(a12=49.94131, azi1=51.198883, azi2=107.821777, lat1=40.6, lat2=51.6, lon1=-73.8, lon2=-0.5, m12=4877684.602706, M12=0.64473, M21=0.645046, s12=5551759.400319, S12=40041368848742.53125) 

439# Inverse1: 49.94131021789904 

440# Inverse3: Distance3Tuple(distance=5551759.400319, initial=51.198883, final=107.821777) 

441 

442# Position: False GDict(a12=49.475527, azi1=51.0, azi2=107.189397, lat1=40.6, lat2=51.884565, lon1=-73.8, lon2=-1.141173, s12=5500000.0) 

443# ArcPosition: False GDict(a12=49.475527, azi1=51.0, azi2=107.189397, lat1=40.6, lat2=51.884565, lon1=-73.8, lon2=-1.141174, s12=5499999.948497) 

444 

445 

446# % python3 -m pygeodesy.geodsolve --verbose 

447 

448# GeodesicSolve 'Test' 1: /opt/local/bin/GeodSolve --version (invoke) 

449# GeodesicSolve 'Test' 1: /opt/local/bin/GeodSolve: GeographicLib version 2.2 (0) 

450# version: /opt/local/bin/GeodSolve: GeographicLib version 2.2 

451# GeodesicSolve 'Test' 2: /opt/local/bin/GeodSolve -f -E -p 10 \ 40.600000000000001 -73.799999999999997 51.0 5500000.0 (Direct) 

452# GeodesicSolve 'Test' 2: lat1=40.600000000000001, lon1=-73.799999999999997, azi1=51.0, lat2=51.884564505606761, lon2=-1.141172861200829, azi2=107.189397162605886, s12=5500000.0, a12=49.475527463251467, m12=4844148.703101486, M12=0.65091056699808603, M21=0.65122865892196558, S12=39735075134877.094 (0) 

453 

454# Direct: GDict(a12=49.475527, azi1=51.0, azi2=107.189397, lat1=40.6, lat2=51.884565, lon1=-73.8, lon2=-1.141173, m12=4844148.703101, M12=0.650911, M21=0.651229, s12=5500000.0, S12=39735075134877.09375) 

455# GeodesicSolve 'Test' 3: /opt/local/bin/GeodSolve -f -E -p 10 \ 40.600000000000001 -73.799999999999997 51.0 5500000.0 (Direct3) 

456# GeodesicSolve 'Test' 3: lat1=40.600000000000001, lon1=-73.799999999999997, azi1=51.0, lat2=51.884564505606761, lon2=-1.141172861200829, azi2=107.189397162605886, s12=5500000.0, a12=49.475527463251467, m12=4844148.703101486, M12=0.65091056699808603, M21=0.65122865892196558, S12=39735075134877.094 (0) 

457# Direct3: Destination3Tuple(lat=51.884565, lon=-1.141173, final=107.189397) 

458# GeodesicSolve 'Test' 4: /opt/local/bin/GeodSolve -f -E -p 10 -i \ 40.600000000000001 -73.799999999999997 51.600000000000001 -0.5 (Inverse) 

459# GeodesicSolve 'Test' 4: lat1=40.600000000000001, lon1=-73.799999999999997, azi1=51.198882845579824, lat2=51.600000000000001, lon2=-0.5, azi2=107.821776735514248, s12=5551759.4003186841, a12=49.941310217899037, m12=4877684.6027061976, M12=0.64472969205948238, M21=0.64504567852134398, S12=40041368848742.531 (0) 

460 

461# Inverse: GDict(a12=49.94131, azi1=51.198883, azi2=107.821777, lat1=40.6, lat2=51.6, lon1=-73.8, lon2=-0.5, m12=4877684.602706, M12=0.64473, M21=0.645046, s12=5551759.400319, S12=40041368848742.53125) 

462# GeodesicSolve 'Test' 5: /opt/local/bin/GeodSolve -f -E -p 10 -i \ 40.600000000000001 -73.799999999999997 51.600000000000001 -0.5 (Inverse1) 

463# GeodesicSolve 'Test' 5: lat1=40.600000000000001, lon1=-73.799999999999997, azi1=51.198882845579824, lat2=51.600000000000001, lon2=-0.5, azi2=107.821776735514248, s12=5551759.4003186841, a12=49.941310217899037, m12=4877684.6027061976, M12=0.64472969205948238, M21=0.64504567852134398, S12=40041368848742.531 (0) 

464# Inverse1: 49.94131021789904 

465# GeodesicSolve 'Test' 6: /opt/local/bin/GeodSolve -f -E -p 10 -i \ 40.600000000000001 -73.799999999999997 51.600000000000001 -0.5 (Inverse3) 

466# GeodesicSolve 'Test' 6: lat1=40.600000000000001, lon1=-73.799999999999997, azi1=51.198882845579824, lat2=51.600000000000001, lon2=-0.5, azi2=107.821776735514248, s12=5551759.4003186841, a12=49.941310217899037, m12=4877684.6027061976, M12=0.64472969205948238, M21=0.64504567852134398, S12=40041368848742.531 (0) 

467# Inverse3: Distance3Tuple(distance=5551759.400319, initial=51.198883, final=107.821777) 

468 

469# Position: True GDict(a12=49.475527, azi1=51.0, azi2=107.189397, lat1=40.6, lat2=51.884565, lon1=-73.8, lon2=-1.141173, m12=4844148.703101, M12=0.650911, M21=0.651229, s12=5500000.0, S12=39735075134877.09375) 

470# ArcPosition: False GDict(a12=49.475527, azi1=51.0, azi2=107.189397, lat1=40.6, lat2=51.884565, lon1=-73.8, lon2=-1.141174, m12=4844148.669561, M12=0.650911, M21=0.651229, s12=5499999.948497, S12=39735074737272.734375) 

471 

472 

473# % python3 -m pygeodesy.geodsolve --verbose 

474 

475# GeodesicSolve 'Test'@1: /opt/local/bin/GeodSolve --version (invoke) 

476# GeodesicSolve 'Test'@1: '/opt/local/bin/GeodSolve: GeographicLib version 2.3' (0, stdout/-err) 

477# GeodesicSolve 'Test'@1: /opt/local/bin/GeodSolve: GeographicLib version 2.3 (0) 

478# version: /opt/local/bin/GeodSolve: GeographicLib version 2.3 

479# GeodesicSolve 'Test'@2: /opt/local/bin/GeodSolve -f -E -p 10 \ 40.600000000000001 -73.799999999999997 51.0 5500000.0 (Direct) 

480# GeodesicSolve 'Test'@2: '40.600000000000001 -73.799999999999997 51.000000000000000 51.884564505606761 -1.141172861200843 107.189397162605871 5500000.0000000000 49.475527463251460 4844148.7031014860 0.65091056699808614 0.65122865892196569 39735075134877.078' (0, stdout/-err) 

481# GeodesicSolve 'Test'@2: lat1=40.600000000000001, lon1=-73.799999999999997, azi1=51.0, lat2=51.884564505606761, lon2=-1.141172861200843, azi2=107.189397162605871, s12=5500000.0, a12=49.47552746325146, m12=4844148.703101486, M12=0.65091056699808614, M21=0.65122865892196569, S12=39735075134877.078 (0) 

482 

483# Direct: GDict(a12=49.475527, azi1=51.0, azi2=107.189397, lat1=40.6, lat2=51.884565, lon1=-73.8, lon2=-1.141173, m12=4844148.703101, M12=0.650911, M21=0.651229, s12=5500000.0, S12=39735075134877.078125) 

484# GeodesicSolve 'Test'@3: /opt/local/bin/GeodSolve -f -E -p 10 \ 40.600000000000001 -73.799999999999997 51.0 5500000.0 (Direct3) 

485# GeodesicSolve 'Test'@3: '40.600000000000001 -73.799999999999997 51.000000000000000 51.884564505606761 -1.141172861200843 107.189397162605871 5500000.0000000000 49.475527463251460 4844148.7031014860 0.65091056699808614 0.65122865892196569 39735075134877.078' (0, stdout/-err) 

486# GeodesicSolve 'Test'@3: lat1=40.600000000000001, lon1=-73.799999999999997, azi1=51.0, lat2=51.884564505606761, lon2=-1.141172861200843, azi2=107.189397162605871, s12=5500000.0, a12=49.47552746325146, m12=4844148.703101486, M12=0.65091056699808614, M21=0.65122865892196569, S12=39735075134877.078 (0) 

487# Direct3: Destination3Tuple(lat=51.884565, lon=-1.141173, final=107.189397) 

488# GeodesicSolve 'Test'@4: /opt/local/bin/GeodSolve -f -E -p 10 -i \ 40.600000000000001 -73.799999999999997 51.600000000000001 -0.5 (Inverse) 

489# GeodesicSolve 'Test'@4: '40.600000000000001 -73.799999999999997 51.198882845579824 51.600000000000001 -0.500000000000000 107.821776735514248 5551759.4003186813 49.941310217899037 4877684.6027061967 0.64472969205948238 0.64504567852134398 40041368848742.531' (0, stdout/-err) 

490# GeodesicSolve 'Test'@4: lat1=40.600000000000001, lon1=-73.799999999999997, azi1=51.198882845579824, lat2=51.600000000000001, lon2=-0.5, azi2=107.821776735514248, s12=5551759.4003186813, a12=49.941310217899037, m12=4877684.6027061967, M12=0.64472969205948238, M21=0.64504567852134398, S12=40041368848742.531 (0) 

491 

492# Inverse: GDict(a12=49.94131, azi1=51.198883, azi2=107.821777, lat1=40.6, lat2=51.6, lon1=-73.8, lon2=-0.5, m12=4877684.602706, M12=0.64473, M21=0.645046, s12=5551759.400319, S12=40041368848742.53125) 

493# GeodesicSolve 'Test'@5: /opt/local/bin/GeodSolve -f -E -p 10 -i \ 40.600000000000001 -73.799999999999997 51.600000000000001 -0.5 (Inverse1) 

494# GeodesicSolve 'Test'@5: '40.600000000000001 -73.799999999999997 51.198882845579824 51.600000000000001 -0.500000000000000 107.821776735514248 5551759.4003186813 49.941310217899037 4877684.6027061967 0.64472969205948238 0.64504567852134398 40041368848742.531' (0, stdout/-err) 

495# GeodesicSolve 'Test'@5: lat1=40.600000000000001, lon1=-73.799999999999997, azi1=51.198882845579824, lat2=51.600000000000001, lon2=-0.5, azi2=107.821776735514248, s12=5551759.4003186813, a12=49.941310217899037, m12=4877684.6027061967, M12=0.64472969205948238, M21=0.64504567852134398, S12=40041368848742.531 (0) 

496# Inverse1: 49.94131021789904 

497# GeodesicSolve 'Test'@6: /opt/local/bin/GeodSolve -f -E -p 10 -i \ 40.600000000000001 -73.799999999999997 51.600000000000001 -0.5 (Inverse3) 

498# GeodesicSolve 'Test'@6: '40.600000000000001 -73.799999999999997 51.198882845579824 51.600000000000001 -0.500000000000000 107.821776735514248 5551759.4003186813 49.941310217899037 4877684.6027061967 0.64472969205948238 0.64504567852134398 40041368848742.531' (0, stdout/-err) 

499# GeodesicSolve 'Test'@6: lat1=40.600000000000001, lon1=-73.799999999999997, azi1=51.198882845579824, lat2=51.600000000000001, lon2=-0.5, azi2=107.821776735514248, s12=5551759.4003186813, a12=49.941310217899037, m12=4877684.6027061967, M12=0.64472969205948238, M21=0.64504567852134398, S12=40041368848742.531 (0) 

500# Inverse3: Distance3Tuple(distance=5551759.400319, initial=51.198883, final=107.821777) 

501 

502# Position: False GDict(a12=49.475527, azi1=51.0, azi2=107.189397, lat1=40.6, lat2=51.884565, lon1=-73.8, lon2=-1.141173, s12=5500000.0) 

503# ArcPosition: False GDict(a12=49.475527, azi1=51.0, azi2=107.189397, lat1=40.6, lat2=51.884565, lon1=-73.8, lon2=-1.141174, s12=5499999.948497) 

504 

505# **) MIT License 

506# 

507# Copyright (C) 2016-2025 -- mrJean1 at Gmail -- All Rights Reserved. 

508# 

509# Permission is hereby granted, free of charge, to any person obtaining a 

510# copy of this software and associated documentation files (the "Software"), 

511# to deal in the Software without restriction, including without limitation 

512# the rights to use, copy, modify, merge, publish, distribute, sublicense, 

513# and/or sell copies of the Software, and to permit persons to whom the 

514# Software is furnished to do so, subject to the following conditions: 

515# 

516# The above copyright notice and this permission notice shall be included 

517# in all copies or substantial portions of the Software. 

518# 

519# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 

520# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 

521# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 

522# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR 

523# OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 

524# ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 

525# OTHER DEALINGS IN THE SOFTWARE.