pygeodesy 24.3.24__py2.py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- PyGeodesy-24.3.24.dist-info/METADATA +272 -0
- PyGeodesy-24.3.24.dist-info/RECORD +115 -0
- PyGeodesy-24.3.24.dist-info/WHEEL +6 -0
- PyGeodesy-24.3.24.dist-info/top_level.txt +1 -0
- pygeodesy/LICENSE +21 -0
- pygeodesy/__init__.py +615 -0
- pygeodesy/__main__.py +103 -0
- pygeodesy/albers.py +867 -0
- pygeodesy/auxilats/_CX_4.py +218 -0
- pygeodesy/auxilats/_CX_6.py +314 -0
- pygeodesy/auxilats/_CX_8.py +475 -0
- pygeodesy/auxilats/__init__.py +54 -0
- pygeodesy/auxilats/__main__.py +86 -0
- pygeodesy/auxilats/auxAngle.py +548 -0
- pygeodesy/auxilats/auxDLat.py +302 -0
- pygeodesy/auxilats/auxDST.py +296 -0
- pygeodesy/auxilats/auxLat.py +848 -0
- pygeodesy/auxilats/auxily.py +272 -0
- pygeodesy/azimuthal.py +1150 -0
- pygeodesy/basics.py +892 -0
- pygeodesy/booleans.py +2031 -0
- pygeodesy/cartesianBase.py +1062 -0
- pygeodesy/clipy.py +704 -0
- pygeodesy/constants.py +516 -0
- pygeodesy/css.py +660 -0
- pygeodesy/datums.py +752 -0
- pygeodesy/deprecated/__init__.py +61 -0
- pygeodesy/deprecated/bases.py +40 -0
- pygeodesy/deprecated/classes.py +262 -0
- pygeodesy/deprecated/consterns.py +54 -0
- pygeodesy/deprecated/datum.py +40 -0
- pygeodesy/deprecated/functions.py +375 -0
- pygeodesy/deprecated/nvector.py +48 -0
- pygeodesy/deprecated/rhumbBase.py +32 -0
- pygeodesy/deprecated/rhumbaux.py +33 -0
- pygeodesy/deprecated/rhumbsolve.py +33 -0
- pygeodesy/deprecated/rhumbx.py +33 -0
- pygeodesy/dms.py +986 -0
- pygeodesy/ecef.py +1348 -0
- pygeodesy/elevations.py +279 -0
- pygeodesy/ellipsoidalBase.py +1224 -0
- pygeodesy/ellipsoidalBaseDI.py +913 -0
- pygeodesy/ellipsoidalExact.py +343 -0
- pygeodesy/ellipsoidalGeodSolve.py +343 -0
- pygeodesy/ellipsoidalKarney.py +403 -0
- pygeodesy/ellipsoidalNvector.py +685 -0
- pygeodesy/ellipsoidalVincenty.py +590 -0
- pygeodesy/ellipsoids.py +2476 -0
- pygeodesy/elliptic.py +1198 -0
- pygeodesy/epsg.py +243 -0
- pygeodesy/errors.py +804 -0
- pygeodesy/etm.py +1190 -0
- pygeodesy/fmath.py +1013 -0
- pygeodesy/formy.py +1818 -0
- pygeodesy/frechet.py +865 -0
- pygeodesy/fstats.py +760 -0
- pygeodesy/fsums.py +1898 -0
- pygeodesy/gars.py +358 -0
- pygeodesy/geodesicw.py +581 -0
- pygeodesy/geodesicx/_C4_24.py +1699 -0
- pygeodesy/geodesicx/_C4_27.py +2395 -0
- pygeodesy/geodesicx/_C4_30.py +3301 -0
- pygeodesy/geodesicx/__init__.py +48 -0
- pygeodesy/geodesicx/__main__.py +91 -0
- pygeodesy/geodesicx/gx.py +1382 -0
- pygeodesy/geodesicx/gxarea.py +535 -0
- pygeodesy/geodesicx/gxbases.py +154 -0
- pygeodesy/geodesicx/gxline.py +669 -0
- pygeodesy/geodsolve.py +426 -0
- pygeodesy/geohash.py +914 -0
- pygeodesy/geoids.py +1884 -0
- pygeodesy/hausdorff.py +892 -0
- pygeodesy/heights.py +1155 -0
- pygeodesy/interns.py +687 -0
- pygeodesy/iters.py +545 -0
- pygeodesy/karney.py +919 -0
- pygeodesy/ktm.py +633 -0
- pygeodesy/latlonBase.py +1766 -0
- pygeodesy/lazily.py +960 -0
- pygeodesy/lcc.py +684 -0
- pygeodesy/ltp.py +1107 -0
- pygeodesy/ltpTuples.py +1563 -0
- pygeodesy/mgrs.py +721 -0
- pygeodesy/named.py +1324 -0
- pygeodesy/namedTuples.py +683 -0
- pygeodesy/nvectorBase.py +695 -0
- pygeodesy/osgr.py +781 -0
- pygeodesy/points.py +1686 -0
- pygeodesy/props.py +628 -0
- pygeodesy/resections.py +1048 -0
- pygeodesy/rhumb/__init__.py +46 -0
- pygeodesy/rhumb/aux_.py +397 -0
- pygeodesy/rhumb/bases.py +1148 -0
- pygeodesy/rhumb/ekx.py +563 -0
- pygeodesy/rhumb/solve.py +572 -0
- pygeodesy/simplify.py +647 -0
- pygeodesy/solveBase.py +472 -0
- pygeodesy/sphericalBase.py +724 -0
- pygeodesy/sphericalNvector.py +1264 -0
- pygeodesy/sphericalTrigonometry.py +1447 -0
- pygeodesy/streprs.py +627 -0
- pygeodesy/trf.py +2079 -0
- pygeodesy/triaxials.py +1484 -0
- pygeodesy/units.py +969 -0
- pygeodesy/unitsBase.py +349 -0
- pygeodesy/ups.py +538 -0
- pygeodesy/utily.py +1231 -0
- pygeodesy/utm.py +762 -0
- pygeodesy/utmups.py +318 -0
- pygeodesy/utmupsBase.py +517 -0
- pygeodesy/vector2d.py +785 -0
- pygeodesy/vector3d.py +968 -0
- pygeodesy/vector3dBase.py +1049 -0
- pygeodesy/webmercator.py +383 -0
- pygeodesy/wgrs.py +439 -0
pygeodesy/epsg.py
ADDED
|
@@ -0,0 +1,243 @@
|
|
|
1
|
+
|
|
2
|
+
# -*- coding: utf-8 -*-
|
|
3
|
+
|
|
4
|
+
u'''European Petroleum Survey Group (EPSG) en-/decoding.
|
|
5
|
+
|
|
6
|
+
Classes L{Epsg} and L{EPSGError} and functions to L{encode} and L{decode2}
|
|
7
|
+
(U{EPSG<https://EPSG.org>}) codes from and to U{UTM
|
|
8
|
+
<https://WikiPedia.org/wiki/Universal_Transverse_Mercator_coordinate_system>} and
|
|
9
|
+
U{UPS<https://WikiPedia.org/wiki/Universal_polar_stereographic_coordinate_system>}
|
|
10
|
+
zones.
|
|
11
|
+
|
|
12
|
+
A pure Python implementation transcoded from I{Charles Karney}'s C++ class U{UTMUPS
|
|
13
|
+
<https://GeographicLib.SourceForge.io/C++/doc/classGeographicLib_1_1UTMUPS.html>},
|
|
14
|
+
including coverage of UPS as zone C{0}.
|
|
15
|
+
'''
|
|
16
|
+
|
|
17
|
+
from pygeodesy.basics import isint, isstr, _xinstanceof
|
|
18
|
+
from pygeodesy.errors import _ValueError
|
|
19
|
+
from pygeodesy.interns import NN, _N_, _NS_, _S_, _SPACE_
|
|
20
|
+
from pygeodesy.lazily import _ALL_LAZY, _ALL_OTHER
|
|
21
|
+
from pygeodesy.namedTuples import UtmUps2Tuple
|
|
22
|
+
from pygeodesy.props import Property_RO
|
|
23
|
+
from pygeodesy.streprs import Fmt
|
|
24
|
+
from pygeodesy.units import Int
|
|
25
|
+
from pygeodesy.ups import Ups
|
|
26
|
+
from pygeodesy.utm import Utm
|
|
27
|
+
from pygeodesy.utmupsBase import _to3zBhp, _UPS_ZONE, _UTM_ZONE_MIN, \
|
|
28
|
+
_UTM_ZONE_MAX, _UTMUPS_ZONE_INVALID
|
|
29
|
+
|
|
30
|
+
__all__ = _ALL_LAZY.epsg
|
|
31
|
+
__version__ = '22.09.24'
|
|
32
|
+
|
|
33
|
+
# _EPSG_INVALID = _UTMUPS_ZONE_INVALID
|
|
34
|
+
_EPSG_N_01 = 32601 # EPSG code for UTM zone 01 N
|
|
35
|
+
_EPSG_N_60 = 32660 # EPSG code for UTM zone 60 N
|
|
36
|
+
_EPSG_N = 32661 # EPSG code for UPS pole N
|
|
37
|
+
|
|
38
|
+
_EPSG_S_01 = 32701 # EPSG code for UTM zone 01 S
|
|
39
|
+
_EPSG_S_60 = 32760 # EPSG code for UTM zone 60 S
|
|
40
|
+
_EPSG_S = 32761 # EPSG code for UPS pole S
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
class Epsg(Int):
|
|
44
|
+
'''U{EPSG<https://EPSG.org>} class, a named C{int}.
|
|
45
|
+
'''
|
|
46
|
+
_band = NN
|
|
47
|
+
_epsg = None
|
|
48
|
+
_hemisphere = NN
|
|
49
|
+
_utmups = None
|
|
50
|
+
_zone = _UTMUPS_ZONE_INVALID
|
|
51
|
+
|
|
52
|
+
def __new__(cls, eisu, name=NN):
|
|
53
|
+
'''New L{Epsg} (I{European Petroleum Survey Group}) code from a
|
|
54
|
+
UTM/USP coordinate or other EPSG code.
|
|
55
|
+
|
|
56
|
+
@arg eisu: Other code (L{Epsg}, C{int}, C{str}, L{Utm} or L{Ups}).
|
|
57
|
+
|
|
58
|
+
@return: New L{Epsg}.
|
|
59
|
+
|
|
60
|
+
@raise TypeError: Invalid B{C{eisu}}.
|
|
61
|
+
|
|
62
|
+
@raise EPSGError: Invalid B{C{eisu}}.
|
|
63
|
+
'''
|
|
64
|
+
if isinstance(eisu, Epsg):
|
|
65
|
+
self = int.__new__(cls, int(eisu))
|
|
66
|
+
self._band = eisu.band
|
|
67
|
+
self._epsg = self # XXX eisu
|
|
68
|
+
self._hemisphere = eisu.hemisphere
|
|
69
|
+
self._utmups = eisu.utmups
|
|
70
|
+
self._zone = eisu.zone
|
|
71
|
+
if eisu.name:
|
|
72
|
+
self.name = eisu.name
|
|
73
|
+
|
|
74
|
+
elif isint(eisu):
|
|
75
|
+
self = int.__new__(cls, eisu)
|
|
76
|
+
self._epsg = eisu
|
|
77
|
+
self._zone, self._hemisphere = decode2(eisu) # PYCHOK UtmUps2Tuple
|
|
78
|
+
|
|
79
|
+
elif isstr(eisu):
|
|
80
|
+
self = encode(eisu)
|
|
81
|
+
|
|
82
|
+
else:
|
|
83
|
+
u = eisu
|
|
84
|
+
_xinstanceof(Utm, Ups, eisu=u)
|
|
85
|
+
self = encode(u.zone, hemipole=u.hemisphere, band=u.band) # PYCHOK **kwds
|
|
86
|
+
self._utmups = u
|
|
87
|
+
if u.name:
|
|
88
|
+
self.name = u.name
|
|
89
|
+
|
|
90
|
+
if name:
|
|
91
|
+
self.name = name
|
|
92
|
+
return self
|
|
93
|
+
|
|
94
|
+
def __repr__(self):
|
|
95
|
+
return Fmt.PAREN(self.named, int.__repr__(self))
|
|
96
|
+
|
|
97
|
+
def __str__(self):
|
|
98
|
+
return int.__str__(self)
|
|
99
|
+
|
|
100
|
+
@Property_RO
|
|
101
|
+
def band(self):
|
|
102
|
+
'''Get the I{latitudinal} UTM or I{polar} UPS Band
|
|
103
|
+
(C{'A'|'B'|'C'|'D'|..|'W'|'X'|'Y'|'Z'} or C{""}).
|
|
104
|
+
'''
|
|
105
|
+
return self._band
|
|
106
|
+
|
|
107
|
+
@Property_RO
|
|
108
|
+
def hemisphere(self):
|
|
109
|
+
'''Get the UTM/UPS hemisphere/-pole (C{'N'|'S'}).
|
|
110
|
+
'''
|
|
111
|
+
return self._hemisphere
|
|
112
|
+
|
|
113
|
+
@Property_RO
|
|
114
|
+
def utmups(self):
|
|
115
|
+
'''Get the UTM/UPS original (L{Utm}, L{Ups}).
|
|
116
|
+
'''
|
|
117
|
+
return self._utmups
|
|
118
|
+
|
|
119
|
+
def utmupsStr(self, B=False):
|
|
120
|
+
'''Get the UTM/UPS zone, band and hemisphere/-pole (C{str}).
|
|
121
|
+
'''
|
|
122
|
+
b = self.band if B else NN
|
|
123
|
+
h = s = self.hemisphere
|
|
124
|
+
if h:
|
|
125
|
+
s = _SPACE_
|
|
126
|
+
return NN(Fmt.zone(self.zone), b, s, h)
|
|
127
|
+
|
|
128
|
+
@Property_RO
|
|
129
|
+
def zone(self):
|
|
130
|
+
'''Get the (longitudinal) UTM/UPS zone (C{int}, C{1..60} for UTM, C{0} for UPS).
|
|
131
|
+
'''
|
|
132
|
+
return self._zone
|
|
133
|
+
|
|
134
|
+
|
|
135
|
+
class EPSGError(_ValueError):
|
|
136
|
+
'''EPSG encode, decode or other L{Epsg} issue.
|
|
137
|
+
'''
|
|
138
|
+
pass
|
|
139
|
+
|
|
140
|
+
|
|
141
|
+
def decode2(epsg):
|
|
142
|
+
'''Determine the UTM/USP zone and hemisphere from a given
|
|
143
|
+
U{EPSG<https://EPSG.org>}.
|
|
144
|
+
|
|
145
|
+
@arg epsg: The EPSG (L{Epsg}, C{str} or C{scalar}).
|
|
146
|
+
|
|
147
|
+
@return: A L{UtmUps2Tuple}C{(zone, hemipole)}.
|
|
148
|
+
|
|
149
|
+
@raise EPSGError: Invalid B{C{epsg}}.
|
|
150
|
+
|
|
151
|
+
@note: Coverage of UPS as zone C{0} follows I{Karney}'s function U{UTMUPS::DecodeEPSG
|
|
152
|
+
<https://GeographicLib.SourceForge.io/C++/doc/classGeographicLib_1_1UTMUPS.html>}.
|
|
153
|
+
'''
|
|
154
|
+
if isinstance(epsg, Epsg):
|
|
155
|
+
z, h = epsg.zone, epsg.hemisphere
|
|
156
|
+
|
|
157
|
+
else:
|
|
158
|
+
try:
|
|
159
|
+
e = int(epsg) # int(long) OK
|
|
160
|
+
if _EPSG_N_01 <= e <= _EPSG_N_60:
|
|
161
|
+
z, h = int(e - _EPSG_N_01 + _UTM_ZONE_MIN), _N_
|
|
162
|
+
|
|
163
|
+
elif _EPSG_S_01 <= e <= _EPSG_S_60:
|
|
164
|
+
z, h = int(e - _EPSG_S_01 + _UTM_ZONE_MIN), _S_
|
|
165
|
+
|
|
166
|
+
elif e == _EPSG_N:
|
|
167
|
+
z, h = _UPS_ZONE, _N_
|
|
168
|
+
|
|
169
|
+
elif e == _EPSG_S:
|
|
170
|
+
z, h = _UPS_ZONE, _S_
|
|
171
|
+
|
|
172
|
+
else:
|
|
173
|
+
raise ValueError(NN)
|
|
174
|
+
except (TypeError, ValueError) as x:
|
|
175
|
+
raise EPSGError(epsg=epsg, cause=x)
|
|
176
|
+
|
|
177
|
+
return UtmUps2Tuple(z, h)
|
|
178
|
+
|
|
179
|
+
|
|
180
|
+
def encode(zone, hemipole=NN, band=NN):
|
|
181
|
+
'''Determine the U{EPSG<https://EPSG.org>} code for
|
|
182
|
+
a given UTM/UPS zone number, hemisphere/pole and/or Band.
|
|
183
|
+
|
|
184
|
+
@arg zone: The (longitudinal) UTM zone (C{int}, 1..60) or UPS
|
|
185
|
+
zone (C{int}, 0) or UTM zone with/-out I{latitudinal}
|
|
186
|
+
Band letter (C{str}, '01C'..'60X') or UPS zone
|
|
187
|
+
with/-out I{polar} Band letter (C{str}, '00A', '00B',
|
|
188
|
+
'00Y' or '00Z').
|
|
189
|
+
@kwarg hemipole: UTM/UPS hemisphere or UPS projection top/center
|
|
190
|
+
pole (C{str}, C{'N[orth]'} or C{'S[outh]'}).
|
|
191
|
+
@kwarg band: Optional I{latitudinal} UTM or I{polar} UPS Band
|
|
192
|
+
letter (C{str}).
|
|
193
|
+
|
|
194
|
+
@return: C{EPSG} code (L{Epsg}).
|
|
195
|
+
|
|
196
|
+
@raise EPSGError: Invalid B{C{zone}}, B{C{hemipole}} or B{C{band}}.
|
|
197
|
+
|
|
198
|
+
@note: Coverage of UPS as zone C{0} follows I{Karney}'s function U{UTMUPS::EncodeEPSG
|
|
199
|
+
<https://GeographicLib.SourceForge.io/C++/doc/classGeographicLib_1_1UTMUPS.html>}.
|
|
200
|
+
'''
|
|
201
|
+
try:
|
|
202
|
+
z, B, hp = _to3zBhp(zone, band, hemipole=hemipole) # in .utmupsBase
|
|
203
|
+
if hp not in _NS_:
|
|
204
|
+
raise ValueError
|
|
205
|
+
except (TypeError, ValueError) as x:
|
|
206
|
+
raise EPSGError(zone=zone, hemipole=hemipole, band=band, cause=x)
|
|
207
|
+
|
|
208
|
+
if _UTM_ZONE_MIN <= z <= _UTM_ZONE_MAX:
|
|
209
|
+
e = z - _UTM_ZONE_MIN + (_EPSG_N_01 if hp == _N_ else _EPSG_S_01)
|
|
210
|
+
elif z == _UPS_ZONE:
|
|
211
|
+
e = _EPSG_N if hp == _N_ else _EPSG_S
|
|
212
|
+
else:
|
|
213
|
+
raise EPSGError(zone=zone)
|
|
214
|
+
|
|
215
|
+
e = Epsg(e)
|
|
216
|
+
e._band = B
|
|
217
|
+
# e._hemisphere = hp
|
|
218
|
+
return e
|
|
219
|
+
|
|
220
|
+
|
|
221
|
+
__all__ += _ALL_OTHER(decode2, encode)
|
|
222
|
+
|
|
223
|
+
# **) MIT License
|
|
224
|
+
#
|
|
225
|
+
# Copyright (C) 2016-2024 -- mrJean1 at Gmail -- All Rights Reserved.
|
|
226
|
+
#
|
|
227
|
+
# Permission is hereby granted, free of charge, to any person obtaining a
|
|
228
|
+
# copy of this software and associated documentation files (the "Software"),
|
|
229
|
+
# to deal in the Software without restriction, including without limitation
|
|
230
|
+
# the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
|
231
|
+
# and/or sell copies of the Software, and to permit persons to whom the
|
|
232
|
+
# Software is furnished to do so, subject to the following conditions:
|
|
233
|
+
#
|
|
234
|
+
# The above copyright notice and this permission notice shall be included
|
|
235
|
+
# in all copies or substantial portions of the Software.
|
|
236
|
+
#
|
|
237
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
|
238
|
+
# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
239
|
+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
|
240
|
+
# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
|
|
241
|
+
# OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
|
|
242
|
+
# ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
|
243
|
+
# OTHER DEALINGS IN THE SOFTWARE.
|