1

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

3

4 u'''A pure Python implementation of geodesy tools for various ellipsoidal and spherical earth

5 models using precision trigonometric, vector-based, exact, elliptic, iterative and approximate

6 methods for geodetic (lat-/longitude) and geocentric (U{ECEF<https://WikiPedia.org/wiki/ECEF>}

7 cartesian) coordinates.

8

9 Transcoded from U{JavaScript originals<https://GitHub.com/ChrisVeness/geodesy>} by I{Chris Veness

10(C) 2005-2022} and from several U{C++ classes<https://GeographicLib.SourceForge.io/C++/doc/annotated.html>}

11 by I{Charles F.F. Karney (C) 2008-2022} and published under the same U{MIT License

12<https://OpenSource.org/licenses/MIT>}**.

13

14 There are four modules for ellipsoidal earth models, C{ellipsoidalExact}, C{-Karney},

15 C{-Vincenty} and C{-Nvector} and two for spherical ones, C{sphericalTrigonometry}

16 and C{-Nvector}. Each module provides a geodetic B{C{LatLon}} and a geocentric

17 B{C{Cartesian}} class with methods and functions to compute distance, surface area,

18 perimeter, initial and final bearing, intermediate and nearest points, circle intersections

19 and secants, path intersections, 3-point resections, rhumb and rhumb lines, trilateration (by

20 intersection, by overlap and in 3d), conversions and unrolling, among other things. For more

21 information and further details see the U{documentation<https://mrJean1.GitHub.io/PyGeodesy>},

22 the descriptions of U{Latitude/Longitude<https://www.Movable-Type.co.UK/scripts/latlong.html>},

23 U{Vincenty<https://www.Movable-Type.co.UK/scripts/latlong-vincenty.html>} and

24 U{Vector-based<https://www.Movable-Type.co.UK/scripts/latlong-vectors.html>} geodesy,

25 the original U{JavaScript source<https://GitHub.com/ChrisVeness/geodesy>} or

26 U{docs<https://www.Movable-Type.co.UK/scripts/geodesy/docs>} and I{Karney}'s Python

27 U{geographiclib<https://PyPI.org/project/geographiclib>} and U{C++ GeographicLib

28<https://GeographicLib.SourceForge.io/C++/doc/index.html>}.

29

30 Also included are modules for conversions to and from U{Cassini-Soldner

31<https://GeographicLib.SourceForge.io/C++/doc/classGeographicLib_1_1CassiniSoldner.html>},

32 U{ECEF<https://WikiPedia.org/wiki/ECEF>} (Earth-Centered, Earth-Fixed cartesian), U{UTM

33<https://www.Movable-Type.co.UK/scripts/latlong-utm-mgrs.html>} (Universal Transverse Mercator

34 and U{Exact<https://GeographicLib.SourceForge.io/C++/doc/classGeographicLib_1_1TransverseMercatorExact.html>}),

35 U{UPS<https://WikiPedia.org/wiki/Universal_polar_stereographic_coordinate_system>} (Universal Polar

36 Stereographic) and U{Web Mercator<https://WikiPedia.org/wiki/Web_Mercator>} (Pseudo-Mercator) coordinates,

37 U{MGRS<https://GeographicLib.SourceForge.io/C++/doc/classGeographicLib_1_1MGRS.html>} (Military Grid Reference

38 System, UTM I{and} UPS) and U{OSGR<https://www.Movable-Type.co.UK/scripts/latlong-os-gridref.html>} (British

39 Ordinance Survery Grid Reference) grid references, U{TRF<http://ITRF.ENSG.IGN.Fr>} (Terrestrial Reference

40 Frames) and modules to encode and decode U{EPSG<https://EPSG.org>}, U{Geohashes

41<https://www.Movable-Type.co.UK/scripts/geohash.html>}, U{Georefs (WGRS)

42<https://WikiPedia.org/wiki/World_Geographic_Reference_System>} and U{Garefs (GARS)

43<https://WikiPedia.org/wiki/Global_Area_Reference_System>}.

44

45 Other modules provide U{Albers equal-area<https://GeographicLib.SourceForge.io/

46 html/classGeographicLib_1_1AlbersEqualArea.html>} projections, U{equidistant

47<https://GeographicLib.SourceForge.io/C++/doc/classGeographicLib_1_1AzimuthalEquidistant.html>}

48 and other I{azimuthal} projections, Lambert I{conformal conic} projections and

49 positions, functions to clip paths or polygons of C{LatLon} points using the

50 U{Cohen-Sutherland<https://WikiPedia.org/wiki/Cohen-Sutherland_algorithm>},

51 U{Forster-Hormann-Popa<https://www.ScienceDirect.com/science/article/pii/S259014861930007X>},

52 U{Greiner-Hormann<http://www.inf.USI.CH/hormann/papers/Greiner.1998.ECO.pdf>},

53 U{Liang-Barsky<https://www.CS.Helsinki.FI/group/goa/viewing/leikkaus/intro.html>} and

54 U{Sutherland-Hodgman<https://WikiPedia.org/wiki/Sutherland-Hodgman_algorithm>} methods,

55 functions to U{simplify<https://Bost.Ocks.org/mike/simplify>} or linearize a path of C{LatLon}

56 points (or a U{NumPy array<https://docs.SciPy.org/doc/numpy/reference/generated/numpy.array.html>}),

57 including implementations of the U{Ramer-Douglas-Peucker<https://WikiPedia.org/wiki/

58 Ramer-Douglas-Peucker_algorithm>}, the U{Visvalingam-Whyatt<https://hydra.Hull.ac.UK/

59 resources/hull:8338>} and the U{Reumann-Witkam<https://psimpl.SourceForge.net/reumann-witkam.html>}

60 algorithms and modified versions of the former. Other classes provide I{boolean} operations between

61(composite) polygons or U{interpolate <https://docs.SciPy.org/doc/scipy/reference/interpolate.html>}

62 the L{height<pygeodesy.heights>} of C{LatLon} points and L{Geoid<pygeodesy.geoids>} models or

63 compute various U{Fréchet<https://WikiPedia.org/wiki/Frechet_distance>} or U{Hausdorff

64<https://WikiPedia.org/wiki/Hausdorff_distance>} distances.

65

66 Installation

67============

68

69 To install PyGeodesy, type C{python[3] -m pip install PyGeodesy} or C{python[3] -m easy_install

70 PyGeodesy} in a terminal or command window.

71

72 Alternatively, download C{PyGeodesy-yy.m.d.zip} from U{PyPI<https://PyPI.org/project/PyGeodesy>}

73 or U{GitHub<https://GitHub.com/mrJean1/PyGeodesy>}, C{unzip} the downloaded file, C{cd} to

74 directory C{Pygeodesy-yy.m.d} and type C{python[3] setup.py install}.

75

76 To run all PyGeodesy tests, type C{python[3] setup.py test} or type C{python[3]

77 test/run.py} or type C{python[3] test/unitTestSuite.py} before or after installation.

78

79 Dependencies

80============

81

82 Installation of I{Karney}'s Python package U{geographiclib<https://PyPI.org/project/geographiclib>}

83 is optional, but required to use modules L{ellipsoidalKarney} and L{css}, L{azimuthal} classes

84 L{EquidistantKarney} and L{GnomonicKarney} and the L{HeightIDWkarney} interpolator.

85

86 Both U{numpy<https://PyPI.org/project/numpy>} and U{scipy<https://PyPI.org/project/scipy>} must be

87 installed for most L{Geoid...<pygeodesy.geoids>} and L{Height...<pygeodesy.heights>} interpolators,

88 except L{GeoidKarney} and the L{HeightIDW...<pygeodesy.heights>} ones.

89

90 Functions and C{LatLon} methods L{circin6}, L{circum3}, L{circum4_}, L{soddy4}, L{trilaterate3d2}

91 and C{trilaterate5} require U{numpy<https://PyPI.org/project/numpy>}.

92

93 Modules L{ellipsoidalGeodSolve} and L{geodsolve} and L{azimuthal} classes L{EquidistantGeodSolve}

94 and L{GnomonicGeodSolve} depend on I{Karney}'s C++ utility U{GeodSolve

95<https://GeographicLib.SourceForge.io/C++/doc/GeodSolve.1.html>} to be executable and set with

96 env variable C{PYGEODESY_GEODSOLVE}.

97

98 To compare C{MGRS} results from modules L{mgrs} and C{testMgrs} with I{Karney}'s C++ utility

99 U{GeoConvert<https://GeographicLib.SourceForge.io/C++/doc/GeoConvert.1.html>}, the latter must

100 be executable and set with env variable C{PYGEODESY_GEOCONVERT}.

101

102 Module L{rhumbsolve} needs I{Karney}'s C++ utility U{RhumbSolve

103<https://GeographicLib.SourceForge.io/C++/doc/RhumbSolve.1.html>} to be executable and set with

104 env variable C{PYGEODESY_RHUMBSOLVE}.

105

106 Documentation

107=============

108

109 In addition to the C{pygeodesy} package, the U{PyGeodesy<https://PyPI.org/project/PyGeodesy>}

110 U{distribution files<https://GitHub.com/mrJean1/PyGeodesy/tree/master/dist>} contain the tests, the

111 test results (on macOS only) and the complete U{documentation<https://mrJean1.GitHub.io/PyGeodesy>}

112(generated by U{Epydoc<https://PyPI.org/project/epydoc>} using command line: C{epydoc --html

113--no-private --no-source --name=PyGeodesy --url=... -v pygeodesy}).

114

115 Tests

116=====

117

118 The tests ran with Python 3.11.2 (with U{geographiclib<https://PyPI.org/project/geographiclib>} 2.0, U{numpy

119<https://PyPI.org/project/numpy>} 1.24.2 and U{scipy<https://PyPI.org/project/scipy>} 1.10.1), Python 3.10.8

120(with U{geographiclib<https://PyPI.org/project/geographiclib>} 2.0, U{numpy<https://PyPI.org/project/numpy>} 1.23.3,

121 U{scipy<https://PyPI.org/project/scipy>} 1.9.1, U{GeoConvert<https://GeographicLib.SourceForge.io/html/utilities.html>}

122 1.51, U{GeodSolve<https://GeographicLib.SourceForge.io/html/utilities.html>} 1.51 and U{RhumbSolve

123<https://GeographicLib.SourceForge.io/html/utilities.html>} 1.51), Python 3.9.6, Python 3.8.10 (with U{geographiclib

124<https://PyPI.org/project/geographiclib>} 1.52, U{numpy<https://PyPI.org/project/numpy>} 1.19.2 and U{scipy

125<https://PyPI.org/project/scipy>} 1.5.2) and Python 2.7.18 (with U{geographiclib<https://PyPI.org/project/geographiclib>}

126 1.50, U{numpy<https://PyPI.org/project/numpy>} 1.16.6, U{scipy<https://PyPI.org/project/scipy>} 1.2.2, U{GeoConvert

127<https://GeographicLib.SourceForge.io/html/utilities.html>} 1.51, U{GeodSolve

128<https://GeographicLib.SourceForge.io/html/utilities.html>} 1.51 and U{RhumbSolve

129<https://GeographicLib.SourceForge.io/html/utilities.html>} 1.51), all on macOS 13.2.1 Venture and in 64-bit only.

130

131 All tests ran with and without C{lazy import} for Python 3 and with command line option C{-W default} and env variable

132 C{PYGEODESY_WARNINGS=on} for all Python versions. The results of those tests are included in the distribution files.

133

134 Test coverage has been measured with U{coverage<https://PyPI.org/project/coverage>} 7.2.2 using only Python 3.11.2

135 and 3.10.8. The complete coverage report in HTML and a PDF summary are included in the distribution files.

136

137 Python 3.11.2, 3.10.8 and 3.9.6 ran on Apple M1 Silicon (C{arm64}), I{natively}. Python 3.8.10 and 2.7.18 ran on

138 Intel (C{x86_64}) or Intel I{emulation} ("C{arm64_x86_64}", see function L{pygeodesy.machine}).

139

140 The tests also ran with Python 3.11.2 (and U{geographiclib<https://PyPI.org/project/geographiclib>} 2.0) on U{Debian

141 11<https://Cirrus-CI.com/github/mrJean1/PyGeodesy/master>} in 64-bit only and with Python 3.11.2, 3.10.10 and 2.7.18

142(all with U{geographiclib<https://PyPI.org/project/geographiclib>} 1.52) on U{Windows 10<https://CI.AppVeyor.com/

143 project/mrJean1/pygeodesy>} in 64- and/or 32-bit.

144

145 A single-File and single-Directory application with C{pygeodesy} has been bundled using U{PyInstaller

146<https://PyPI.org/project/pyinstaller>} 3.4 and 64-bit Python 3.7.3 on macOS 10.13.6 High Sierra.

147

148 Previously, the tests were run with Python 3.10.1-7, 3.9.1, 3.8.7, 3.7.1, 2.7.15, U{PyPy<https://PyPy.org>}

149 7.3.1 (Python 3.6.9) and U{PyPy<https://PyPy.org>} 7.1.1 (Python 2.7.13) (and U{geographiclib

150<https://PyPI.org/project/geographiclib>} 1.52, U{numpy<https://PyPI.org/project/numpy>} 1.16.3,

151 1.16.4, 1.16.6, 1.19.0, 1.19.4, 1.19.5 or 1.22.4 and U{scipy<https://PyPI.org/project/scipy>} 1.2.1,

152 1.4.1, 1.5.2 or 1.8.1) on U{Ubuntu 16.04<https://Travis-CI.com/mrJean1/PyGeodesy>}, with Python 3.10.0-1,

153 3.9.0-5, 3.8.0-6, 3.7.2-6, 3.7.0, 3.6.2-5, 3.5.3, 2.7.13-17, 2.7.10 and 2.6.9 (and U{numpy

154<https://PyPI.org/project/numpy>} 1.19.0, 1.16.5, 1.16.2, 1.15.2, 1.14.0, 1.13.1, 1.8.0rc1 or 1.6.2 and

155 U{scipy<https://PyPI.org/project/scipy>} 1.5.0), U{PyPy<https://PyPy.org>} 7.3.0 (Python 2.7.13 and 3.6.9),

156 U{PyPy<https://PyPy.org>} 6.0.0 (Python 2.7.13 and 3.5.3) and U{Intel-Python<https://software.Intel.com/

157 en-us/distribution-for-python>} 3.5.3 (and U{numpy<https://PyPI.org/project/numpy>} 1.11.3) on macOS 13.0.0-1

158 Ventura, 12.1-6 Monterey, 11.0-5.2-6.1 Big Sur (aka 10.16), 10.15.3, 10.15.5-7 Catalina, 10.14 Mojave, 10.13.6

159 High Sierra and 10.12 Sierra, MacOS X 10.11 El Capitan and/or MacOS X 10.10 Yosemite, with U{Pythonista

160<https://OMZ-Software.com/pythonista>}3.2 (with geographiclib 1.50 or 1.49 and numpy 1.8.0) on iOS 14.4.2,

161 11.4.1, 12.0-3 on iPad4, iPhone6, iPhone10 and/or iPhone12, with U{Pythonista<https://OMZ-Software.com/pythonista>}

162 3.1 on iOS 10.3.3, 11.0.3, 11.1.2 and 11.3 on iPad4, all in 64-bit only and with 32-bit Python 2.7.14 on

163 Windows Server 2012R2, Windows 10 Pro and with 32-bit Python 2.6.6 on Windows XP SP3.

164

165 Notes

166=====

167

168 All Python source code has been statically U{checked<https://GitHub.com/ActiveState/code/tree/master/recipes/

169 Python/546532_PyChecker_postprocessor>} with U{PyChecker<https://PyPI.org/project/pychecker>}, U{PyFlakes

170<https://PyPI.org/project/pyflakes>}, U{PyCodeStyle<https://PyPI.org/project/pycodestyle>} (formerly Pep8) and

171 U{McCabe<https://PyPI.org/project/mccabe>} using Python 2.7.18 and with U{Flake8<https://PyPI.org/project/flake8>}

172 using Python 3.11.2, both in 64-bit on macOS 13.2.1 Ventura.

173

174 For a summary of all I{Karney}-based functionality in C{pygeodesy}, see module U{karney

175<https://mrJean1.GitHub.io/PyGeodesy/docs/pygeodesy.karney-module.html>}.

176

177 In Python 2, symbols L{S_DEG}, L{S_MIN}, L{S_SEC}, L{S_RAD} and L{S_SEP} may be multi-byte, non-ascii

178 characters and if so, I{not} C{unicode}.

179

180 Env variables

181=============

182

183 The following environment variables are observed by C{PyGeodesy}:

184

185 - C{PYGEODESY_EXCEPTION_CHAINING} - see module L{pygeodesy.errors}.

186 - C{PYGEODESY_FSUM_PARTIALS} - see module L{pygeodesy.fsums} and class L{pygeodesy.Fsum}.

187 - C{PYGEODESY_FSUM_RESIDUAL} - see module L{pygeodesy.fsums} and class L{pygeodesy.Fsum}.

188 - C{PYGEODESY_GEOCONVERT} - see module L{pygeodesy.mgrs}.

189 - C{PYGEODESY_GEODSOLVE} - see module L{pygeodesy.geodsolve}.

190 - C{PYGEODESY_LAZY_IMPORT} - see module L{pygeodesy.lazily} and variable L{pygeodesy.isLazy}.

191 - C{PYGEODESY_NOTIMPLEMENTED} - __special__ methods return C{NotImplemented} if set to "std".

192 - C{PYGEODESY_RHUMBSOLVE} - see module L{pygeodesy.rhumbsolve}.

193 - C{PYGEODESY_UPS_POLES} - see modules L{pygeodesy.ups} and L{pygeodesy.mgrs}.

194

195 and these to control standard or I{named} C{repr}esentations:

196

197 - C{PYGEODESY_BEARING_STD_REPR} - see method L{pygeodesy.Bearing}C{.__repr__}.

198 - C{PYGEODESY_BOOL_STD_REPR} - see method L{pygeodesy.Bool}C{.__repr__}.

199 - C{PYGEODESY_DEGREES_STD_REPR} - see method L{pygeodesy.Degrees}C{.__repr__}.

200 - C{PYGEODESY_FLOAT_STD_REPR} - see method L{pygeodesy.Float}C{.__repr__}.

201 - C{PYGEODESY_INT_STD_REPR} - see method L{pygeodesy.Int}C{.__repr__}.

202 - C{PYGEODESY_METER_STD_REPR} - see method L{pygeodesy.Meter}C{.__repr__}.

203 - C{PYGEODESY_RADIANS_STD_REPR} - see method L{pygeodesy.Radians}C{.__repr__}.

204 - C{PYGEODESY_STR_STD_REPR} - see method L{pygeodesy.Str}C{.__repr__}.

205

206 plus during development:

207

208 - C{PYGEODESY_FOR_DOCS} - for extended documentation by C{epydoc}.

209 - C{PYGEODESY_GEOGRAPHICLIB} - see module L{pygeodesy.karney}.

210 - C{PYGEODESY_WARNINGS} - see module L{pygeodesy.props} and function L{pygeodesy.DeprecationWarnings}.

211 - C{PYGEODESY_XPACKAGES} - see module L{pygeodesy.basics}.

212 - C{PYTHONDEVMODE} - see modules L{pygeodesy.errors} and L{pygeodesy.props}.

213

214 and:

215

216 - C{PYGEODESY_INIT__ALL__} - Set env variable C{PYGEODESY_INIT__ALL__} to anything

217 other than C{"__all__"} to avoid importing all C{pygeodesy} modules unnecessarily

218 (in Python 2 or with C{PYGEODESY_LAZY_IMPORT} turned off in Python 3). However,

219 to import a C{pygeodesy} item, the item name must be qualified with the C{module}

220 name, for example C{ from pygeodesy.ellipsoidalExact import LatLon }

221

222 License

223=======

224

225**) U{Copyright (C) 2016-2023 -- mrJean1 at Gmail -- All Rights Reserved.

226<https://OpenSource.org/licenses/MIT>}

227

228 C{Permission is hereby granted, free of charge, to any person obtaining a

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

230 to deal in the Software without restriction, including without limitation

231 the rights to use, copy, modify, merge, publish, distribute, sublicense,

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

233 Software is furnished to do so, subject to the following conditions:}

234

235 C{The above copyright notice and this permission notice shall be included

236 in all copies or substantial portions of the Software.}

237

238 C{THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS

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

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

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

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

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

244 OTHER DEALINGS IN THE SOFTWARE.}

245

246@newfield example: Example, Examples

247

248@var EPS: System's M{epsilon} ≈ 2.22044604925e-16 (C{float}).

249@var EPS0: M{EPS**2} ≈ 4.9e-32 for near-zero comparison

250@var EPS02: M{EPS**4} ≈ 2.4e-63 for near-zero squared comparison

251@var EPS1: M{1 - EPS} ≈ 0.9999999999999998 (C{float}).

252@var EPS2: M{EPS * 2} ≈ 4.440892098501e-16 (C{float}).

253@var EPS_2: M{EPS / 2} ≈ 1.110223024625e-16 (C{float}).

254@var EPS4: M{EPS * 4} ≈ 8.881784197001e-16 (C{float}).

255

256@var F_D: Format degrees as unsigned "deg°" with symbol, plus compass point suffix C{N, S, E} or C{W} (C{str}).

257@var F_DM: Format degrees as unsigned "deg°min′" with symbols, plus suffix (C{str}).

258@var F_DMS: Format degrees as unsigned "deg°min′sec″" with symbols, plus suffix (C{str}).

259@var F_DEG: Format degrees as unsigned "[D]DD" I{without} symbol, plus suffix (C{str}).

260@var F_MIN: Format degrees as unsigned "[D]DDMM" I{without} symbols, plus suffix (C{str}).

261@var F_SEC: Format degrees as unsigned "[D]DDMMSS" I{without} symbols, plus suffix (C{str}).

262@var F_D60: Format degrees as unsigned "[D]DD.MMSS" C{sexagecimal} I{without} symbols, plus suffix (C{str}).

263@var F__E: Format degrees as unsigned "%E" I{without} symbols, plus suffix (C{str}).

264@var F__F: Format degrees as unsigned "%F" I{without} symbols, plus suffix (C{str}).

265@var F__G: Format degrees as unsigned "%G" I{without} symbols, plus suffix (C{str}).

266@var F_RAD: Convert degrees to radians and format as unsigned "RR" with symbol, plus suffix (C{str}).

267

268@var F_D_: Format degrees as signed "-/deg°" with symbol, I{without} suffix (C{str}).

269@var F_DM_: Format degrees as signed "-/deg°min′" with symbols, I{without} suffix (C{str}).

270@var F_DMS_: Format degrees as signed "-/deg°min′sec″" with symbols, I{without} suffix (C{str}).

271@var F_DEG_: Format degrees as signed "-/[D]DD" I{without} symbol, I{without} suffix (C{str}).

272@var F_MIN_: Format degrees as signed "-/[D]DDMM" I{without} symbols, I{without} suffix (C{str}).

273@var F_SEC_: Format degrees as signed "-/[D]DDMMSS" I{without} symbols, I{without} suffix (C{str}).

274@var F_D60_: Format degrees as signed "-/[D]DD.MMSS" C{sexagecimal} I{without} symbols, I{without} suffix (C{str}).

275@var F__E_: Format degrees as signed "-/%E" I{without} symbols, I{without} suffix (C{str}).

276@var F__F_: Format degrees as signed "-/%F" I{without} symbols, I{without} suffix (C{str}).

277@var F__G_: Format degrees as signed "-/%G" I{without} symbols, I{without} suffix (C{str}).

278@var F_RAD_: Convert degrees to radians and format as signed "-/RR" I{without} symbol, I{without} suffix (C{str}).

279

280@var F_D__: Format degrees as signed "-/+deg°" with symbol, I{without} suffix (C{str}).

281@var F_DM__: Format degrees as signed "-/+deg°min′" with symbols, I{without} suffix (C{str}).

282@var F_DMS__: Format degrees as signed "-/+deg°min′sec″" with symbols, I{without} suffix (C{str}).

283@var F_DEG__: Format degrees as signed "-/+[D]DD" I{without} symbol, I{without} suffix (C{str}).

284@var F_MIN__: Format degrees as signed "-/+[D]DDMM" I{without} symbols, without suffix (C{str}).

285@var F_SEC__: Format degrees as signed "-/+[D]DDMMSS" I{without} symbols, I{without} suffix (C{str}).

286@var F_D60__: Format degrees as signed "-/+[D]DD.MMSS" C{sexagecimal} I{without} symbols, I{without} suffix (C{str}).

287@var F__E__: Format degrees as signed "-/+%E" I{without} symbols, I{without} suffix (C{str}).

288@var F__F__: Format degrees as signed "-/+%F" I{without} symbols, I{without} suffix (C{str}).

289@var F__G__: Format degrees as signed "-/+%G" I{without} symbols, I{without} suffix (C{str}).

290@var F_RAD__: Convert degrees to radians and format as signed "-/+RR" I{without} symbol, I{without} suffix (C{str}).

291

292@var DIG: System's M{float decimal digits} = 15 (C{int}).

293@var INF: Infinity (C{float}), see functions L{pygeodesy.isinf} and L{pygeodesy.isfinite} and C{NINF}.

294@var INT0: C{int(0)}, missing Z-components, C{if B{z}=B{INT0}}, see functions L{pygeodesy.isint0}, L{pygeodesy.meeus2}

295@var MANT_DIG: System's M{float mantissa bits} = 53 (C{int}).

296@var MAX: System's M{float max} ≈ 1.798e+308 (C{float}).

297@var MIN: System's M{float min} ≈ 2.225e-308 (C{float}).

298@var NAN: Not-A-Number (C{float}), see function L{pygeodesy.isnan}.

299@var NEG0: Negative 0.0 (C{float}), see function L{pygeodesy.isneg0}.

300@var NINF: Negative infinity (C{float}), see function L{pygeodesy.isninf} and C{INF}.

301@var NN: Empty (C{str}), U{I{Nomen Nescio}<https://Wiktionary.org/wiki/N.N.>}.

302

303@var PI: Constant M{math.pi} (C{float}).

304@var PI2: Two PI, M{PI * 2}, aka I{Tau} (C{float}).

305@var PI_2: Half PI, M{PI / 2} (C{float}).

306@var PI3: Three PI, M{PI * 3} (C{float}).

307@var PI3_2: One and a half PI, M{PI * 3 / 2} (C{float}).

308@var PI_3: One third PI, M{PI / 3} (C{float}).

309@var PI4: Four PI, M{PI * 4} (C{float}).

310@var PI_4: Quarter PI, M{PI / 4} (C{float}).

311

312@var R_MA: Equatorial earth radius (C{meter}), WGS84, EPSG:3785.

313@var R_MB: Polar earth radius (C{meter}), WGS84, EPSG:3785.

314@var R_M: Mean (spherical) earth radius (C{meter}).

315@var R_KM: Mean (spherical) earth radius (C{km}, kilometer).

316@var R_NM: Mean (spherical) earth radius (C{NM}, nautical miles).

317@var R_SM: Mean (spherical) earth radius (C{SM}, statute miles).

318@var R_FM: Former FAI-Sphere earth radius (C{meter}).

319@var R_GM: Average earth radius, distance to geoid surface (C{meter})

320@var R_QM: Earth' (triaxial) quadratic mean radius (C{meter})

321@var R_VM: Aviation/Navigation earth radius (C{meter}).

322

323@var S_DEG: Degrees symbol, default C{"°"}

324@var S_MIN: Minutes symbol, default C{"′"} aka I{PRIME}

325@var S_SEC: Seconds symbol, default C{"″"} aka I{DOUBLE_PRIME}

326@var S_RAD: Radians symbol, default C{""} aka L{pygeodesy.NN}

327@var S_DMS: If C{True} include, otherwise cancel all DMS symbols, default C{True}.

328@var S_SEP: Separator between C{deg°|min′|sec″|suffix}, default C{""} aka L{pygeodesy.NN}

329

330@var Conics: Registered, predefined conics (C{enum-like}).

331@var Datums: Registered, predefined datums (C{enum-like}).

332@var Ellipsoids: Registered, predefined ellipsoids (C{enum-like}).

333@var RefFrames: Registered, predefined reference frames (C{enum-like}).

334@var Transforms: Registered, predefined transforms (C{enum-like}).

335

336@var isLazy: Lazy import setting (C{int} 0, 1, 2 or 3+) from C{env} variable C{PYGEODESY_LAZY_IMPORT}, or C{None} if C{lazy import} is not supported or not enabled, or C{False} if initializing C{lazy import} failed.

337

338@var pygeodesy_abspath: Fully qualified C{pygeodesy} directory name (C{str}).

339

340@var version: Normalized C{PyGeodesy} version (C{str}).

341'''

342

343 from os.path import abspath, basename, dirname

344 import sys

345

346_init__all__ = True

347# <https://PyInstaller.ReadTheDocs.io/en/stable/runtime-information.html>

348_isfrozen = getattr(sys, 'frozen', False)

349 pygeodesy_abspath = dirname(abspath(__file__)) # sys._MEIPASS + '/pygeodesy'

350_pygeodesy_ = __package__ or basename(pygeodesy_abspath)

351

352 if _isfrozen: # avoid lazy import

353 _lazy_import2 = None

354 else:

355 # setting __path__ should ...

356 __path__ = [pygeodesy_abspath]

357 try: # ... make this import work, ...

358 import pygeodesy.lazily as _

359 except ImportError: # ... if it doesn't, extend

360 # sys.path to include this very directory such

361 # that all public and private sub-modules can

362 # be imported (and checked by PyChecker, etc.)

363 sys.path.insert(0, pygeodesy_abspath) # XXX __path__[0]

364

365 try: # lazily requires Python 3.7+, see lazily.__doc__

366 from pygeodesy.lazily import _a_l_l_, _getenv, LazyImportError, \

367 _lazy_import2 # PYCHOK expected

368 _, __getattr__ = _lazy_import2(_pygeodesy_) # PYCHOK expected

369 _init__all__ = _getenv('PYGEODESY_INIT__ALL__', _a_l_l_) == _a_l_l_

370 del _a_l_l_, _getenv

371

372 except (ImportError, LazyImportError, NotImplementedError):

373 _lazy_import2 = None

374

375 if _init__all__ and not _lazy_import2: # import and set __all__

376

377 # import all public modules and export as such

378 import pygeodesy.albers as albers # PYCHOK exported

379 import pygeodesy.azimuthal as azimuthal # PYCHOK exported

380 import pygeodesy.deprecated.bases as bases # PYCHOK DEPRECATED

381 import pygeodesy.basics as basics # PYCHOK exported

382 import pygeodesy.booleans as booleans # PYCHOK exported

383 import pygeodesy.cartesianBase as cartesianBase # PYCHOK exported

384 import pygeodesy.clipy as clipy # PYCHOK exported

385 import pygeodesy.constants as constants # PYCHOK exported

386 import pygeodesy.css as css # PYCHOK exported

387 import pygeodesy.deprecated.datum as datum # PYCHOK DEPRECATED

388 import pygeodesy.datums as datums # PYCHOK exported

389 import pygeodesy.deprecated as deprecated # PYCHOK exported

390 import pygeodesy.dms as dms # PYCHOK exported

391 import pygeodesy.ecef as ecef # PYCHOK exported

392 import pygeodesy.elevations as elevations # PYCHOK exported

393 import pygeodesy.ellipsoidalBase as ellipsoidalBase # PYCHOK exported

394 import pygeodesy.ellipsoidalBaseDI as ellipsoidalBaseDI # PYCHOK exported

395 import pygeodesy.ellipsoidalExact as ellipsoidalExact # PYCHOK exported

396 import pygeodesy.ellipsoidalGeodSolve as ellipsoidalGeodSolve # PYCHOK exported

397 import pygeodesy.ellipsoidalKarney as ellipsoidalKarney # PYCHOK exported

398 import pygeodesy.ellipsoidalNvector as ellipsoidalNvector # PYCHOK exported

399 import pygeodesy.ellipsoidalVincenty as ellipsoidalVincenty # PYCHOK exported

400 import pygeodesy.ellipsoids as ellipsoids # PYCHOK exported

401 import pygeodesy.elliptic as elliptic # PYCHOK exported

402 import pygeodesy.epsg as epsg # PYCHOK exported

403 import pygeodesy.etm as etm # PYCHOK exported

404 import pygeodesy.errors as errors # PYCHOK exported

405 import pygeodesy.fmath as fmath # PYCHOK exported

406 import pygeodesy.formy as formy # PYCHOK exported

407 import pygeodesy.frechet as frechet # PYCHOK exported

408 import pygeodesy.fstats as fstats # PYCHOK exported

409 import pygeodesy.fsums as fsums # PYCHOK exported

410 import pygeodesy.gars as gars # PYCHOK exported

411 import pygeodesy.geodesicx as geodesicx # PYCHOK exported

412 import pygeodesy.geodsolve as geodsolve # PYCHOK exported

413 import pygeodesy.geohash as geohash # PYCHOK exported

414 import pygeodesy.geoids as geoids # PYCHOK exported

415 import pygeodesy.hausdorff as hausdorff # PYCHOK exported

416 import pygeodesy.heights as heights # PYCHOK exported

417 import pygeodesy.interns as interns # PYCHOK exported

418 import pygeodesy.iters as iters # PYCHOK exported

419 import pygeodesy.karney as karney # PYCHOK exported

420 import pygeodesy.ktm as ktm # PYCHOK exported

421 import pygeodesy.latlonBase as latlonBase # PYCHOK exported

422 import pygeodesy.lazily as lazily # PYCHOK exported

423 import pygeodesy.lcc as lcc # PYCHOK exported

424 import pygeodesy.ltp as ltp # PYCHOK exported

425 import pygeodesy.ltpTuples as ltpTuples # PYCHOK exported

426 import pygeodesy.mgrs as mgrs # PYCHOK exported

427 import pygeodesy.named as named # PYCHOK exported

428 import pygeodesy.namedTuples as namedTuples # PYCHOK exported

429 import pygeodesy.nvectorBase as nvectorBase # PYCHOK exported

430 import pygeodesy.deprecated.nvector as nvector # PYCHOK DEPRECATED

431 import pygeodesy.osgr as osgr # PYCHOK exported

432 import pygeodesy.points as points # PYCHOK exported

433 import pygeodesy.props as props # PYCHOK exported

434 import pygeodesy.resections as resections # PYCHOK exported

435 import pygeodesy.rhumbsolve as rhumbsolve # PYCHOK exported

436 import pygeodesy.rhumbx as rhumbx # PYCHOK exported

437 import pygeodesy.simplify as simplify # PYCHOK exported

438 import pygeodesy.sphericalBase as sphericalBase # PYCHOK exported

439 import pygeodesy.sphericalNvector as sphericalNvector # PYCHOK exported

440 import pygeodesy.sphericalTrigonometry as sphericalTrigonometry # PYCHOK exported

441 import pygeodesy.solveBase as solveBase # PYCHOK exported

442 import pygeodesy.streprs as streprs # PYCHOK exported

443 import pygeodesy.trf as trf # PYCHOK exported

444 import pygeodesy.triaxials as triaxials # PYCHOK exported

445 import pygeodesy.units as units # PYCHOK exported

446 import pygeodesy.unitsBase as unitsBase # PYCHOK exported

447 import pygeodesy.ups as ups # PYCHOK exported

448 import pygeodesy.utily as utily # PYCHOK exported

449 import pygeodesy.utm as utm # PYCHOK exported

450 import pygeodesy.utmups as utmups # PYCHOK exported

451 import pygeodesy.utmupsBase as utmupsBase # PYCHOK exported

452 import pygeodesy.vector2d as vector2d # PYCHOK exported

453 import pygeodesy.vector3d as vector3d # PYCHOK exported

454 import pygeodesy.vector3dBase as vector3dBase # PYCHOK exported

455 import pygeodesy.webmercator as webmercator # PYCHOK exported

456 import pygeodesy.wgrs as wgrs # PYCHOK exported

457

458 # lift all public classes, constants, functions, etc. but ONLY

459 # from the following modules ... (see also David Beazley's

460 # talk <https://DaBeaz.com/modulepackage/index.html>) ... BUT

461 # NOT modules ellipsoidal*, epsg, gars, geohash, spherical*,

462 # vector and wgrs ... in order keep those as modules ONLY

463 from pygeodesy.albers import * # PYCHOK __all__

464 from pygeodesy.azimuthal import * # PYCHOK __all__

465 from pygeodesy.basics import * # PYCHOK __all__

466 from pygeodesy.booleans import * # PYCHOK __all__

467# from pygeodesy.cartesianBase import * # PYCHOK __(_)__

468 from pygeodesy.clipy import * # PYCHOK __all__

469 from pygeodesy.constants import * # PYCHOK __all__

470 from pygeodesy.css import * # PYCHOK __all__

471 from pygeodesy.datums import * # PYCHOK __all__

472 from pygeodesy.deprecated import * # PYCHOK __all__

473 from pygeodesy.dms import * # PYCHOK __all__

474 from pygeodesy.ecef import * # PYCHOK __all__

475 from pygeodesy.elevations import * # PYCHOK __all__

476# from pygeodesy.ellipsoidalBase import * # PYCHOK __(_)__

477# from pygeodesy.ellipsoidalBaseDI import * # PYCHOK __(_)__

478# from pygeodesy.ellipsoidalExact import * # PYCHOK __(_)__

479# from pygeodesy.ellipsoidalGeodSolve import * # PYCHOK __(_)__

480# from pygeodesy.ellipsoidalKarney import * # PYCHOK __(_)__

481# from pygeodesy.ellipsoidalNvector import * # PYCHOK __(_)__

482 from pygeodesy.ellipsoidalVincenty import VincentyError # PYCHOK lazily

483 from pygeodesy.ellipsoids import * # PYCHOK __all__

484 from pygeodesy.elliptic import * # PYCHOK __all__

485 from pygeodesy.epsg import Epsg, EPSGError # PYCHOK lazily

486 from pygeodesy.etm import * # PYCHOK __all__

487 from pygeodesy.errors import * # PYCHOK __all__

488 from pygeodesy.fmath import * # PYCHOK __all__

489 from pygeodesy.formy import * # PYCHOK __all__

490 from pygeodesy.frechet import * # PYCHOK __all__

491 from pygeodesy.fstats import * # PYCHOK __all__

492 from pygeodesy.fsums import * # PYCHOK __all__

493 from pygeodesy.gars import Garef, GARSError # PYCHOK lazily

494 from pygeodesy.geodesicx import * # PYCHOK __all__

495 from pygeodesy.geodsolve import * # PYCHOK __all__

496 from pygeodesy.geohash import Geohash, GeohashError, \

497 Neighbors8Dict, Resolutions2Tuple # PYCHOK lazily

498 from pygeodesy.geoids import * # PYCHOK __all__

499 from pygeodesy.hausdorff import * # PYCHOK __all__

500 from pygeodesy.heights import * # PYCHOK __all__

501 from pygeodesy.interns import * # PYCHOK __all__

502 from pygeodesy.iters import * # PYCHOK __all__

503 from pygeodesy.karney import * # PYCHOK __all__

504 from pygeodesy.ktm import * # PYCHOK __all__

505# from pygeodesy.latlonBase import * # PYCHOK __(_)__

506 from pygeodesy.lazily import * # PYCHOK __all__

507 from pygeodesy.lcc import * # PYCHOK __all__

508 from pygeodesy.ltp import * # PYCHOK __all__

509 from pygeodesy.ltpTuples import * # PYCHOK __all__

510 from pygeodesy.mgrs import * # PYCHOK __all__

511 from pygeodesy.named import * # PYCHOK __all__

512 from pygeodesy.namedTuples import * # PYCHOK __all__

513# from pygeodesy.nvectorBase import * # PYCHOK __(_)__

514 from pygeodesy.osgr import * # PYCHOK __all__

515 from pygeodesy.points import * # PYCHOK __all__

516 from pygeodesy.props import * # PYCHOK __all__

517 from pygeodesy.resections import * # PYCHOK __all__

518 from pygeodesy.rhumbsolve import * # PYCHOK __all__

519 from pygeodesy.rhumbx import * # PYCHOK __all__

520 from pygeodesy.simplify import * # PYCHOK __all__

521# from pygeodesy.sphericalBase import * # PYCHOK __(_)__

522# from pygeodesy.sphericalNvector import * # PYCHOK __(_)__

523# from pygeodesy.sphericalTrigonometry import * # PYCHOK __(_)__

524# from pygeodesy.solveBase import * # PYCHOK __(_)__

525 from pygeodesy.streprs import * # PYCHOK __all__

526 from pygeodesy.trf import * # PYCHOK __all__

527 from pygeodesy.triaxials import * # PYCHOK __all__

528 from pygeodesy.units import * # PYCHOK __all__

529 from pygeodesy.unitsBase import * # PYCHOK __all__

530 from pygeodesy.ups import * # PYCHOK __all__

531 from pygeodesy.utily import * # PYCHOK __all__

532 from pygeodesy.utm import * # PYCHOK __all__

533 from pygeodesy.utmups import * # PYCHOK __all__

534# from pygeodesy.utmupsBase import * # PYCHOK __(_)__

535 from pygeodesy.vector2d import * # PYCHOK __all__

536 from pygeodesy.vector3d import * # PYCHOK __all__

537# from pygeodesy.vector3dBase import * # PYCHOK __(_)__

538 from pygeodesy.webmercator import * # PYCHOK __all__

539 from pygeodesy.wgrs import Georef, WGRSError # PYCHOK lazily

540

541 def _all(globalocals):

542 from pygeodesy.interns import NN as _NN, _attribute_, _COMMASPACE_, \

543 _DOT_, _module_, _s_ # PYCHOK expected

544 from pygeodesy.streprs import Fmt as _Fmt # PYCHOK expected

545 # collect all public module and attribute names and check

546 # that modules are imported from this package, 'pygeodesy'

547 # (but the latter only when not bundled with PyInstaller or

548 # Py2Exe, since the file-layout is different. Courtesy of

549 # GilderGeek<https://GitHub.com/mrJean1/PyGeodesy/issues/31>)

550 ns = list(lazily._ALL_INIT)

551# XXX ps = () if _isfrozen else set([_pygeodesy_] + __name__.split(_DOT_))

552 for mod, attrs in lazily._ALL_LAZY.enums():

553 if mod not in globalocals:

554 t = _DOT_(_pygeodesy_, mod)

555 raise ImportError('missing %s%s: %s' % (_module_, _NN, t))

556 ns.append(mod)

557 # check that all other public attributes do exist

558 if attrs and isinstance(attrs, tuple):

559 t = tuple(a for a in attrs if a not in globalocals)

560 if t:

561 s = _Fmt.SQUARE(_s_, len(t)) if len(t) > 1 else _NN

562 t = _COMMASPACE_.join(_DOT_(_pygeodesy_, mod, a) for a in t)

563 raise ImportError('missing %s%s: %s' % (_attribute_, s, t))

564 ns.extend(attrs)

565# XXX if ps: # check that mod is a _pygeodesy_ module

566# XXX m = globalocals[mod] # assert(m.__name__ == mod)

567# XXX f = getattr(m, '__file__', _NN)

568# XXX d = dirname(abspath(f)) if f else pygeodesy_abspath

569# XXX p = getattr(m, '__package__', _NN) or _pygeodesy_

570# XXX if p not in ps or d != pygeodesy_abspath:

571# XXX raise ImportError('foreign module: %s from %r' % (_DOT_(p, mod), f or p))

572 return tuple(set(ns)) # remove duplicates

573

574 __all__ = _all(globals()) # or locals()

575 else:

576 __all__ = ()

577 _init__all__ = False

578

579 from pygeodesy.interns import _DOT_ # PYCHOK import

580__version__ = '23.04.06'

581# see setup.py for similar logic

582 version = _DOT_.join(map(str, map(int, __version__.split(_DOT_))))

583

584# XXX del ellipsoidalBase, ellipsoidalBaseDI, sphericalBase, utmupsBase # PYCHOK expected

585 del abspath, basename, dirname, _DOT_, _lazy_import2, sys

586

587# **) MIT License

588#

589# Copyright (C) 2016-2023 -- mrJean1 at Gmail -- All Rights Reserved.

590#

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

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

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

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

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

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

597#

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

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

600#

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

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

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

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

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

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

607# OTHER DEALINGS IN THE SOFTWARE.