Coverage for pygeodesy/__init__.py: 98%
197 statements
« prev ^ index » next coverage.py v7.17.0, created at 2026-11-10 16:16 -0500
« prev ^ index » next coverage.py v7.17.0, created at 2026-11-10 16:16 -0500
2# -*- coding: utf-8 -*-
4u'''A pure Python implementation of geodesy tools for various ellipsoidal and spherical earth models
5using precision exact, elliptic, trigonometric, vector-based, iterative and approximate methods for
6geodetic (lat-/longitude), geocentric (U{ECEF<https://WikiPedia.org/wiki/ECEF>} cartesian), local (U{LTP
7<https://WikiPedia.org/wiki/Local_tangent_plane_coordinates>}) and certain U{triaxial ellipsoidal
8<https://GeographicLib.SourceForge.io/1.44/triaxial.html>} coordinates.
10Transcoded in part from U{JavaScript originals<https://GitHub.com/ChrisVeness/geodesy>} by I{Chris Veness (C)
112005-2025} and from several U{C++ classes<https://GeographicLib.SourceForge.io/C++/doc/annotated.html>} by I{Charles
12F. F. Karney (C) 2008-2025} 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), among other things.
22Also included are modules for conversions to and from U{Cassini-Soldner
23<https://GeographicLib.SourceForge.io/C++/doc/classGeographicLib_1_1CassiniSoldner.html>},
24U{ECEF<https://WikiPedia.org/wiki/ECEF>} (Earth-Centered, Earth-Fixed cartesian), U{UTM
25<https://www.Movable-Type.co.UK/scripts/latlong-utm-mgrs.html>} (Universal Transverse Mercator
26and U{Exact<https://GeographicLib.SourceForge.io/C++/doc/classGeographicLib_1_1TransverseMercatorExact.html>}),
27U{UPS<https://WikiPedia.org/wiki/Universal_polar_stereographic_coordinate_system>} (Universal Polar Stereographic),
28U{Oblique Mercator<https://WikiPedia.org/wiki/Oblique_Mercator_projection>} (Hotine and Laborde) and U{Web Mercator
29<https://WikiPedia.org/wiki/Web_Mercator>} (Pseudo-Mercator) coordinates,
30U{MGRS<https://GeographicLib.SourceForge.io/C++/doc/classGeographicLib_1_1MGRS.html>} (Military Grid Reference
31System, UTM I{and} UPS) and U{OSGR<https://www.Movable-Type.co.UK/scripts/latlong-os-gridref.html>} (British
32Ordinance Survery Grid Reference) grid references, U{TRF<http://ITRF.ENSG.IGN.Fr>} (Terrestrial Reference
33Frames) and modules to encode and decode U{EPSG<https://EPSG.org>}, U{Geohashes
34<https://www.Movable-Type.co.UK/scripts/geohash.html>}, U{Georefs (WGRS)
35<https://WikiPedia.org/wiki/World_Geographic_Reference_System>} and U{Garefs (GARS)
36<https://WikiPedia.org/wiki/Global_Area_Reference_System>}.
38Other modules provide U{Albers equal-area
39<https://GeographicLib.SourceForge.io/C++/doc/classGeographicLib_1_1AlbersEqualArea.html>} projections, U{equidistant
40<https://GeographicLib.SourceForge.io/C++/doc/classGeographicLib_1_1AzimuthalEquidistant.html>} and other I{azimuthal}
41projections, Lambert I{conformal conic} projections and positions, functions to clip paths or polygons of C{LatLon}
42points using the U{Cohen-Sutherland<https://WikiPedia.org/wiki/Cohen-Sutherland_algorithm>},
43U{Forster-Hormann-Popa<https://www.ScienceDirect.com/science/article/pii/S259014861930007X>},
44U{Greiner-Hormann<http://www.inf.USI.CH/hormann/papers/Greiner.1998.ECO.pdf>},
45U{Liang-Barsky<https://www.CS.Helsinki.FI/group/goa/viewing/leikkaus/intro.html>} and
46U{Sutherland-Hodgman<https://WikiPedia.org/wiki/Sutherland-Hodgman_algorithm>} methods,
47functions to U{simplify<https://Bost.Ocks.org/mike/simplify>} or linearize a path of C{LatLon}
48points (or a U{NumPy array<https://docs.SciPy.org/doc/numpy/reference/generated/numpy.array.html>}),
49including implementations of the U{Ramer-Douglas-Peucker<https://WikiPedia.org/wiki/
50Ramer-Douglas-Peucker_algorithm>}, the U{Visvalingam-Whyatt<https://hydra.Hull.ac.UK/
51resources/hull:8338>} and the U{Reumann-Witkam<https://psimpl.SourceForge.net/reumann-witkam.html>}
52algorithms and modified versions of the former.
54Plus modules and classes to U{interpolate<https://docs.SciPy.org/doc/scipy/reference/interpolate.html>} the
55L{height<pygeodesy.heights>} of C{LatLon} points and L{Geoid<pygeodesy.geoids>} models, to compute various U{Fréchet
56<https://WikiPedia.org/wiki/Frechet_distance>} or U{Hausdorff<https://WikiPedia.org/wiki/Hausdorff_distance>}
57distances or to perform I{boolean} operations between (composite) polygons of C{LatLon} points.
59For further details see the U{documentation<https://mrJean1.GitHub.io/PyGeodesy>}, the descriptions of
60U{Latitude/Longitude<https://www.Movable-Type.co.UK/scripts/latlong.html>}, U{Vincenty
61<https://www.Movable-Type.co.UK/scripts/latlong-vincenty.html>} and U{Vector-based
62<https://www.Movable-Type.co.UK/scripts/latlong-vectors.html>} geodesy, the original U{JavaScript source
63<https://GitHub.com/ChrisVeness/geodesy>} or U{docs<https://www.Movable-Type.co.UK/scripts/geodesy/docs>}
64and I{Karney}'s Python U{geographiclib<https://PyPI.org/project/geographiclib>} and C++ U{GeographicLib
65<https://GeographicLib.SourceForge.io/C++/doc/index.html>}.
67Dependencies
68============
70Installation of I{Karney}'s Python package U{geographiclib<https://PyPI.org/project/geographiclib>}
71is optional, but required for module L{ellipsoidalKarney}, L{azimuthal} classes L{EquidistantKarney}
72and L{GnomonicKarney} and the L{HeightIDWkarney} interpolator.
74Both U{numpy<https://PyPI.org/project/numpy>} and U{scipy<https://PyPI.org/project/scipy>} must be
75installed for most L{Geoid...<pygeodesy.geoids>} and L{Height...<pygeodesy.heights>} interpolators,
76except L{GeoidKarney} and the L{HeightIDW...<pygeodesy.heights>} ones.
78Functions and C{LatLon} methods L{circin6}, L{circum3}, L{circum4_} and L{soddy4} and functions
79L{triaxum5} and L{trilaterate3d2} require U{numpy<https://PyPI.org/project/numpy>} to be installed,
80modules L{auxilats} and L{rhumb} may need U{numpy<https://PyPI.org/project/numpy>}.
82Modules L{ellipsoidalGeodSolve} and L{geodsolve} and L{azimuthal} classes L{EquidistantGeodSolve}
83and L{GnomonicGeodSolve} depend on I{Karney}'s C++ utility U{GeodSolve
84<https://GeographicLib.SourceForge.io/C++/doc/GeodSolve.1.html>} to be executable and set with
85env variable C{PYGEODESY_GEODSOLVE} or with property L{Ellipsoid.geodsolve}.
87Triaxial geodesic classes L{Geodesic3Solve} and L{GeodesicLine3Solve} in module L{geod3solve} need
88I{Karney}'s C++ utility U{Geod3Solve<https://GeographicLib.SourceForge.io/C++/doc/Geod3Solve.1.html>}
89to be executable and set with env variable C{PYGEODESY_GEOD3SOLVE} or with property
90L{Geodesic3Solve.Geod3Solve<geod3solve._Geodesic3SolveBase.Geod3Solve>}.
92Class L{Intersectool} in module L{geodesici} needs I{Karney}'s C++ utility U{IntersectTool
93<https://GeographicLib.SourceForge.io/C++/doc/IntersectTool.1.html>} to be executable and set with
94env variable C{PYGEODESY_INTERSECTTOOL} or with property L{Intersectool.IntersectTool
95<geodesici.Intersectool.IntersectTool>}.
97To compare C{MGRS} results from modules L{mgrs} and C{testMgrs} with I{Karney}'s C++ utility
98U{GeoConvert<https://GeographicLib.SourceForge.io/C++/doc/GeoConvert.1.html>}, the latter must
99be executable and set with env variable C{PYGEODESY_GEOCONVERT}.
101Module L{rhumb.solve} needs I{Karney}'s C++ utility U{RhumbSolve
102<https://GeographicLib.SourceForge.io/C++/doc/RhumbSolve.1.html>} to be executable and set with
103env variable C{PYGEODESY_RHUMBSOLVE} or with property L{Ellipsoid.rhumbsolve}.
105Notes
106=====
108For a summary of all I{Karney}-based functionality in C{pygeodesy}, see module U{karney
109<https://mrJean1.GitHub.io/PyGeodesy/docs/pygeodesy.karney-module.html>}.
111In 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
112characters and if so, I{not} C{unicode}.
114Env variables
115=============
117The following environment variables are observed by C{pygeodesy}:
119 - C{PYGEODESY_EXCEPTION_CHAINING} - see module L{errors<pygeodesy.errors>}.
120 - C{PYGEODESY_FMT_FORM} - see module L{dms<pygeodesy.dms>}.
121 - C{PYGEODESY_FSUM_F2PRODUCT} - see module L{fsums<pygeodesy.fsums>} and method L{f2product<pygeodesy.Fsum.f2product>}.
122 - C{PYGEODESY_FSUM_NONFINITES} - see module L{fsums<pygeodesy.fsums>} and method L{nonfinites<pygeodesy.Fsum.nonfinites>}.
123 - C{PYGEODESY_FSUM_RESIDUAL} - see module L{fsums<pygeodesy.fsums>} and method L{RESIDUAL<pygeodesy.Fsum.RESIDUAL>}.
124 - C{PYGEODESY_GEOCONVERT} - see module L{mgrs<pygeodesy.mgrs>}.
125 - C{PYGEODESY_GEODSOLVE} - see module L{geodsolve<pygeodesy.geodsolve>}.
126 - C{PYGEODESY_GEOD3SOLVE} - see module L{geod3solve<pygeodesy.geod3solve>}.
127 - C{PYGEODESY_INTERSECTTOOL} - see module L{geodesici<pygeodesy.geodesici>}.
128 - C{PYGEODESY_LAZY_IMPORT} - see module L{lazily<pygeodesy.lazily>} and variable L{isLazy<pygeodesy.isLazy>}.
129 - C{PYGEODESY_NOTIMPLEMENTED} - C{__special__} methods return C{NotImplemented} if set to "std".
130 - C{PYGEODESY_RHUMBSOLVE} - see module L{rhumb.solve<pygeodesy.rhumb.solve>}.
131 - C{PYGEODESY_UPS_POLES} - see modules L{ups<pygeodesy.ups>} and L{mgrs<pygeodesy.mgrs>}.
133and these to specify standard or I{named} C{repr}esentations:
135 - C{PYGEODESY_AZIMUTH_STD_REPR} - see method L{Azimuth<pygeodesy.Azimuth>}C{.__repr__}.
136 - C{PYGEODESY_BEARING_STD_REPR} - see method L{Bearing<pygeodesy.Bearing>}C{.__repr__}.
137 - C{PYGEODESY_BOOL_STD_REPR} - see method L{Bool<pygeodesy.Bool>}C{.__repr__}.
138 - C{PYGEODESY_DEGREES_STD_REPR} - see method L{Degrees<pygeodesy.Degrees>}C{.__repr__}.
139 - C{PYGEODESY_EPOCH_STD_REPR} - see method L{Float<pygeodesy.Epoch>}C{.__repr__}.
140 - C{PYGEODESY_FLOAT_STD_REPR} - see method L{Float<pygeodesy.Float>}C{.__repr__}.
141 - C{PYGEODESY_INT_STD_REPR} - see method L{Int<pygeodesy.Int>}C{.__repr__}.
142 - C{PYGEODESY_METER_STD_REPR} - see method L{Meter<pygeodesy.Meter>}C{.__repr__}.
143 - C{PYGEODESY_RADIANS_STD_REPR} - see method L{Radians<pygeodesy.Radians>}C{.__repr__}.
144 - C{PYGEODESY_STR_STD_REPR} - see method L{Str<pygeodesy.Str>}C{.__repr__}.
146plus during development:
148 - C{PYGEODESY_FOR_DOCS} - for extended documentation by C{epydoc}.
149 - C{PYGEODESY_GEOGRAPHICLIB} - see module L{karney<pygeodesy.karney>}.
150 - C{PYGEODESY_WARNINGS} - see module L{props<pygeodesy.props>} and function L{DeprecationWarnings<pygeodesy.DeprecationWarnings>}.
151 - C{PYGEODESY_XPACKAGES} - see module L{basics<pygeodesy.basics>}.
152 - C{PYTHONDEVMODE} - see modules L{errors<pygeodesy.errors>} and L{props<pygeodesy.props>}.
154and:
156 - C{PYGEODESY_INIT__ALL__} - Set env variable C{PYGEODESY_INIT__ALL__} to anything other than C{"__all__"} to avoid
157 importing all C{pygeodesy} modules unnecessarily (in Python 2 or with C{PYGEODESY_LAZY_IMPORT} turned off in Python
158 3). However, to import a C{pygeodesy} item, the item name must be qualified with the C{module} name, for example
159 C{ from pygeodesy.ellipsoidalExact import LatLon } or C{ from pygeodesy.deprecated import collins }
161License
162=======
164**) U{Copyright (C) 2016-2027 -- mrJean1 at Gmail -- All Rights Reserved.<https://OpenSource.org/licenses/MIT>}
166C{Permission is hereby granted, free of charge, to any person obtaining a copy of this software
167and associated documentation files (the "Software"), to deal in the Software without restriction,
168including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
169and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so,
170subject to the following conditions:}
172C{The above copyright notice and this permission notice shall be included in all copies or substantial
173portions of the Software.}
175C{THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT
176NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
177IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
178WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
179SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.}
181@newfield example: Example, Examples
183@var EPS: System's M{epsilon} ≈ 2.22044604925e-16 (C{float}).
184@var EPS0: M{EPS**2} ≈ 4.9e-32 for near-zero comparison
185@var EPS02: M{EPS**4} ≈ 2.4e-63 for near-zero squared comparison
186@var EPS1: M{1 - EPS} ≈ 0.9999999999999998 (C{float}).
187@var EPS2: M{EPS * 2} ≈ 4.440892098501e-16 (C{float}).
188@var EPS_2: M{EPS / 2} ≈ 1.110223024625e-16 (C{float}).
189@var EPS4: M{EPS * 4} ≈ 8.881784197001e-16 (C{float}).
190@var EPS8: M{EPS * 8} ≈ 1.776356839400e-15 (C{float}).
192@var F_D: Format degrees as unsigned "deg°" with symbol, plus compass point suffix C{N, S, E} or C{W} (C{str}).
193@var F_DM: Format degrees as unsigned "deg°min′" with symbols, plus suffix (C{str}).
194@var F_DMS: Format degrees as unsigned "deg°min′sec″" with symbols, plus suffix (C{str}).
195@var F_DEG: Format degrees as unsigned "[D]DD" I{without} symbol, plus suffix (C{str}).
196@var F_MIN: Format degrees as unsigned "[D]DDMM" I{without} symbols, plus suffix (C{str}).
197@var F_SEC: Format degrees as unsigned "[D]DDMMSS" I{without} symbols, plus suffix (C{str}).
198@var F_D60: Format degrees as unsigned "[D]DD.MMSS" C{sexagecimal} I{without} symbols, plus suffix (C{str}).
199@var F__E: Format degrees as unsigned "%E" I{without} symbols, plus suffix (C{str}).
200@var F__F: Format degrees as unsigned "%F" I{without} symbols, plus suffix (C{str}).
201@var F__G: Format degrees as unsigned "%G" I{without} symbols, plus suffix (C{str}).
202@var F_RAD: Convert degrees to radians and format as unsigned "RR" with symbol, plus suffix (C{str}).
204@var F_D_: Format degrees as signed "-/deg°" with symbol, I{without} suffix (C{str}).
205@var F_DM_: Format degrees as signed "-/deg°min′" with symbols, I{without} suffix (C{str}).
206@var F_DMS_: Format degrees as signed "-/deg°min′sec″" with symbols, I{without} suffix (C{str}).
207@var F_DEG_: Format degrees as signed "-/[D]DD" I{without} symbol, I{without} suffix (C{str}).
208@var F_MIN_: Format degrees as signed "-/[D]DDMM" I{without} symbols, I{without} suffix (C{str}).
209@var F_SEC_: Format degrees as signed "-/[D]DDMMSS" I{without} symbols, I{without} suffix (C{str}).
210@var F_D60_: Format degrees as signed "-/[D]DD.MMSS" C{sexagecimal} I{without} symbols, I{without} suffix (C{str}).
211@var F__E_: Format degrees as signed "-/%E" I{without} symbols, I{without} suffix (C{str}).
212@var F__F_: Format degrees as signed "-/%F" I{without} symbols, I{without} suffix (C{str}).
213@var F__G_: Format degrees as signed "-/%G" I{without} symbols, I{without} suffix (C{str}).
214@var F_RAD_: Convert degrees to radians and format as signed "-/RR" I{without} symbol, I{without} suffix (C{str}).
216@var F_D__: Format degrees as signed "-/+deg°" with symbol, I{without} suffix (C{str}).
217@var F_DM__: Format degrees as signed "-/+deg°min′" with symbols, I{without} suffix (C{str}).
218@var F_DMS__: Format degrees as signed "-/+deg°min′sec″" with symbols, I{without} suffix (C{str}).
219@var F_DEG__: Format degrees as signed "-/+[D]DD" I{without} symbol, I{without} suffix (C{str}).
220@var F_MIN__: Format degrees as signed "-/+[D]DDMM" I{without} symbols, without suffix (C{str}).
221@var F_SEC__: Format degrees as signed "-/+[D]DDMMSS" I{without} symbols, I{without} suffix (C{str}).
222@var F_D60__: Format degrees as signed "-/+[D]DD.MMSS" C{sexagecimal} I{without} symbols, I{without} suffix (C{str}).
223@var F__E__: Format degrees as signed "-/+%E" I{without} symbols, I{without} suffix (C{str}).
224@var F__F__: Format degrees as signed "-/+%F" I{without} symbols, I{without} suffix (C{str}).
225@var F__G__: Format degrees as signed "-/+%G" I{without} symbols, I{without} suffix (C{str}).
226@var F_RAD__: Convert degrees to radians and format as signed "-/+RR" I{without} symbol, I{without} suffix (C{str}).
228@var DIG: System's M{float decimal digits} = 15 (C{int}).
229@var INF: Infinity (C{float}), see functions L{isinf<pygeodesy.isinf>} and L{isfinite<pygeodesy.isfinite>} and C{NINF}.
230@var INT0: C{int(0)}, missing Z-components, C{if B{z}=B{INT0}}, see functions L{isint0<pygeodesy.isint0>}, L{meeus2<pygeodesy.meeus2>}
231@var MANT_DIG: System's M{float mantissa bits} = 53 (C{int}).
232@var MAX: System's M{float max} ≈ 1.798e+308 (C{float}).
233@var MIN: System's M{float min} ≈ 2.225e-308 (C{float}).
234@var NAN: Not-A-Number (C{float}), see function L{isnan<pygeodesy.isnan>}.
235@var NEG0: Negative 0.0 (C{float}), see function L{isneg0<pygeodesy.isneg0>}.
236@var NINF: Negative infinity (C{float}), see function L{isninf<pygeodesy.isninf>} and C{INF}.
237@var NN: Empty (C{str}), U{I{Nomen Nescio}<https://Wiktionary.org/wiki/N.N.>}.
239@var OVERFLOW: Object representing C{overflow} (1 / L{EPS0<pygeodesy.constants.EPS0>} = 4.9e+32).
241@var PI: Constant M{math.pi} (C{float}).
242@var PI2: Two PI, M{PI * 2}, aka I{Tau} (C{float}).
243@var PI_2: Half PI, M{PI / 2} (C{float}).
244@var PI3: Three PI, M{PI * 3} (C{float}).
245@var PI3_2: One and a half PI, M{PI * 3 / 2} (C{float}).
246@var PI_3: One third PI, M{PI / 3} (C{float}).
247@var PI4: Four PI, M{PI * 4} (C{float}).
248@var PI_4: Quarter PI, M{PI / 4} (C{float}).
249@var PI_6: One sixth PI, M{PI / 6} (C{float}).
251@var R_MA: Equatorial earth radius (C{meter}), WGS84, EPSG:3785.
252@var R_MB: Polar earth radius (C{meter}), WGS84, EPSG:3785.
253@var R_M: Mean (spherical) earth radius (C{meter}).
254@var R_KM: Mean (spherical) earth radius (C{Km}, kilometer).
255@var R_NM: Mean (spherical) earth radius (C{NM}, nautical miles).
256@var R_SM: Mean (spherical) earth radius (C{SM}, statute miles).
257@var R_FM: Former FAI-Sphere earth radius (C{meter}).
258@var R_GM: Average earth radius, distance to geoid surface (C{meter})
259@var R_QM: Earth' (triaxial) quadratic mean radius (C{meter})
260@var R_VM: Aviation/Navigation earth radius (C{meter}).
262@var S_DEG: Degrees symbol, default C{"°"}
263@var S_MIN: Minutes symbol, default C{"′"} aka I{PRIME}
264@var S_SEC: Seconds symbol, default C{"″"} aka I{DOUBLE_PRIME}
265@var S_RAD: Radians symbol, default C{""} aka L{NN<pygeodesy.NN>}
266@var S_DMS: If C{True}, include, otherwise cancel all DMS symbols, default C{True}.
267@var S_SEP: Separator between C{deg°|min′|sec″|suffix}, default C{""} aka L{NN<pygeodesy.NN>}
269@var Conics: Registered, predefined L{conics<pygeodesy.Conic>} (C{enum-like}).
270@var Datums: Registered, predefined L{datums<pygeodesy.Datum>} (C{enum-like}).
271@var Ellipsoids: Registered, predefined L{ellipsoids<pygeodesy.Ellipsoid>} (C{enum-like}).
272@var RefFrames: Registered, predefined L{reference frames<pygeodesy.RefFrame>} (C{enum-like}).
273@var Transforms: Registered, predefined L{transforms<pygeodesy.Transform>} (C{enum-like}).
274@var Triaxials: Registered, predefined L{triaxial ellipsoids<pygeodesy.Triaxial>} (C{enum-like}).
275@var Triaxial3s: Registered, predefined L{triaxial3 ellipsoids<pygeodesy.Triaxial3>} (C{enum-like}).
277@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.
279@var pygeodesy_abspath: Fully qualified C{pygeodesy} directory name (C{str}).
281@var version: Normalized C{pygeodesy} version (C{str}).
282'''
284import os.path as _os_path
285import sys as _sys
287_init__all__ = True
288# <https://PyInstaller.ReadTheDocs.io/en/stable/runtime-information.html>
289_isfrozen = getattr(_sys, 'frozen', False)
290pygeodesy_abspath = _os_path.dirname(_os_path.abspath(__file__)) # _sys._MEIPASS + '/pygeodesy'
291_pygeodesy_ = __package__ or _os_path.basename(pygeodesy_abspath)
293if _isfrozen: # avoid lazy import
294 _lazy_import2 = None
295else:
296 # setting __path__ should ...
297 __path__ = [pygeodesy_abspath]
298 try: # ... make this import work, ...
299 import pygeodesy.lazily as _
300 except ImportError: # ... if it doesn't, extend _sys.path to include
301 # this very directory such that all public and private sub-modules
302 # can be imported (by epydoc, checked by PyChecker, etc.)
303 _sys.path.insert(0, pygeodesy_abspath) # XXX __path__[0]
305 try: # lazily requires Python 3.7+, see lazily.__doc__
306 from pygeodesy.lazily import _init__all__, _lazy_import2 # PYCHOK expected
307 _, __getattr__ = _lazy_import2(_pygeodesy_) # PYCHOK expected
309 except (ImportError, NotImplementedError): # LazyImportError
310 _lazy_import2 = None
312if _init__all__ and not _lazy_import2: # import and set __all__
314 # import all public modules and export as such
315 import pygeodesy.albers as albers # noqa: F401
316 import pygeodesy.angles as angles # noqa: F401
317 import pygeodesy.auxilats as auxilats # noqa: F401
318 import pygeodesy.azimuthal as azimuthal # noqa: F401
319 import pygeodesy.basics as basics # noqa: F401
320 import pygeodesy.booleans as booleans # noqa: F401
321 import pygeodesy.cartesianBase as cartesianBase # noqa: F401 INTERNAL
322 import pygeodesy.clipy as clipy # noqa: F401
323 import pygeodesy.constants as constants # noqa: F401
324 import pygeodesy.css as css # noqa: F401
325 import pygeodesy.datums as datums # noqa: F401
326 import pygeodesy.deprecated as deprecated # noqa: F401
327 import pygeodesy.dms as dms # noqa: F401
328 import pygeodesy.ecef as ecef # noqa: F401
329 import pygeodesy.ecefLocals as ecefLocals # noqa: F401
330 import pygeodesy.elevations as elevations # noqa: F401
331 import pygeodesy.ellipses as ellipses # noqa: F401
332 import pygeodesy.ellipsoidalBase as ellipsoidalBase # noqa: F401 INTERNAL
333 import pygeodesy.ellipsoidalBaseDI as ellipsoidalBaseDI # noqa: F401 INTERNAL
334 import pygeodesy.ellipsoidalExact as ellipsoidalExact # noqa: F401
335 import pygeodesy.ellipsoidalGeodSolve as ellipsoidalGeodSolve # noqa: F401
336 import pygeodesy.ellipsoidalKarney as ellipsoidalKarney # noqa: F401
337 import pygeodesy.ellipsoidalNvector as ellipsoidalNvector # noqa: F401
338 import pygeodesy.ellipsoidalVincenty as ellipsoidalVincenty # noqa: F401
339 import pygeodesy.ellipsoids as ellipsoids # noqa: F401
340 import pygeodesy.elliptic as elliptic # noqa: F401
341 import pygeodesy.epsg as epsg # noqa: F401
342 import pygeodesy.etm as etm # noqa: F401
343 import pygeodesy.errors as errors # noqa: F401
344 import pygeodesy.fmath as fmath # noqa: F401
345 import pygeodesy.formy as formy # noqa: F401
346 import pygeodesy.frechet as frechet # noqa: F401
347 import pygeodesy.fstats as fstats # noqa: F401
348 import pygeodesy.fsums as fsums # noqa: F401
349 import pygeodesy.gars as gars # noqa: F401
350 import pygeodesy.geodesici as geodesici # noqa: F401
351 import pygeodesy.geodesicw as geodesicw # noqa: F401
352 import pygeodesy.geodesicx as geodesicx # noqa: F401
353 import pygeodesy.geodsolve as geodsolve # noqa: F401
354 import pygeodesy.geod3solve as geod3solve # noqa: F401
355 import pygeodesy.geohash as geohash # noqa: F401
356 import pygeodesy.geoids as geoids # noqa: F401
357 import pygeodesy.hausdorff as hausdorff # noqa: F401
358 import pygeodesy.heights as heights # noqa: F401
359 import pygeodesy.hom as hom # noqa: F401
360 import pygeodesy.internals as internals # noqa: F401
361 import pygeodesy.interns as interns # noqa: F401
362 import pygeodesy.iters as iters # noqa: F401
363 import pygeodesy.karney as karney # noqa: F401
364 import pygeodesy.ktm as ktm # noqa: F401
365 import pygeodesy.latlonBase as latlonBase # noqa: F401 INTERNAL
366 import pygeodesy.lazily as lazily # noqa: F401
367 import pygeodesy.lcc as lcc # noqa: F401
368 import pygeodesy.lom as lom # noqa: F401
369 import pygeodesy.ltp as ltp # noqa: F401
370 import pygeodesy.ltpTuples as ltpTuples # noqa: F401
371 import pygeodesy.mgrs as mgrs # noqa: F401
372 import pygeodesy.named as named # noqa: F401
373 import pygeodesy.namedTuples as namedTuples # noqa: F401
374 import pygeodesy.nvectorBase as nvectorBase # noqa: F401 INTERNAL
375 import pygeodesy.osgr as osgr # noqa: F401
376 import pygeodesy.points as points # noqa: F401
377 import pygeodesy.props as props # noqa: F401
378 import pygeodesy.resections as resections # noqa: F401
379 import pygeodesy.rhumb as rhumb # noqa: F401
380 import pygeodesy.simplify as simplify # noqa: F401
381 import pygeodesy.sphericalBase as sphericalBase # noqa: F401 INTERNAL
382 import pygeodesy.sphericalNvector as sphericalNvector # noqa: F401
383 import pygeodesy.sphericalTrigonometry as sphericalTrigonometry # noqa: F401
384 import pygeodesy.solveBase as solveBase # noqa: F401
385 import pygeodesy.streprs as streprs # noqa: F401
386 import pygeodesy.trf as trf # noqa: F401
387 import pygeodesy.triaxials as triaxials # noqa: F401
388 import pygeodesy.units as units # noqa: F401
389 import pygeodesy.unitsBase as unitsBase # noqa: F401 INTERNAL
390 import pygeodesy.ups as ups # noqa: F401
391 import pygeodesy.utily as utily # noqa: F401
392 import pygeodesy.utm as utm # noqa: F401
393 import pygeodesy.utmups as utmups # noqa: F401
394 import pygeodesy.utmupsBase as utmupsBase # noqa: F401 INTERNAL
395 import pygeodesy.vector2d as vector2d # noqa: F401
396 import pygeodesy.vector3d as vector3d # noqa: F401
397 import pygeodesy.vector3dBase as vector3dBase # noqa: F401 INTERNAL
398 import pygeodesy.webmercator as webmercator # noqa: F401
399 import pygeodesy.wgrs as wgrs # noqa: F401
401 # lift all public classes, constants, functions, etc. but ONLY
402 # from the following modules ... (see also David Beazley's
403 # talk <https://DaBeaz.com/modulepackage/index.html>) ... BUT
404 # NOT modules ellipsoidal*, epsg, gars, geohash, spherical*,
405 # vector and wgrs ... in order keep those as modules ONLY
406 from pygeodesy.albers import * # noqa: F403
407 from pygeodesy.angles import * # noqa: F403
408 from pygeodesy.azimuthal import * # noqa: F403
409# from pygeodesy.auxilats import * # noqa: F403
410 from pygeodesy.basics import * # noqa: F403
411 from pygeodesy.booleans import * # noqa: F403
412 from pygeodesy.cartesianBase import * # noqa: F403 INTERNAL
413 from pygeodesy.clipy import * # noqa: F403
414 from pygeodesy.constants import * # noqa: F403
415 from pygeodesy.css import * # noqa: F403
416 from pygeodesy.datums import * # noqa: F403
417 from pygeodesy.deprecated import * # noqa: F403 DEPRECATED
418 from pygeodesy.dms import * # noqa: F403
419 from pygeodesy.ecef import * # noqa: F403
420# from pygeodesy.ecefLocals import * # noqa: F403
421 from pygeodesy.elevations import * # noqa: F403
422 from pygeodesy.ellipses import * # noqa: F403
423# from pygeodesy.ellipsoidalBase import * # noqa: F403 INTERNAL
424# from pygeodesy.ellipsoidalBaseDI import * # noqa: F403 INTERNAL
425# from pygeodesy.ellipsoidalExact import * # noqa: F403
426# from pygeodesy.ellipsoidalGeodSolve import * # noqa: F403
427# from pygeodesy.ellipsoidalKarney import * # noqa: F403
428# from pygeodesy.ellipsoidalNvector import * # noqa: F403
429 from pygeodesy.ellipsoidalVincenty import * # noqa: F403
430 from pygeodesy.ellipsoids import * # noqa: F403
431 from pygeodesy.elliptic import * # noqa: F403
432 from pygeodesy.epsg import * # noqa: F403
433 from pygeodesy.etm import * # noqa: F403
434 from pygeodesy.errors import * # noqa: F403
435 from pygeodesy.fmath import * # noqa: F403
436 from pygeodesy.formy import * # noqa: F403
437 from pygeodesy.frechet import * # noqa: F403
438 from pygeodesy.fstats import * # noqa: F403
439 from pygeodesy.fsums import * # noqa: F403
440 from pygeodesy.gars import * # noqa: F403
441 from pygeodesy.geodesici import * # noqa: F403
442 from pygeodesy.geodesicw import * # noqa: F403
443 from pygeodesy.geodesicx import * # noqa: F403
444 from pygeodesy.geodsolve import * # noqa: F403
445 from pygeodesy.geod3solve import * # noqa: F403
446 from pygeodesy.geohash import * # noqa: F403
447 from pygeodesy.geoids import * # noqa: F403
448 from pygeodesy.hausdorff import * # noqa: F403
449 from pygeodesy.heights import * # noqa: F403
450 from pygeodesy.hom import * # noqa: F403
451 from pygeodesy.internals import * # noqa: F403
452 from pygeodesy.interns import * # noqa: F403
453 from pygeodesy.iters import * # noqa: F403
454 from pygeodesy.karney import * # noqa: F403
455 from pygeodesy.ktm import * # noqa: F403
456 from pygeodesy.latlonBase import * # noqa: F403 INTERNAL
457 from pygeodesy.lazily import * # noqa: F403
458 from pygeodesy.lcc import * # noqa: F403
459 from pygeodesy.lom import * # noqa: F403
460 from pygeodesy.ltp import * # noqa: F403
461 from pygeodesy.ltpTuples import * # noqa: F403
462 from pygeodesy.mgrs import * # noqa: F403
463 from pygeodesy.named import * # noqa: F403
464 from pygeodesy.namedTuples import * # noqa: F403
465 from pygeodesy.nvectorBase import * # noqa: F403 INTERNAL
466 from pygeodesy.osgr import * # noqa: F403
467 from pygeodesy.points import * # noqa: F403
468 from pygeodesy.props import * # noqa: F403
469 from pygeodesy.resections import * # noqa: F403
470 from pygeodesy.rhumb import * # noqa: F403
471 from pygeodesy.simplify import * # noqa: F403
472# from pygeodesy.sphericalBase import * # noqa: F403 INTERNAL
473# from pygeodesy.sphericalNvector import * # noqa: F403
474# from pygeodesy.sphericalTrigonometry import * # noqa: F403
475# from pygeodesy.solveBase import * # noqa: F403 INTERNAL
476 from pygeodesy.streprs import * # noqa: F403
477 from pygeodesy.trf import * # noqa: F403
478 from pygeodesy.triaxials import * # noqa: F403
479# from pygeodesy.triaxials.bases import * # noqa: F403
480# from pygeodesy.triaxials.conformals import * # noqa: F403
481# from pygeodesy.triaxials.spheres import * # noqa: F403
482# from pygeodesy.triaxials.triaxial3 import * # noqa: F403
483# from pygeodesy.triaxials.triaxial5 import * # noqa: F403
484 from pygeodesy.units import * # noqa: F403
485 from pygeodesy.unitsBase import * # noqa: F403 Float, ...
486 from pygeodesy.ups import * # noqa: F403
487 from pygeodesy.utily import * # noqa: F403
488 from pygeodesy.utm import * # noqa: F403
489 from pygeodesy.utmups import * # noqa: F403
490# from pygeodesy.utmupsBase import * # noqa: F403 INTERNAL
491 from pygeodesy.vector2d import * # noqa: F403
492 from pygeodesy.vector3d import * # noqa: F403
493 from pygeodesy.vector3dBase import * # noqa: F403 INTERNAL
494 from pygeodesy.webmercator import * # noqa: F403
495 from pygeodesy.wgrs import * # noqa: F403
497 def _all(globalocals):
498 from pygeodesy.internals import _headof, _DOT_ # PYCHOK expected
499 from pygeodesy.interns import NN as _NN, _attribute_, _COMMASPACE_, \
500 _module_, _s_ # PYCHOK expected
501 from pygeodesy.streprs import Fmt as _Fmt # PYCHOK expected
502 # collect all public module and attribute names and check
503 # that modules are imported from this package, 'pygeodesy'
504 # (but the latter only when not bundled with PyInstaller or
505 # Py2Exe, since the file-layout is different. Courtesy of
506 # GilderGeek<https://GitHub.com/mrJean1/PyGeodesy/issues/31>)
507 ns = list(lazily._ALL_INIT)
508# XXX ps = () if _isfrozen else set([_pygeodesy_] + __name__.split(_DOT_))
509 for mod, attrs in lazily._all_enums():
510 mod = _headof(_headof(mod))
511 if mod not in globalocals:
512 t = _DOT_(_pygeodesy_, mod)
513 raise ImportError('missing %s%s: %s' % (_module_, _NN, t))
514 ns.append(mod)
515 # check that all other public attrs do exist
516 if attrs and isinstance(attrs, tuple):
517 attrs = lazily._ALL_ATTRS(attrs)
518 t = tuple(a for a in attrs if a not in globalocals)
519 if t:
520 s = _Fmt.SQUARE(_s_, len(t)) if len(t) > 1 else _NN
521 t = _COMMASPACE_.join(_DOT_(_pygeodesy_, mod, a) for a in t)
522 raise ImportError('missing %s%s: %s' % (_attribute_, s, t))
523 ns.extend(attrs)
524# XXX if ps: # check that mod is a _pygeodesy_ module
525# XXX m = globalocals[mod] # assert(typename(m) == mod)
526# XXX f = getattr(m, _dunder_file_, _NN)
527# XXX d = _os_path.dirname(_os_path.abspath(f)) if f else pygeodesy_abspath
528# XXX p = getattr(m, _dunder_package_, _NN) or _pygeodesy_
529# XXX if p not in ps or d != pygeodesy_abspath:
530# XXX t = '%s from %r' % (_DOT_(p, mod), f or p)
531# XXX raise ImportError('foreign %s: %s' % (_module_, t))
532 return tuple(set(ns)) # remove duplicates
534 __all__ = _all(globals()) # or locals()
535else:
536 __all__ = ()
537 _init__all__ = False
539from pygeodesy.internals import _version2, _DOT_ # noqa: E402
540# from pygeodesy.interns import _DOT_ # from .internals
541__version__ = '26.11.11'
542# see setup.py for similar logic
543version = _DOT_(*_version2(__version__, n=3))
545del _DOT_, _lazy_import2, _os_path, _sys, _version2
547# **) MIT License
548#
549# Copyright (C) 2016-2027 -- mrJean1 at Gmail -- All Rights Reserved.
550#
551# Permission is hereby granted, free of charge, to any person obtaining a
552# copy of this software and associated documentation files (the "Software"),
553# to deal in the Software without restriction, including without limitation
554# the rights to use, copy, modify, merge, publish, distribute, sublicense,
555# and/or sell copies of the Software, and to permit persons to whom the
556# Software is furnished to do so, subject to the following conditions:
557#
558# The above copyright notice and this permission notice shall be included
559# in all copies or substantial portions of the Software.
560#
561# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
562# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
563# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
564# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
565# OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
566# ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
567# OTHER DEALINGS IN THE SOFTWARE.