Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
for E in (Datums.WGS84.ellipsoid, Datums.NAD83.ellipsoid,
Ellipsoids.Sphere, Ellipsoids.SpherePopular):
if E.f:
f_ = 'f_=1/%.10F' % (1 / E.f,)
else:
f_ = 'f_=' + _n_a_
e = (E.a - E.b) / (E.a + E.b) - E.n
t = (E.toStr(prec=10),
'A=%r, e=%s, %s, n=%s(%s)' % (E.A, fstr(E.e, prec=13, fmt=_e),
f_, fstr(E.n, prec=13, fmt=_Fmt),
fstr(e, prec=3, fmt=_e),),
'%s=(%s)' % (Ellipsoid.AlphaKs.name, fstr(E.AlphaKs, prec=20),),
'%s= (%s)' % (Ellipsoid.BetaKs.name, fstr(E.BetaKs, prec=20),),
'%s= %s' % ('KsOrder', E.KsOrder),
'%s= (%s)' % (Ellipsoid.Mabcd.name, fstr(E.Mabcd, prec=20),))
print('\nEllipsoid.%s: %s' % (E.name, ',\n '.join(t)))
# __doc__ of this file
for e in (Datums, Ellipsoids, Transforms):
t = [NN] + repr(e).split('\n')
print('\n@var '.join(i.strip(',') for i in t))
# zap floats cache
_flt = float # PYCHOK expected
del _Flts
Everest1969 = Ellipsoid(6377295.664, 6356094.667915, 300.8017, 'Everest1969'),
Fisher1968 = Ellipsoid(6378150.0, 6356768.33724438, 298.3, 'Fisher1968'),
GEM10C = Ellipsoid(6378137.0, 6356752.31424783, 298.2572236, 'GEM10C'),
GRS67 = Ellipsoid(6378160.0, 6356774.516, 298.247167427, 'GRS67'), # Lucerne
GRS80 = Ellipsoid(6378137.0, 6356752.314140347, 298.257222101, 'GRS80'), # ITRS, ETRS89
Helmert1906 = Ellipsoid(6378200.0, 6356818.16962789, 298.3, 'Helmert1906'),
IERS1989 = Ellipsoid(6378136.0, 6356751.302, 298.257, 'IERS1989'),
IERS1992TOPEX = Ellipsoid(6378136.3, 6356751.61659215, 298.257223563, 'IERS1992TOPEX'), # IERS/TOPEX/Poseidon/McCarthy
IERS2003 = Ellipsoid(6378136.6, 6356751.85797165, 298.25642, 'IERS2003'),
Intl1924 = Ellipsoid(6378388.0, 6356911.946, 297.0, 'Intl1924'), # aka Hayford
Intl1967 = Ellipsoid(6378157.5, 6356772.2, 298.24961539, 'Intl1967'), # New Int'l
Krassovski1940 = Ellipsoid(6378245.0, 6356863.01877305, 298.3, 'Krassovski1940'), # spelling
Krassowsky1940 = Ellipsoid(6378245.0, 6356863.01877305, 298.3, 'Krassowsky1940'), # spelling
Maupertuis1738 = Ellipsoid(6397300.0, 6363806.28272251, 191.0, 'Maupertuis1738'), # France
Mercury1960 = Ellipsoid(6378166.0, 6356784.28360711, 298.3, 'Mercury1960'),
Mercury1968Mod = Ellipsoid(6378150.0, 6356768.33724438, 298.3, 'Mercury1968Mod'),
NWL1965 = Ellipsoid(6378145.0, 6356759.76948868, 298.25, 'NWL1965'), # Naval Weapons Lab.
OSU86F = Ellipsoid(6378136.2, 6356751.51693008, 298.2572236, 'OSU86F'),
OSU91A = Ellipsoid(6378136.3, 6356751.6165948, 298.2572236, 'OSU91A'),
# Plessis1817 = Ellipsoid(6397523.0, 6355863.0, 153.56512242, 'Plessis1817'), # XXX incorrect?
Plessis1817 = Ellipsoid(6376523.0, 6355862.93325557, 308.64, 'Plessis1817'), # XXX IGN France 1972
SGS85 = Ellipsoid(6378136.0, 6356751.30156878, 298.257, 'SGS85'), # Soviet Geodetic System
SoAmerican1969 = Ellipsoid(6378160.0, 6356774.71919531, 298.25, 'SoAmerican1969'), # South American
Struve1860 = Ellipsoid(6378298.3, 6356657.14266956, 294.73, 'Struve1860'),
WGS60 = Ellipsoid(6378165.0, 6356783.28695944, 298.3, 'WGS60'),
WGS66 = Ellipsoid(6378145.0, 6356759.76948868, 298.25, 'WGS66'),
WGS72 = Ellipsoid(6378135.0, 6356750.52, 298.26, 'WGS72'),
WGS84 = Ellipsoid(6378137.0, 6356752.31425, 298.257223563, 'WGS84'), # GPS
Sphere = Ellipsoid(R_M, R_M, 0.0, 'Sphere'), # pseudo
SphereAuthalic = Ellipsoid(R_FM, R_FM, 0.0, 'SphereAuthalic'), # pseudo
SpherePopular = Ellipsoid(R_MA, R_MA, 0.0, 'SpherePopular'), # EPSG:3857 Spheroid
)
def volume(self):
'''Get the ellipsoid's volume (C{meter**3}), M{4 / 3 * PI * a**2 * b}.
'''
if self._volume is None:
self._volume = Scalar(PI2 * _2_3rd * self.a2 * self.b, name=Ellipsoid.volume.name)
return self._volume
Ellipsoids = _NamedEnum('Ellipsoids', Ellipsoid) #: Registered ellipsoids.
#
#
#
Ellipsoids._assert( #
Airy1830 = Ellipsoid(6377563.396, 6356256.909, 299.3249646, 'Airy1830'),
AiryModified = Ellipsoid(6377340.189, 6356034.448, 299.3249646, 'AiryModified'),
# ANS = Ellipsoid(6378160.0, 6356774.719, 298.25, 'ANS'),
Australia1966 = Ellipsoid(6378160.0, 6356774.719, 298.25, 'Australia1966'),
# Bessel1841 = Ellipsoid(6377397.155, 6356078.963, 299.152815351, 'Bessel1841'),
Bessel1841 = Ellipsoid(6377397.155, 6356078.962818, 299.1528128, 'Bessel1841'),
Clarke1866 = Ellipsoid(6378206.4, 6356583.8, 294.978698214, 'Clarke1866'),
Clarke1880 = Ellipsoid(6378249.145, 6356514.86954978, 293.465, 'Clarke1880'),
Clarke1880IGN = Ellipsoid(6378249.2, 6356515.0, 293.466021294, 'Clarke1880IGN'),
Clarke1880Mod = Ellipsoid(6378249.145, 6356514.96582849, 293.4663, 'Clarke1880Mod'),
CPM1799 = Ellipsoid(6375738.7, 6356671.92557493, 334.39, 'CPM1799'), # Comm. des Poids et Mesures
Delambre1810 = Ellipsoid(6376428.0, 6355957.92616372, 311.5, 'Delambre1810'), # Belgium
Engelis1985 = Ellipsoid(6378136.05, 6356751.32272154, 298.2566, 'Engelis1985'),
Everest1969 = Ellipsoid(6377295.664, 6356094.667915, 300.8017, 'Everest1969'),
Fisher1968 = Ellipsoid(6378150.0, 6356768.33724438, 298.3, 'Fisher1968'),
GEM10C = Ellipsoid(6378137.0, 6356752.31424783, 298.2572236, 'GEM10C'),
GRS67 = Ellipsoid(6378160.0, 6356774.516, 298.247167427, 'GRS67'), # Lucerne
GRS80 = Ellipsoid(6378137.0, 6356752.314140347, 298.257222101, 'GRS80'), # ITRS, ETRS89
try:
E = a_ellipsoid
if f is None:
if isinstance(E, Datum):
self._datum = E
E = E.ellipsoid
elif not isinstance(E, Ellipsoid):
raise TypeError
if not name:
name = E.name
elif isscalar(E) and isscalar(f):
a = float(E)
f_ = (1.0 / f) if f else 0 # sphere
b = None if f_ else a
E = Ellipsoid(a, b, f_, name=_UNDERSCORE_ + name)
else:
raise ValueError
if not (E.a > 0 and E.f < 1):
raise ValueError
except (TypeError, ValueError) as x:
t = unstr(self.classname, a=a_ellipsoid, f=f)
raise EcefError(t + _SPACE_ + _ellipsoid_, txt=str(x))
self._E = E
if name:
self.name = name
Maupertuis1738 = Ellipsoid(6397300.0, 6363806.28272251, 191.0, 'Maupertuis1738'), # France
Mercury1960 = Ellipsoid(6378166.0, 6356784.28360711, 298.3, 'Mercury1960'),
Mercury1968Mod = Ellipsoid(6378150.0, 6356768.33724438, 298.3, 'Mercury1968Mod'),
NWL1965 = Ellipsoid(6378145.0, 6356759.76948868, 298.25, 'NWL1965'), # Naval Weapons Lab.
OSU86F = Ellipsoid(6378136.2, 6356751.51693008, 298.2572236, 'OSU86F'),
OSU91A = Ellipsoid(6378136.3, 6356751.6165948, 298.2572236, 'OSU91A'),
# Plessis1817 = Ellipsoid(6397523.0, 6355863.0, 153.56512242, 'Plessis1817'), # XXX incorrect?
Plessis1817 = Ellipsoid(6376523.0, 6355862.93325557, 308.64, 'Plessis1817'), # XXX IGN France 1972
SGS85 = Ellipsoid(6378136.0, 6356751.30156878, 298.257, 'SGS85'), # Soviet Geodetic System
SoAmerican1969 = Ellipsoid(6378160.0, 6356774.71919531, 298.25, 'SoAmerican1969'), # South American
Struve1860 = Ellipsoid(6378298.3, 6356657.14266956, 294.73, 'Struve1860'),
WGS60 = Ellipsoid(6378165.0, 6356783.28695944, 298.3, 'WGS60'),
WGS66 = Ellipsoid(6378145.0, 6356759.76948868, 298.25, 'WGS66'),
WGS72 = Ellipsoid(6378135.0, 6356750.52, 298.26, 'WGS72'),
WGS84 = Ellipsoid(6378137.0, 6356752.31425, 298.257223563, 'WGS84'), # GPS
Sphere = Ellipsoid(R_M, R_M, 0.0, 'Sphere'), # pseudo
SphereAuthalic = Ellipsoid(R_FM, R_FM, 0.0, 'SphereAuthalic'), # pseudo
SpherePopular = Ellipsoid(R_MA, R_MA, 0.0, 'SpherePopular'), # EPSG:3857 Spheroid
)
def _r_s2(s):
'''(INTERNAL) rotation in C{radians} and C{degree seconds}.
'''
return _flt(radians(s / 3600.0)), _flt(s)
class Transform(_NamedEnumItem):
'''Helmert transformation.
'''
tx = 0 #: X translation (C{meter}).
ty = 0 #: Y translation (C{meter}).
IERS2003 = Ellipsoid(6378136.6, 6356751.85797165, 298.25642, 'IERS2003'),
Intl1924 = Ellipsoid(6378388.0, 6356911.946, 297.0, 'Intl1924'), # aka Hayford
Intl1967 = Ellipsoid(6378157.5, 6356772.2, 298.24961539, 'Intl1967'), # New Int'l
Krassovski1940 = Ellipsoid(6378245.0, 6356863.01877305, 298.3, 'Krassovski1940'), # spelling
Krassowsky1940 = Ellipsoid(6378245.0, 6356863.01877305, 298.3, 'Krassowsky1940'), # spelling
Maupertuis1738 = Ellipsoid(6397300.0, 6363806.28272251, 191.0, 'Maupertuis1738'), # France
Mercury1960 = Ellipsoid(6378166.0, 6356784.28360711, 298.3, 'Mercury1960'),
Mercury1968Mod = Ellipsoid(6378150.0, 6356768.33724438, 298.3, 'Mercury1968Mod'),
NWL1965 = Ellipsoid(6378145.0, 6356759.76948868, 298.25, 'NWL1965'), # Naval Weapons Lab.
OSU86F = Ellipsoid(6378136.2, 6356751.51693008, 298.2572236, 'OSU86F'),
OSU91A = Ellipsoid(6378136.3, 6356751.6165948, 298.2572236, 'OSU91A'),
# Plessis1817 = Ellipsoid(6397523.0, 6355863.0, 153.56512242, 'Plessis1817'), # XXX incorrect?
Plessis1817 = Ellipsoid(6376523.0, 6355862.93325557, 308.64, 'Plessis1817'), # XXX IGN France 1972
SGS85 = Ellipsoid(6378136.0, 6356751.30156878, 298.257, 'SGS85'), # Soviet Geodetic System
SoAmerican1969 = Ellipsoid(6378160.0, 6356774.71919531, 298.25, 'SoAmerican1969'), # South American
Struve1860 = Ellipsoid(6378298.3, 6356657.14266956, 294.73, 'Struve1860'),
WGS60 = Ellipsoid(6378165.0, 6356783.28695944, 298.3, 'WGS60'),
WGS66 = Ellipsoid(6378145.0, 6356759.76948868, 298.25, 'WGS66'),
WGS72 = Ellipsoid(6378135.0, 6356750.52, 298.26, 'WGS72'),
WGS84 = Ellipsoid(6378137.0, 6356752.31425, 298.257223563, 'WGS84'), # GPS
Sphere = Ellipsoid(R_M, R_M, 0.0, 'Sphere'), # pseudo
SphereAuthalic = Ellipsoid(R_FM, R_FM, 0.0, 'SphereAuthalic'), # pseudo
SpherePopular = Ellipsoid(R_MA, R_MA, 0.0, 'SpherePopular'), # EPSG:3857 Spheroid
)
def _r_s2(s):
'''(INTERNAL) rotation in C{radians} and C{degree seconds}.
'''
return _flt(radians(s / 3600.0)), _flt(s)
# LogicalDictionary/StandardValues/ellipsoid.html>
#
Ellipsoids._assert( #
Airy1830 = Ellipsoid(6377563.396, 6356256.909, 299.3249646, 'Airy1830'),
AiryModified = Ellipsoid(6377340.189, 6356034.448, 299.3249646, 'AiryModified'),
# ANS = Ellipsoid(6378160.0, 6356774.719, 298.25, 'ANS'),
Australia1966 = Ellipsoid(6378160.0, 6356774.719, 298.25, 'Australia1966'),
# Bessel1841 = Ellipsoid(6377397.155, 6356078.963, 299.152815351, 'Bessel1841'),
Bessel1841 = Ellipsoid(6377397.155, 6356078.962818, 299.1528128, 'Bessel1841'),
Clarke1866 = Ellipsoid(6378206.4, 6356583.8, 294.978698214, 'Clarke1866'),
Clarke1880 = Ellipsoid(6378249.145, 6356514.86954978, 293.465, 'Clarke1880'),
Clarke1880IGN = Ellipsoid(6378249.2, 6356515.0, 293.466021294, 'Clarke1880IGN'),
Clarke1880Mod = Ellipsoid(6378249.145, 6356514.96582849, 293.4663, 'Clarke1880Mod'),
CPM1799 = Ellipsoid(6375738.7, 6356671.92557493, 334.39, 'CPM1799'), # Comm. des Poids et Mesures
Delambre1810 = Ellipsoid(6376428.0, 6355957.92616372, 311.5, 'Delambre1810'), # Belgium
Engelis1985 = Ellipsoid(6378136.05, 6356751.32272154, 298.2566, 'Engelis1985'),
Everest1969 = Ellipsoid(6377295.664, 6356094.667915, 300.8017, 'Everest1969'),
Fisher1968 = Ellipsoid(6378150.0, 6356768.33724438, 298.3, 'Fisher1968'),
GEM10C = Ellipsoid(6378137.0, 6356752.31424783, 298.2572236, 'GEM10C'),
GRS67 = Ellipsoid(6378160.0, 6356774.516, 298.247167427, 'GRS67'), # Lucerne
GRS80 = Ellipsoid(6378137.0, 6356752.314140347, 298.257222101, 'GRS80'), # ITRS, ETRS89
Helmert1906 = Ellipsoid(6378200.0, 6356818.16962789, 298.3, 'Helmert1906'),
IERS1989 = Ellipsoid(6378136.0, 6356751.302, 298.257, 'IERS1989'),
IERS1992TOPEX = Ellipsoid(6378136.3, 6356751.61659215, 298.257223563, 'IERS1992TOPEX'), # IERS/TOPEX/Poseidon/McCarthy
IERS2003 = Ellipsoid(6378136.6, 6356751.85797165, 298.25642, 'IERS2003'),
Intl1924 = Ellipsoid(6378388.0, 6356911.946, 297.0, 'Intl1924'), # aka Hayford
Intl1967 = Ellipsoid(6378157.5, 6356772.2, 298.24961539, 'Intl1967'), # New Int'l
Krassovski1940 = Ellipsoid(6378245.0, 6356863.01877305, 298.3, 'Krassovski1940'), # spelling
Krassowsky1940 = Ellipsoid(6378245.0, 6356863.01877305, 298.3, 'Krassowsky1940'), # spelling
Maupertuis1738 = Ellipsoid(6397300.0, 6363806.28272251, 191.0, 'Maupertuis1738'), # France
Mercury1960 = Ellipsoid(6378166.0, 6356784.28360711, 298.3, 'Mercury1960'),
Mercury1968Mod = Ellipsoid(6378150.0, 6356768.33724438, 298.3, 'Mercury1968Mod'),
Intl1924 = Ellipsoid(6378388.0, 6356911.946, 297.0, 'Intl1924'), # aka Hayford
Intl1967 = Ellipsoid(6378157.5, 6356772.2, 298.24961539, 'Intl1967'), # New Int'l
Krassovski1940 = Ellipsoid(6378245.0, 6356863.01877305, 298.3, 'Krassovski1940'), # spelling
Krassowsky1940 = Ellipsoid(6378245.0, 6356863.01877305, 298.3, 'Krassowsky1940'), # spelling
Maupertuis1738 = Ellipsoid(6397300.0, 6363806.28272251, 191.0, 'Maupertuis1738'), # France
Mercury1960 = Ellipsoid(6378166.0, 6356784.28360711, 298.3, 'Mercury1960'),
Mercury1968Mod = Ellipsoid(6378150.0, 6356768.33724438, 298.3, 'Mercury1968Mod'),
NWL1965 = Ellipsoid(6378145.0, 6356759.76948868, 298.25, 'NWL1965'), # Naval Weapons Lab.
OSU86F = Ellipsoid(6378136.2, 6356751.51693008, 298.2572236, 'OSU86F'),
OSU91A = Ellipsoid(6378136.3, 6356751.6165948, 298.2572236, 'OSU91A'),
# Plessis1817 = Ellipsoid(6397523.0, 6355863.0, 153.56512242, 'Plessis1817'), # XXX incorrect?
Plessis1817 = Ellipsoid(6376523.0, 6355862.93325557, 308.64, 'Plessis1817'), # XXX IGN France 1972
SGS85 = Ellipsoid(6378136.0, 6356751.30156878, 298.257, 'SGS85'), # Soviet Geodetic System
SoAmerican1969 = Ellipsoid(6378160.0, 6356774.71919531, 298.25, 'SoAmerican1969'), # South American
Struve1860 = Ellipsoid(6378298.3, 6356657.14266956, 294.73, 'Struve1860'),
WGS60 = Ellipsoid(6378165.0, 6356783.28695944, 298.3, 'WGS60'),
WGS66 = Ellipsoid(6378145.0, 6356759.76948868, 298.25, 'WGS66'),
WGS72 = Ellipsoid(6378135.0, 6356750.52, 298.26, 'WGS72'),
WGS84 = Ellipsoid(6378137.0, 6356752.31425, 298.257223563, 'WGS84'), # GPS
Sphere = Ellipsoid(R_M, R_M, 0.0, 'Sphere'), # pseudo
SphereAuthalic = Ellipsoid(R_FM, R_FM, 0.0, 'SphereAuthalic'), # pseudo
SpherePopular = Ellipsoid(R_MA, R_MA, 0.0, 'SpherePopular'), # EPSG:3857 Spheroid
)
def _r_s2(s):
'''(INTERNAL) rotation in C{radians} and C{degree seconds}.
'''
return _flt(radians(s / 3600.0)), _flt(s)
class Transform(_NamedEnumItem):
def R2(self):
'''Get the authalic earth radius (C{meter}), M{sqrt((a**2 + b**2 * atanh(e) / e) / 2)}.
@see: U{Earth radius} and
U{c}.
'''
if self._R2 is None:
if self.e2 > 0:
r = atanh(self.e) / self.e
elif self.e2 < 0: # GeographicLib Ellipsoid Area
r = atan(self.e) / self.e
else:
r = 1
self._R2 = Radius(sqrt((self.a2 + self.b2 * r) * 0.5), name=Ellipsoid.R2.name)
return self._R2