Coverage for pygeodesy/__init__.py: 98%
186 statements
« prev ^ index » next coverage.py v7.6.1, created at 2025-04-09 11:05 -0400
« prev ^ index » next coverage.py v7.6.1, created at 2025-04-09 11:05 -0400
2# -*- coding: utf-8 -*-
4u'''A pure Python implementation of geodesy tools for various ellipsoidal and spherical earth
5models using precision trigonometric, vector-based, exact, elliptic, iterative and approximate
6methods for geodetic (lat-/longitude), geocentric (U{ECEF<https://WikiPedia.org/wiki/ECEF>}
7cartesian) and certain U{triaxial ellipsoidal<https://GeographicLib.SourceForge.io/1.44/triaxial.html>}
8coordinates.
10Transcoded in part from U{JavaScript originals<https://GitHub.com/ChrisVeness/geodesy>} by I{Chris Veness (C)
112005-2024} and from several U{C++ classes<https://GeographicLib.SourceForge.io/C++/doc/annotated.html>} by I{Charles
12F. F. Karney (C) 2008-2024} and published under the same U{MIT License<https://OpenSource.org/licenses/MIT>}**.
14There are four modules for ellipsoidal earth models, C{ellipsoidalExact}, C{-Karney}, C{-Vincenty} and C{-Nvector}
15and two for spherical ones, C{sphericalTrigonometry} and C{-Nvector}. Each module provides a geodetic B{C{LatLon}}
16and a geocentric B{C{Cartesian}} class with methods and functions to compute distance, surface area, perimeter,
17forward and reverse azimuth, initial and final bearing, intermediate and nearest points, intersections of geodesic,
18great circle and rhumb lines, circle intersections and secants, U{3-point resections
19<https://WikiPedia.org/wiki/Position_resection_and_intersection>}, triangulation, trilateration (by intersection,
20by overlap and in 3-D), conversions and unrolling, among other things. For more information and further details see
21the U{documentation<https://mrJean1.GitHub.io/PyGeodesy>}, the descriptions of U{Latitude/Longitude
22<https://www.Movable-Type.co.UK/scripts/latlong.html>}, U{Vincenty
23<https://www.Movable-Type.co.UK/scripts/latlong-vincenty.html>} and U{Vector-based
24<https://www.Movable-Type.co.UK/scripts/latlong-vectors.html>} geodesy, the original U{JavaScript source
25<https://GitHub.com/ChrisVeness/geodesy>} or U{docs<https://www.Movable-Type.co.UK/scripts/geodesy/docs>}
26and I{Karney}'s Python U{geographiclib<https://PyPI.org/project/geographiclib>} and C++ U{GeographicLib
27<https://GeographicLib.SourceForge.io/C++/doc/index.html>}.
29Also included are modules for conversions to and from U{Cassini-Soldner
30<https://GeographicLib.SourceForge.io/C++/doc/classGeographicLib_1_1CassiniSoldner.html>},
31U{ECEF<https://WikiPedia.org/wiki/ECEF>} (Earth-Centered, Earth-Fixed cartesian), U{UTM
32<https://www.Movable-Type.co.UK/scripts/latlong-utm-mgrs.html>} (Universal Transverse Mercator
33and U{Exact<https://GeographicLib.SourceForge.io/C++/doc/classGeographicLib_1_1TransverseMercatorExact.html>}),
34U{UPS<https://WikiPedia.org/wiki/Universal_polar_stereographic_coordinate_system>} (Universal Polar
35Stereographic) and U{Web Mercator<https://WikiPedia.org/wiki/Web_Mercator>} (Pseudo-Mercator) coordinates,
36U{MGRS<https://GeographicLib.SourceForge.io/C++/doc/classGeographicLib_1_1MGRS.html>} (Military Grid Reference
37System, UTM I{and} UPS) and U{OSGR<https://www.Movable-Type.co.UK/scripts/latlong-os-gridref.html>} (British
38Ordinance Survery Grid Reference) grid references, U{TRF<http://ITRF.ENSG.IGN.Fr>} (Terrestrial Reference
39Frames) and modules to encode and decode U{EPSG<https://EPSG.org>}, U{Geohashes
40<https://www.Movable-Type.co.UK/scripts/geohash.html>}, U{Georefs (WGRS)
41<https://WikiPedia.org/wiki/World_Geographic_Reference_System>} and U{Garefs (GARS)
42<https://WikiPedia.org/wiki/Global_Area_Reference_System>}.
44Other modules provide U{Albers equal-area
45<https://GeographicLib.SourceForge.io/C++/doc/classGeographicLib_1_1AlbersEqualArea.html>} projections, U{equidistant
46<https://GeographicLib.SourceForge.io/C++/doc/classGeographicLib_1_1AzimuthalEquidistant.html>} and other I{azimuthal}
47projections, Lambert I{conformal conic} projections and positions, functions to clip paths or polygons of C{LatLon}
48points using the U{Cohen-Sutherland<https://WikiPedia.org/wiki/Cohen-Sutherland_algorithm>},
49U{Forster-Hormann-Popa<https://www.ScienceDirect.com/science/article/pii/S259014861930007X>},
50U{Greiner-Hormann<http://www.inf.USI.CH/hormann/papers/Greiner.1998.ECO.pdf>},
51U{Liang-Barsky<https://www.CS.Helsinki.FI/group/goa/viewing/leikkaus/intro.html>} and
52U{Sutherland-Hodgman<https://WikiPedia.org/wiki/Sutherland-Hodgman_algorithm>} methods,
53functions to U{simplify<https://Bost.Ocks.org/mike/simplify>} or linearize a path of C{LatLon}
54points (or a U{NumPy array<https://docs.SciPy.org/doc/numpy/reference/generated/numpy.array.html>}),
55including implementations of the U{Ramer-Douglas-Peucker<https://WikiPedia.org/wiki/
56Ramer-Douglas-Peucker_algorithm>}, the U{Visvalingam-Whyatt<https://hydra.Hull.ac.UK/
57resources/hull:8338>} and the U{Reumann-Witkam<https://psimpl.SourceForge.net/reumann-witkam.html>}
58algorithms and modified versions of the former. Other classes provide I{boolean} operations between
59(composite) polygons or U{interpolate <https://docs.SciPy.org/doc/scipy/reference/interpolate.html>}
60the L{height<pygeodesy.heights>} of C{LatLon} points and L{Geoid<pygeodesy.geoids>} models, compute
61various U{Fréchet<https://WikiPedia.org/wiki/Frechet_distance>} or U{Hausdorff<https://WikiPedia.org/
62wiki/Hausdorff_distance>} distances.
64Installation
65============
67To install C{pygeodesy}, type C{python[3] -m pip install pygeodesy} or C{python[3] -m easy_install
68pygeodesy} in a terminal or command window.
70If the wheel C{pygeodesy-yy.m.d-py2.py3-none-any.whl} is missing in U{PyPI Download files<https://
71PyPI.org/project/pygeodesy/#files>}, download the file from U{GitHub/dist<https://GitHub.com/mrJean1/
72PyGeodesy/tree/master/dist>}. Install that with C{python[3] -m pip install <path-to-downloaded-wheel>}
73and verify with C{python[3] -m pygeodesy}.
75Alternatively, download C{pygeodesy-yy.m.d.tar.gz} from U{PyPI<https://PyPI.org/project/pygeodesy>}
76or U{GitHub<https://GitHub.com/mrJean1/PyGeodesy>}, C{unzip} the downloaded file, C{cd} to
77directory C{pygeodesy-yy.m.d} and type C{python[3] setup.py install}.
79To run all C{pygeodesy} tests, type C{python[3] test/run.py} or type C{python[3] test/unitTestSuite.py}
80before or after installation.
82Dependencies
83============
85Installation of I{Karney}'s Python package U{geographiclib<https://PyPI.org/project/geographiclib>}
86is optional, but required to use modules L{ellipsoidalKarney} and L{css}, L{azimuthal} classes
87L{EquidistantKarney} and L{GnomonicKarney} and the L{HeightIDWkarney} interpolator.
89Both U{numpy<https://PyPI.org/project/numpy>} and U{scipy<https://PyPI.org/project/scipy>} must be
90installed for most L{Geoid...<pygeodesy.geoids>} and L{Height...<pygeodesy.heights>} interpolators,
91except L{GeoidKarney} and the L{HeightIDW...<pygeodesy.heights>} ones.
93Functions and C{LatLon} methods L{circin6}, L{circum3}, L{circum4_}, L{soddy4}, L{trilaterate3d2} do and
94C{trilaterate5} and modules L{auxilats} and L{rhumb} may require U{numpy<https://PyPI.org/project/numpy>}.
96Modules L{ellipsoidalGeodSolve} and L{geodsolve} and L{azimuthal} classes L{EquidistantGeodSolve}
97and L{GnomonicGeodSolve} depend on I{Karney}'s C++ utility U{GeodSolve
98<https://GeographicLib.SourceForge.io/C++/doc/GeodSolve.1.html>} to be executable and set with
99env variable C{PYGEODESY_GEODSOLVE} or with property L{Ellipsoid.geodsolve}.
101Class L{Intersectool} in module L{geodesici} needs I{Karney}'s C++ utility U{IntersectTool
102<https://GeographicLib.SourceForge.io/C++/doc/IntersectTool.1.html>} to be executable and set with
103env variable C{PYGEODESY_INTERSECTTOOL}.
105To compare C{MGRS} results from modules L{mgrs} and C{testMgrs} with I{Karney}'s C++ utility
106U{GeoConvert<https://GeographicLib.SourceForge.io/C++/doc/GeoConvert.1.html>}, the latter must
107be executable and set with env variable C{PYGEODESY_GEOCONVERT}.
109Module L{rhumb.solve} needs I{Karney}'s C++ utility U{RhumbSolve
110<https://GeographicLib.SourceForge.io/C++/doc/RhumbSolve.1.html>} to be executable and set with
111env variable C{PYGEODESY_RHUMBSOLVE} or with property L{Ellipsoid.rhumbsolve}.
113Documentation
114=============
116In addition to the C{pygeodesy} package, the U{pygeodesy<https://PyPI.org/project/pygeodesy>}
117U{distribution files<https://GitHub.com/mrJean1/PyGeodesy/tree/master/dist>} contain the tests,
118the test results (on macOS only) and the complete U{documentation<https://mrJean1.GitHub.io/PyGeodesy>}
119(generated by U{Epydoc<https://PyPI.org/project/epydoc>} using command line:
120C{epydoc --html --no-private --no-source --name=pygeodesy --url=... -v pygeodesy}).
122Tests
123=====
125The tests ran with Python 3.13.2 (with U{geographiclib<https://PyPI.org/project/geographiclib>} 2.0),
126Python 3.12.7 (with U{geographiclib<https://PyPI.org/project/geographiclib>} 2.0,
127U{numpy<https://PyPI.org/project/numpy>} 2.1.0, U{scipy<https://PyPI.org/project/scipy>} 1.14.1,
128U{GeodSolve<https://GeographicLib.SourceForge.io/C++/doc/utilities.html>} 2.3,
129U{IntersectTool<https://GeographicLib.SourceForge.io/C++/doc/utilities.html>} 2.3 and
130U{RhumbSolve<https://GeographicLib.SourceForge.io/C++/doc/utilities.html>} 2.3),
131Python 3.11.5 (with U{geographiclib<https://PyPI.org/project/geographiclib>} 2.0,
132U{numpy<https://PyPI.org/project/numpy>} 1.24.2 and U{scipy<https://PyPI.org/project/scipy>} 1.10.1),
133Python 3.10.8 (with U{geographiclib <https://PyPI.org/project/geographiclib>} 2.0,
134U{numpy<https://PyPI.org/project/numpy>} 1.23.3, U{scipy<https://PyPI.org/project/scipy>} 1.9.1,
135U{GeoConvert<https://GeographicLib.SourceForge.io/C++/doc/utilities.html>} 2.3,
136U{GeodSolve<https://GeographicLib.SourceForge.io/C++/doc/utilities.html>} 2.3) and
137Python 2.7.18 (with U{geographiclib<https://PyPI.org/project/geographiclib>} 1.50,
138U{numpy<https://PyPI.org/project/numpy>} 1.16.6, U{scipy<https://PyPI.org/project/scipy>} 1.2.2,
139U{GeoConvert<https://GeographicLib.SourceForge.io/C++/doc/utilities.html>} 2.3,
140U{GeodSolve<https://GeographicLib.SourceForge.io/C++/doc/utilities.html>} 2.3,
141U{IntersectTool<https://GeographicLib.SourceForge.io/C++/doc/utilities.html>} 2.3 and
142U{RhumbSolve<https://GeographicLib.SourceForge.io/C++/doc/utilities.html>} 2.3), all in 64-bit on
143macOS 15.4 Sequoia.
145All tests ran with and without C{lazy import} for Python 3 and with command line option C{-W default} and
146env variable C{PYGEODESY_WARNINGS=on} for all Python versions. The results of those tests are included in
147the distribution files.
149Test coverage has been measured with U{coverage<https://PyPI.org/project/coverage>} 7.6.1 using Python
1503.13.2, 3.12.7, 3.11.5 and 3.10.8. The complete coverage report in HTML and a PDF summary are included in
151the distribution files.
153Python 3.13.2, 3.12.7, 3.11.5 and 3.10.8 run on Apple M1 Silicon (C{arm64}), I{natively}. Python 2.7.18 runs
154on Intel (C{x86_64}) or Intel I{emulation} ("C{arm64_x86_64}", see function L{machine<pygeodesy.machine>}).
156The tests also ran with Python 3.13.2 (and U{geographiclib<https://PyPI.org/project/geographiclib>} 2.0) on
157U{Debian 12<https://Cirrus-CI.com/github/mrJean1/PyGeodesy/master>} in 64-bit only, with Python 3.12.5 (and
158U{geographiclib<https://PyPI.org/project/geographiclib>} 2.0) on U{Windows 2019Server
159<https://CI.AppVeyor.com/project/mrJean1/pygeodesy>} in 64-bit only and with Python 2.7.18 (and U{geographiclib
160<https://PyPI.org/project/geographiclib>} 1.52) on U{Windows 10<https://CI.AppVeyor.com/project/mrJean1/pygeodesy>}
161in 64- and 32-bit.
163A single-File and single-Directory application with C{pygeodesy} has been bundled using U{PyInstaller
164<https://PyPI.org/project/pyinstaller>} 3.4 and 64-bit Python 3.7.3 on macOS 10.13.6 High Sierra.
166Previously, the tests were run with Python 3.13.0-1, 3.12.0-6, 3.11.2-4, 3.10.1-7, 3.9.6, 3.9.1, 3.8.7, 3.7.1, 2.7.15,
167U{PyPy<https://PyPy.org>} 7.3.12 (Python 3.10.12), 7.3.1 (Python 3.6.9) and U{PyPy<https://PyPy.org>} 7.1.1 (Python
1682.7.13) (and U{geographiclib <https://PyPI.org/project/geographiclib>} 1.52, U{numpy<https://PyPI.org/project/numpy>}
1691.16.3, 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, 1.4.1,
1701.5.2 or 1.8.1) on U{Ubuntu 16.04<https://Travis-CI.com/mrJean1/PyGeodesy>}, with Python 3.10.0-1, 3.9.0-5, 3.8.0-6,
1713.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<https://PyPI.org/project/numpy>} 1.19.0,
1721.16.5, 1.16.2, 1.15.2, 1.14.0, 1.13.1, 1.8.0rc1 or 1.6.2 and U{scipy<https://PyPI.org/project/scipy>} 1.5.0), U{PyPy
173<https://PyPy.org>} 7.3.0 (Python 2.7.13 and 3.6.9), U{PyPy<https://PyPy.org>} 6.0.0 (Python 2.7.13 and 3.5.3)
174and U{Intel-Python<https://software.Intel.com/en-us/distribution-for-python>} 3.5.3 (and U{numpy
175<https://PyPI.org/project/numpy>} 1.11.3) on macOS 14.0-6.1 Sonoma, 13.0-5.2 Ventura, 12.1-6 Monterey, 11.0-5.2-6.1
176Big Sur (aka 10.16), 10.15.3, 10.15.5-7 Catalina, 10.14 Mojave, 10.13.6 High Sierra and 10.12 Sierra, MacOS X
17710.11 El Capitan and/or MacOS X 10.10 Yosemite, with U{Pythonista<https://OMZ-Software.com/pythonista>}3.2 (with
178geographiclib 1.50 or 1.49 and numpy 1.8.0) on iOS 14.4.2, 11.4.1, 12.0-3 on iPad4, iPhone6, iPhone10 and/or
179iPhone12, with U{Pythonista<https://OMZ-Software.com/pythonista>} 3.1 on iOS 10.3.3, 11.0.3, 11.1.2 and 11.3
180on iPad4, all in 64-bit only and with 32-bit Python 2.7.14 on Windows Server 2012R2, Windows 10 Pro and with
18132-bit Python 2.6.6 on Windows XP SP3.
183Notes
184=====
186All Python source code has been statically U{checked<https://GitHub.com/ActiveState/code/tree/master/recipes/
187Python/546532_PyChecker_postprocessor>} with U{PyChecker<https://PyPI.org/project/pychecker>}, U{PyFlakes
188<https://PyPI.org/project/pyflakes>}, U{PyCodeStyle<https://PyPI.org/project/pycodestyle>} (formerly Pep8) and
189U{McCabe<https://PyPI.org/project/mccabe>} using Python 2.7.18 and with U{Flake8<https://PyPI.org/project/flake8>}
190using Python 3.11.5, both in 64-bit on macOS 15.4 Sequoia.
192For a summary of all I{Karney}-based functionality in C{pygeodesy}, see module U{karney
193<https://mrJean1.GitHub.io/PyGeodesy/docs/pygeodesy.karney-module.html>}.
195In 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
196characters and if so, I{not} C{unicode}.
198Env variables
199=============
201The following environment variables are observed by C{pygeodesy}:
203 - C{PYGEODESY_EXCEPTION_CHAINING} - see module L{errors<pygeodesy.errors>}.
204 - C{PYGEODESY_FMT_FORM} - see module L{dms<pygeodesy.dms>}.
205 - C{PYGEODESY_FSUM_F2PRODUCT} - see module L{fsums<pygeodesy.fsums>} and method L{f2product<pygeodesy.Fsum.f2product>}.
206 - C{PYGEODESY_FSUM_NONFINITES} - see module L{fsums<pygeodesy.fsums>} and method L{nonfinites<pygeodesy.Fsum.nonfinites>}.
207 - C{PYGEODESY_FSUM_RESIDUAL} - see module L{fsums<pygeodesy.fsums>} and method L{RESIDUAL<pygeodesy.Fsum.RESIDUAL>}.
208 - C{PYGEODESY_GEOCONVERT} - see module L{mgrs<pygeodesy.mgrs>}.
209 - C{PYGEODESY_GEODSOLVE} - see module L{geodsolve<pygeodesy.geodsolve>}.
210 - C{PYGEODESY_INTERSECTTOOL} - see module L{geodesici<pygeodesy.geodesici>}.
211 - C{PYGEODESY_LAZY_IMPORT} - see module L{lazily<pygeodesy.lazily>} and variable L{isLazy<pygeodesy.isLazy>}.
212 - C{PYGEODESY_NOTIMPLEMENTED} - C{__special__} methods return C{NotImplemented} if set to "std".
213 - C{PYGEODESY_RHUMBSOLVE} - see module L{rhumb.solve<pygeodesy.rhumb.solve>}.
214 - C{PYGEODESY_UPS_POLES} - see modules L{ups<pygeodesy.ups>} and L{mgrs<pygeodesy.mgrs>}.
216and these to specify standard or I{named} C{repr}esentations:
218 - C{PYGEODESY_AZIMUTH_STD_REPR} - see method L{Azimuth<pygeodesy.Azimuth>}C{.__repr__}.
219 - C{PYGEODESY_BEARING_STD_REPR} - see method L{Bearing<pygeodesy.Bearing>}C{.__repr__}.
220 - C{PYGEODESY_BOOL_STD_REPR} - see method L{Bool<pygeodesy.Bool>}C{.__repr__}.
221 - C{PYGEODESY_DEGREES_STD_REPR} - see method L{Degrees<pygeodesy.Degrees>}C{.__repr__}.
222 - C{PYGEODESY_EPOCH_STD_REPR} - see method L{Float<pygeodesy.Epoch>}C{.__repr__}.
223 - C{PYGEODESY_FLOAT_STD_REPR} - see method L{Float<pygeodesy.Float>}C{.__repr__}.
224 - C{PYGEODESY_INT_STD_REPR} - see method L{Int<pygeodesy.Int>}C{.__repr__}.
225 - C{PYGEODESY_METER_STD_REPR} - see method L{Meter<pygeodesy.Meter>}C{.__repr__}.
226 - C{PYGEODESY_RADIANS_STD_REPR} - see method L{Radians<pygeodesy.Radians>}C{.__repr__}.
227 - C{PYGEODESY_STR_STD_REPR} - see method L{Str<pygeodesy.Str>}C{.__repr__}.
229plus during development:
231 - C{PYGEODESY_FOR_DOCS} - for extended documentation by C{epydoc}.
232 - C{PYGEODESY_GEOGRAPHICLIB} - see module L{karney<pygeodesy.karney>}.
233 - C{PYGEODESY_WARNINGS} - see module L{props<pygeodesy.props>} and function L{DeprecationWarnings<pygeodesy.DeprecationWarnings>}.
234 - C{PYGEODESY_XPACKAGES} - see module L{basics<pygeodesy.basics>}.
235 - C{PYTHONDEVMODE} - see modules L{errors<pygeodesy.errors>} and L{props<pygeodesy.props>}.
237and:
239 - C{PYGEODESY_INIT__ALL__} - Set env variable C{PYGEODESY_INIT__ALL__} to anything other than C{"__all__"} to avoid
240 importing all C{pygeodesy} modules unnecessarily (in Python 2 or with C{PYGEODESY_LAZY_IMPORT} turned off in Python
241 3). However, to import a C{pygeodesy} item, the item name must be qualified with the C{module} name, for example
242 C{ from pygeodesy.ellipsoidalExact import LatLon } or C{ from pygeodesy.deprecated import collins }
244License
245=======
247**) U{Copyright (C) 2016-2025 -- mrJean1 at Gmail -- All Rights Reserved.<https://OpenSource.org/licenses/MIT>}
249C{Permission is hereby granted, free of charge, to any person obtaining a copy of this software
250and associated documentation files (the "Software"), to deal in the Software without restriction,
251including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
252and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so,
253subject to the following conditions:}
255C{The above copyright notice and this permission notice shall be included in all copies or substantial
256portions of the Software.}
258C{THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT
259NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
260IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
261WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
262SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.}
264@newfield example: Example, Examples
266@var EPS: System's M{epsilon} ≈ 2.22044604925e-16 (C{float}).
267@var EPS0: M{EPS**2} ≈ 4.9e-32 for near-zero comparison
268@var EPS02: M{EPS**4} ≈ 2.4e-63 for near-zero squared comparison
269@var EPS1: M{1 - EPS} ≈ 0.9999999999999998 (C{float}).
270@var EPS2: M{EPS * 2} ≈ 4.440892098501e-16 (C{float}).
271@var EPS_2: M{EPS / 2} ≈ 1.110223024625e-16 (C{float}).
272@var EPS4: M{EPS * 4} ≈ 8.881784197001e-16 (C{float}).
274@var F_D: Format degrees as unsigned "deg°" with symbol, plus compass point suffix C{N, S, E} or C{W} (C{str}).
275@var F_DM: Format degrees as unsigned "deg°min′" with symbols, plus suffix (C{str}).
276@var F_DMS: Format degrees as unsigned "deg°min′sec″" with symbols, plus suffix (C{str}).
277@var F_DEG: Format degrees as unsigned "[D]DD" I{without} symbol, plus suffix (C{str}).
278@var F_MIN: Format degrees as unsigned "[D]DDMM" I{without} symbols, plus suffix (C{str}).
279@var F_SEC: Format degrees as unsigned "[D]DDMMSS" I{without} symbols, plus suffix (C{str}).
280@var F_D60: Format degrees as unsigned "[D]DD.MMSS" C{sexagecimal} I{without} symbols, plus suffix (C{str}).
281@var F__E: Format degrees as unsigned "%E" I{without} symbols, plus suffix (C{str}).
282@var F__F: Format degrees as unsigned "%F" I{without} symbols, plus suffix (C{str}).
283@var F__G: Format degrees as unsigned "%G" I{without} symbols, plus suffix (C{str}).
284@var F_RAD: Convert degrees to radians and format as unsigned "RR" with symbol, plus suffix (C{str}).
286@var F_D_: Format degrees as signed "-/deg°" with symbol, I{without} suffix (C{str}).
287@var F_DM_: Format degrees as signed "-/deg°min′" with symbols, I{without} suffix (C{str}).
288@var F_DMS_: Format degrees as signed "-/deg°min′sec″" with symbols, I{without} suffix (C{str}).
289@var F_DEG_: Format degrees as signed "-/[D]DD" I{without} symbol, I{without} suffix (C{str}).
290@var F_MIN_: Format degrees as signed "-/[D]DDMM" I{without} symbols, I{without} suffix (C{str}).
291@var F_SEC_: Format degrees as signed "-/[D]DDMMSS" I{without} symbols, I{without} suffix (C{str}).
292@var F_D60_: Format degrees as signed "-/[D]DD.MMSS" C{sexagecimal} I{without} symbols, I{without} suffix (C{str}).
293@var F__E_: Format degrees as signed "-/%E" I{without} symbols, I{without} suffix (C{str}).
294@var F__F_: Format degrees as signed "-/%F" I{without} symbols, I{without} suffix (C{str}).
295@var F__G_: Format degrees as signed "-/%G" I{without} symbols, I{without} suffix (C{str}).
296@var F_RAD_: Convert degrees to radians and format as signed "-/RR" I{without} symbol, I{without} suffix (C{str}).
298@var F_D__: Format degrees as signed "-/+deg°" with symbol, I{without} suffix (C{str}).
299@var F_DM__: Format degrees as signed "-/+deg°min′" with symbols, I{without} suffix (C{str}).
300@var F_DMS__: Format degrees as signed "-/+deg°min′sec″" with symbols, I{without} suffix (C{str}).
301@var F_DEG__: Format degrees as signed "-/+[D]DD" I{without} symbol, I{without} suffix (C{str}).
302@var F_MIN__: Format degrees as signed "-/+[D]DDMM" I{without} symbols, without suffix (C{str}).
303@var F_SEC__: Format degrees as signed "-/+[D]DDMMSS" I{without} symbols, I{without} suffix (C{str}).
304@var F_D60__: Format degrees as signed "-/+[D]DD.MMSS" C{sexagecimal} I{without} symbols, I{without} suffix (C{str}).
305@var F__E__: Format degrees as signed "-/+%E" I{without} symbols, I{without} suffix (C{str}).
306@var F__F__: Format degrees as signed "-/+%F" I{without} symbols, I{without} suffix (C{str}).
307@var F__G__: Format degrees as signed "-/+%G" I{without} symbols, I{without} suffix (C{str}).
308@var F_RAD__: Convert degrees to radians and format as signed "-/+RR" I{without} symbol, I{without} suffix (C{str}).
310@var DIG: System's M{float decimal digits} = 15 (C{int}).
311@var INF: Infinity (C{float}), see functions L{isinf<pygeodesy.isinf>} and L{isfinite<pygeodesy.isfinite>} and C{NINF}.
312@var INT0: C{int(0)}, missing Z-components, C{if B{z}=B{INT0}}, see functions L{isint0<pygeodesy.isint0>}, L{meeus2<pygeodesy.meeus2>}
313@var MANT_DIG: System's M{float mantissa bits} = 53 (C{int}).
314@var MAX: System's M{float max} ≈ 1.798e+308 (C{float}).
315@var MIN: System's M{float min} ≈ 2.225e-308 (C{float}).
316@var NAN: Not-A-Number (C{float}), see function L{isnan<pygeodesy.isnan>}.
317@var NEG0: Negative 0.0 (C{float}), see function L{isneg0<pygeodesy.isneg0>}.
318@var NINF: Negative infinity (C{float}), see function L{isninf<pygeodesy.isninf>} and C{INF}.
319@var NN: Empty (C{str}), U{I{Nomen Nescio}<https://Wiktionary.org/wiki/N.N.>}.
321@var PI: Constant M{math.pi} (C{float}).
322@var PI2: Two PI, M{PI * 2}, aka I{Tau} (C{float}).
323@var PI_2: Half PI, M{PI / 2} (C{float}).
324@var PI3: Three PI, M{PI * 3} (C{float}).
325@var PI3_2: One and a half PI, M{PI * 3 / 2} (C{float}).
326@var PI_3: One third PI, M{PI / 3} (C{float}).
327@var PI4: Four PI, M{PI * 4} (C{float}).
328@var PI_4: Quarter PI, M{PI / 4} (C{float}).
330@var R_MA: Equatorial earth radius (C{meter}), WGS84, EPSG:3785.
331@var R_MB: Polar earth radius (C{meter}), WGS84, EPSG:3785.
332@var R_M: Mean (spherical) earth radius (C{meter}).
333@var R_KM: Mean (spherical) earth radius (C{Km}, kilometer).
334@var R_NM: Mean (spherical) earth radius (C{NM}, nautical miles).
335@var R_SM: Mean (spherical) earth radius (C{SM}, statute miles).
336@var R_FM: Former FAI-Sphere earth radius (C{meter}).
337@var R_GM: Average earth radius, distance to geoid surface (C{meter})
338@var R_QM: Earth' (triaxial) quadratic mean radius (C{meter})
339@var R_VM: Aviation/Navigation earth radius (C{meter}).
341@var S_DEG: Degrees symbol, default C{"°"}
342@var S_MIN: Minutes symbol, default C{"′"} aka I{PRIME}
343@var S_SEC: Seconds symbol, default C{"″"} aka I{DOUBLE_PRIME}
344@var S_RAD: Radians symbol, default C{""} aka L{NN<pygeodesy.NN>}
345@var S_DMS: If C{True}, include, otherwise cancel all DMS symbols, default C{True}.
346@var S_SEP: Separator between C{deg°|min′|sec″|suffix}, default C{""} aka L{NN<pygeodesy.NN>}
348@var Conics: Registered, predefined conics (C{enum-like}).
349@var Datums: Registered, predefined datums (C{enum-like}).
350@var Ellipsoids: Registered, predefined ellipsoids (C{enum-like}).
351@var RefFrames: Registered, predefined reference frames (C{enum-like}).
352@var Transforms: Registered, predefined transforms (C{enum-like}).
353@var Triaxials: Registered, predefined triaxial ellipsoids (C{enum-like}).
355@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.
357@var pygeodesy_abspath: Fully qualified C{pygeodesy} directory name (C{str}).
359@var version: Normalized C{pygeodesy} version (C{str}).
360'''
362import os.path as _os_path
363import sys as _sys
365_init__all__ = True
366# <https://PyInstaller.ReadTheDocs.io/en/stable/runtime-information.html>
367_isfrozen = getattr(_sys, 'frozen', False)
368pygeodesy_abspath = _os_path.dirname(_os_path.abspath(__file__)) # _sys._MEIPASS + '/pygeodesy'
369_pygeodesy_ = __package__ or _os_path.basename(pygeodesy_abspath)
371if _isfrozen: # avoid lazy import
372 _lazy_import2 = None
373else:
374 # setting __path__ should ...
375 __path__ = [pygeodesy_abspath]
376 try: # ... make this import work, ...
377 import pygeodesy.lazily as _
378 except ImportError: # ... if it doesn't, extend _sys.path to include
379 # this very directory such that all public and private sub-modules
380 # can be imported (by epydoc, checked by PyChecker, etc.)
381 _sys.path.insert(0, pygeodesy_abspath) # XXX __path__[0]
383 try: # lazily requires Python 3.7+, see lazily.__doc__
384 from pygeodesy.lazily import _init__all__, _lazy_import2 # PYCHOK expected
385 _, __getattr__ = _lazy_import2(_pygeodesy_) # PYCHOK expected
387 except (ImportError, NotImplementedError): # LazyImportError
388 _lazy_import2 = None
390if _init__all__ and not _lazy_import2: # import and set __all__
392 # import all public modules and export as such
393 import pygeodesy.albers as albers # PYCHOK exported
394 import pygeodesy.auxilats as auxilats # PYCHOK exported
395 import pygeodesy.azimuthal as azimuthal # PYCHOK exported
396 import pygeodesy.basics as basics # PYCHOK exported
397 import pygeodesy.booleans as booleans # PYCHOK exported
398 import pygeodesy.cartesianBase as cartesianBase # PYCHOK INTERNAL
399 import pygeodesy.clipy as clipy # PYCHOK exported
400 import pygeodesy.constants as constants # PYCHOK exported
401 import pygeodesy.css as css # PYCHOK exported
402 import pygeodesy.datums as datums # PYCHOK exported
403 import pygeodesy.deprecated as deprecated # PYCHOK exported
404 import pygeodesy.dms as dms # PYCHOK exported
405 import pygeodesy.ecef as ecef # PYCHOK exported
406 import pygeodesy.elevations as elevations # PYCHOK exported
407 import pygeodesy.ellipsoidalBase as ellipsoidalBase # PYCHOK INTERNAL
408 import pygeodesy.ellipsoidalBaseDI as ellipsoidalBaseDI # PYCHOK INTERNAL
409 import pygeodesy.ellipsoidalExact as ellipsoidalExact # PYCHOK exported
410 import pygeodesy.ellipsoidalGeodSolve as ellipsoidalGeodSolve # PYCHOK exported
411 import pygeodesy.ellipsoidalKarney as ellipsoidalKarney # PYCHOK exported
412 import pygeodesy.ellipsoidalNvector as ellipsoidalNvector # PYCHOK exported
413 import pygeodesy.ellipsoidalVincenty as ellipsoidalVincenty # PYCHOK exported
414 import pygeodesy.ellipsoids as ellipsoids # PYCHOK exported
415 import pygeodesy.elliptic as elliptic # PYCHOK exported
416 import pygeodesy.epsg as epsg # PYCHOK exported
417 import pygeodesy.etm as etm # PYCHOK exported
418 import pygeodesy.errors as errors # PYCHOK exported
419 import pygeodesy.fmath as fmath # PYCHOK exported
420 import pygeodesy.formy as formy # PYCHOK exported
421 import pygeodesy.frechet as frechet # PYCHOK exported
422 import pygeodesy.fstats as fstats # PYCHOK exported
423 import pygeodesy.fsums as fsums # PYCHOK exported
424 import pygeodesy.gars as gars # PYCHOK exported
425 import pygeodesy.geodesici as geodesici # PYCHOK exported
426 import pygeodesy.geodesicw as geodesicw # PYCHOK exported
427 import pygeodesy.geodesicx as geodesicx # PYCHOK exported
428 import pygeodesy.geodsolve as geodsolve # PYCHOK exported
429 import pygeodesy.geohash as geohash # PYCHOK exported
430 import pygeodesy.geoids as geoids # PYCHOK exported
431 import pygeodesy.hausdorff as hausdorff # PYCHOK exported
432 import pygeodesy.heights as heights # PYCHOK exported
433 import pygeodesy.internals as internals # PYCHOK exported
434 import pygeodesy.interns as interns # PYCHOK exported
435 import pygeodesy.iters as iters # PYCHOK exported
436 import pygeodesy.karney as karney # PYCHOK exported
437 import pygeodesy.ktm as ktm # PYCHOK exported
438 import pygeodesy.latlonBase as latlonBase # PYCHOK INTERNAL
439 import pygeodesy.lazily as lazily # PYCHOK exported
440 import pygeodesy.lcc as lcc # PYCHOK exported
441 import pygeodesy.ltp as ltp # PYCHOK exported
442 import pygeodesy.ltpTuples as ltpTuples # PYCHOK exported
443 import pygeodesy.mgrs as mgrs # PYCHOK exported
444 import pygeodesy.named as named # PYCHOK exported
445 import pygeodesy.namedTuples as namedTuples # PYCHOK exported
446 import pygeodesy.nvectorBase as nvectorBase # PYCHOK INTERNAL
447 import pygeodesy.osgr as osgr # PYCHOK exported
448 import pygeodesy.points as points # PYCHOK exported
449 import pygeodesy.props as props # PYCHOK exported
450 import pygeodesy.resections as resections # PYCHOK exported
451 import pygeodesy.rhumb as rhumb # PYCHOK exported
452 import pygeodesy.simplify as simplify # PYCHOK exported
453 import pygeodesy.sphericalBase as sphericalBase # PYCHOK INTERNAL
454 import pygeodesy.sphericalNvector as sphericalNvector # PYCHOK exported
455 import pygeodesy.sphericalTrigonometry as sphericalTrigonometry # PYCHOK exported
456 import pygeodesy.solveBase as solveBase # PYCHOK exported
457 import pygeodesy.streprs as streprs # PYCHOK exported
458 import pygeodesy.trf as trf # PYCHOK exported
459 import pygeodesy.triaxials as triaxials # PYCHOK exported
460 import pygeodesy.units as units # PYCHOK exported
461 import pygeodesy.unitsBase as unitsBase # PYCHOK INTERNAL
462 import pygeodesy.ups as ups # PYCHOK exported
463 import pygeodesy.utily as utily # PYCHOK exported
464 import pygeodesy.utm as utm # PYCHOK exported
465 import pygeodesy.utmups as utmups # PYCHOK exported
466 import pygeodesy.utmupsBase as utmupsBase # PYCHOK INTERNAL
467 import pygeodesy.vector2d as vector2d # PYCHOK exported
468 import pygeodesy.vector3d as vector3d # PYCHOK exported
469 import pygeodesy.vector3dBase as vector3dBase # PYCHOK INTERNAL
470 import pygeodesy.webmercator as webmercator # PYCHOK exported
471 import pygeodesy.wgrs as wgrs # PYCHOK exported
473 # lift all public classes, constants, functions, etc. but ONLY
474 # from the following modules ... (see also David Beazley's
475 # talk <https://DaBeaz.com/modulepackage/index.html>) ... BUT
476 # NOT modules ellipsoidal*, epsg, gars, geohash, spherical*,
477 # vector and wgrs ... in order keep those as modules ONLY
478 from pygeodesy.albers import * # PYCHOK __all__
479 from pygeodesy.azimuthal import * # PYCHOK __all__
480# from pygeodesy.auxilats import * # PYCHOK __(_)__
481 from pygeodesy.basics import * # PYCHOK __all__
482 from pygeodesy.booleans import * # PYCHOK __all__
483 from pygeodesy.cartesianBase import * # PYCHOK __(_)__ INTERNAL
484 from pygeodesy.clipy import * # PYCHOK __all__
485 from pygeodesy.constants import * # PYCHOK __all__
486 from pygeodesy.css import * # PYCHOK __all__
487 from pygeodesy.datums import * # PYCHOK __all__
488 from pygeodesy.deprecated import * # PYCHOK __all__ DEPRECATED
489 from pygeodesy.dms import * # PYCHOK __all__
490 from pygeodesy.ecef import * # PYCHOK __all__
491 from pygeodesy.elevations import * # PYCHOK __all__
492# from pygeodesy.ellipsoidalBase import * # PYCHOK __(_)__ INTERNAL
493# from pygeodesy.ellipsoidalBaseDI import * # PYCHOK __(_)__ INTERNAL
494# from pygeodesy.ellipsoidalExact import * # PYCHOK __(_)__
495# from pygeodesy.ellipsoidalGeodSolve import * # PYCHOK __(_)__
496# from pygeodesy.ellipsoidalKarney import * # PYCHOK __(_)__
497# from pygeodesy.ellipsoidalNvector import * # PYCHOK __(_)__
498 from pygeodesy.ellipsoidalVincenty import * # PYCHOK __(_)__
499 from pygeodesy.ellipsoids import * # PYCHOK __all__
500 from pygeodesy.elliptic import * # PYCHOK __all__
501 from pygeodesy.epsg import * # PYCHOK __all__
502 from pygeodesy.etm import * # PYCHOK __all__
503 from pygeodesy.errors import * # PYCHOK __all__
504 from pygeodesy.fmath import * # PYCHOK __all__
505 from pygeodesy.formy import * # PYCHOK __all__
506 from pygeodesy.frechet import * # PYCHOK __all__
507 from pygeodesy.fstats import * # PYCHOK __all__
508 from pygeodesy.fsums import * # PYCHOK __all__
509 from pygeodesy.gars import * # PYCHOK __all__
510 from pygeodesy.geodesici import * # PYCHOK __all__
511 from pygeodesy.geodesicw import * # PYCHOK __all__
512 from pygeodesy.geodesicx import * # PYCHOK __all__
513 from pygeodesy.geodsolve import * # PYCHOK __all__
514 from pygeodesy.geohash import * # PYCHOK __all__
515 from pygeodesy.geoids import * # PYCHOK __all__
516 from pygeodesy.hausdorff import * # PYCHOK __all__
517 from pygeodesy.heights import * # PYCHOK __all__
518 from pygeodesy.internals import * # PYCHOK __all__
519 from pygeodesy.interns import * # PYCHOK __all__
520 from pygeodesy.iters import * # PYCHOK __all__
521 from pygeodesy.karney import * # PYCHOK __all__
522 from pygeodesy.ktm import * # PYCHOK __all__
523 from pygeodesy.latlonBase import * # PYCHOK __(_)__ INTERNAL
524 from pygeodesy.lazily import * # PYCHOK __all__
525 from pygeodesy.lcc import * # PYCHOK __all__
526 from pygeodesy.ltp import * # PYCHOK __all__
527 from pygeodesy.ltpTuples import * # PYCHOK __all__
528 from pygeodesy.mgrs import * # PYCHOK __all__
529 from pygeodesy.named import * # PYCHOK __all__
530 from pygeodesy.namedTuples import * # PYCHOK __all__
531 from pygeodesy.nvectorBase import * # PYCHOK __(_)__ INTERNAL
532 from pygeodesy.osgr import * # PYCHOK __all__
533 from pygeodesy.points import * # PYCHOK __all__
534 from pygeodesy.props import * # PYCHOK __all__
535 from pygeodesy.resections import * # PYCHOK __all__
536 from pygeodesy.rhumb import * # PYCHOK __all__
537 from pygeodesy.simplify import * # PYCHOK __all__
538# from pygeodesy.sphericalBase import * # PYCHOK __(_)__ INTERNAL
539# from pygeodesy.sphericalNvector import * # PYCHOK __(_)__
540# from pygeodesy.sphericalTrigonometry import * # PYCHOK __(_)__
541# from pygeodesy.solveBase import * # PYCHOK __(_)__ INTERNAL
542 from pygeodesy.streprs import * # PYCHOK __all__
543 from pygeodesy.trf import * # PYCHOK __all__
544 from pygeodesy.triaxials import * # PYCHOK __all__
545 from pygeodesy.units import * # PYCHOK __all__
546 from pygeodesy.unitsBase import * # PYCHOK __all__ Float, ...
547 from pygeodesy.ups import * # PYCHOK __all__
548 from pygeodesy.utily import * # PYCHOK __all__
549 from pygeodesy.utm import * # PYCHOK __all__
550 from pygeodesy.utmups import * # PYCHOK __all__
551# from pygeodesy.utmupsBase import * # PYCHOK __(_)__ INTERNAL
552 from pygeodesy.vector2d import * # PYCHOK __all__
553 from pygeodesy.vector3d import * # PYCHOK __all__
554 from pygeodesy.vector3dBase import * # PYCHOK __(_)__ INTERNAL
555 from pygeodesy.webmercator import * # PYCHOK __all__
556 from pygeodesy.wgrs import * # PYCHOK __all__
558 def _all(globalocals):
559 from pygeodesy.internals import _headof, _DOT_ # PYCHOK expected
560 from pygeodesy.interns import NN as _NN, _attribute_, _COMMASPACE_, \
561 _module_, _s_, _UNDER_ # PYCHOK expected
562 from pygeodesy.streprs import Fmt as _Fmt # PYCHOK expected
563 # collect all public module and attribute names and check
564 # that modules are imported from this package, 'pygeodesy'
565 # (but the latter only when not bundled with PyInstaller or
566 # Py2Exe, since the file-layout is different. Courtesy of
567 # GilderGeek<https://GitHub.com/mrJean1/PyGeodesy/issues/31>)
568 ns = list(lazily._ALL_INIT)
569# XXX ps = () if _isfrozen else set([_pygeodesy_] + __name__.split(_DOT_))
570 for mod, attrs in lazily._all_enums():
571 mod = _headof(_headof(mod))
572 if mod not in globalocals:
573 t = _DOT_(_pygeodesy_, mod)
574 raise ImportError('missing %s%s: %s' % (_module_, _NN, t))
575 ns.append(mod)
576 # check that all other public attrs do exist
577 if attrs and isinstance(attrs, tuple):
578 attrs = lazily._ALL_ATTRS(attrs)
579 t = tuple(a for a in attrs if a not in globalocals)
580 if t:
581 s = _Fmt.SQUARE(_s_, len(t)) if len(t) > 1 else _NN
582 t = _COMMASPACE_.join(_DOT_(_pygeodesy_, mod, a) for a in t)
583 raise ImportError('missing %s%s: %s' % (_attribute_, s, t))
584 ns.extend(attrs)
585# XXX if ps: # check that mod is a _pygeodesy_ module
586# XXX m = globalocals[mod] # assert(_DUNDER_nameof(m) == mod)
587# XXX f = getattr(m, _dunder_file_, _NN)
588# XXX d = _os_path.dirname(_os_path.abspath(f)) if f else pygeodesy_abspath
589# XXX p = getattr(m, _dunder_package_, _NN) or _pygeodesy_
590# XXX if p not in ps or d != pygeodesy_abspath:
591# XXX t = '%s from %r' % (_DOT_(p, mod), f or p)
592# XXX raise ImportError('foreign %s: %s' % (_module_, t))
593 return tuple(set(ns)) # remove duplicates
595 __all__ = _all(globals()) # or locals()
596else:
597 __all__ = ()
598 _init__all__ = False
600from pygeodesy.internals import _version2, _DOT_ # PYCHOK import
601# from pygeodesy.interns import _DOT_ # from .internals
602__version__ = '25.04.08'
603# see setup.py for similar logic
604version = _DOT_(*_version2(__version__, n=3))
606del _DOT_, _lazy_import2, _os_path, _sys, _version2
608# **) MIT License
609#
610# Copyright (C) 2016-2025 -- mrJean1 at Gmail -- All Rights Reserved.
611#
612# Permission is hereby granted, free of charge, to any person obtaining a
613# copy of this software and associated documentation files (the "Software"),
614# to deal in the Software without restriction, including without limitation
615# the rights to use, copy, modify, merge, publish, distribute, sublicense,
616# and/or sell copies of the Software, and to permit persons to whom the
617# Software is furnished to do so, subject to the following conditions:
618#
619# The above copyright notice and this permission notice shall be included
620# in all copies or substantial portions of the Software.
621#
622# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
623# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
624# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
625# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
626# OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
627# ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
628# OTHER DEALINGS IN THE SOFTWARE.