Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def __new__(cls, z, h, e, n, B, d, c, s, Error=None):
if Error is not None:
e = Easting( e, Error=Error)
n = Northing(n, Error=Error)
c = Scalar(c, name=_convergence_, Error=Error)
s = Scalar(s, name=_scale_, Error=Error)
return _NamedTuple.__new__(cls, z, h, e, n, B, d, c, s)
from pygeodesy.units import Easting, Lam_, Northing, Phi_, Scalar
from pygeodesy.utily import degrees90, degrees180, sincos2
from math import cos, radians, sin, sqrt, tan
__all__ = _ALL_LAZY.osgr
__version__ = '20.07.14'
_10um = 1e-5 #: (INTERNAL) 0.01 millimeter (C{meter})
_100km = 100000 #: (INTERNAL) 100 km (int meter)
_A0 = Phi_(49) #: (INTERNAL) NatGrid true origin latitude, 49°N.
_B0 = Lam_(-2) #: (INTERNAL) NatGrid true origin longitude, 2°W.
_E0 = Easting(400e3) #: (INTERNAL) Easting of true origin (C{meter}).
_N0 = Northing(-100e3) #: (INTERNAL) Northing of true origin (C{meter}).
_F0 = Scalar(0.9996012717) #: (INTERNAL) NatGrid scale of central meridian (C{float}).
_Datums_OSGB36 = Datums.OSGB36 #: (INTERNAL) Airy130 ellipsoid
_latlon_ = 'latlon'
_no_convertDatum_ = 'no .convertDatum'
_ord_A = ord('A')
_TRIPS = 32 #: (INTERNAL) Convergence
def _ll2datum(ll, datum, name):
'''(INTERNAL) Convert datum if needed.
'''
if datum and ll.datum != datum:
try:
ll = ll.convertDatum(datum)
except AttributeError:
raise _TypeError(name, ll, txt=_item_ps(_no_convertDatum_, datum.name))
def _nd2(p, d, r, i, *qs):
# return Nvector and angular distance squared
_Nvll.others(p, name=_point_ + i)
for q in qs:
if p.isequalTo(q, EPS):
raise _ValueError(points=p, txt=_coincident_)
return p.toNvector(), (Scalar(d, name=_distance_ + i) / r)**2
def _scale(E, rho, tau):
# compute the point scale factor, ala Karney
t = hypot1(tau)
return Scalar((rho / E.a) * t * sqrt(E.e12 + E.e2 / t**2))
def es_taupf(self, tau):
'''Compute U{Karney's}
equations (7), (8) and (9).
@see: Function U{Math::taupf}.
'''
T = Scalar(tau, name='tau')
t = hypot1(T)
s = sinh(self.es_atanh(T / t))
return hypot1(s) * T - s * t
def e2s2(self, s):
'''Compute M{1 - e2 * s**2}.
@arg s: S value (C{scalar}).
@return: Result (C{float}).
@raise ValueError: Invalid B{C{s}}.
'''
try:
r = 1 - self.e2 * Scalar(s, name='s')**2
if r < 0:
raise ValueError
except (TypeError, ValueError) as x:
raise _ValueError(self._dot_('e2s2'), s, txt=str(x))
return r
def __new__(cls, z, h, e, n, B, d, c, s, Error=None):
if Error is not None:
e = Easting( e, Error=Error)
n = Northing(n, Error=Error)
c = Scalar(c, name=_convergence_, Error=Error)
s = Scalar(s, name=_scale_, Error=Error)
return _NamedTuple.__new__(cls, z, h, e, n, B, d, c, s)
def __new__(cls, x, y, lat, lon, azi, s, datum):
return _NamedTuple.__new__(cls, Scalar(x, name=_x_, Error=AzimuthalError),
Scalar(y, name=_y_, Error=AzimuthalError), # PYCHOK indent
Lat(lat, Error=AzimuthalError),
Lon(lon, Error=AzimuthalError),
Bearing(azi, name=_azimuth_, Error=AzimuthalError),
Scalar(s, name=_scale_, Error=AzimuthalError), datum)
@arg north: North component (C{meter}).
@arg east: East component (C{meter}).
@arg down: Down component, normal to the surface of
the ellipsoid (C{meter}).
@kwarg name: Optional name (C{str}).
@raise ValueError: Invalid B{C{north}}, B{C{east}}
or B{C{down}}.
@example:
>>> from ellipsiodalNvector import Ned
>>> delta = Ned(110569, 111297, 1936)
>>> delta.toStr(prec=0) # [N:110569, E:111297, D:1936]
'''
self._north = Scalar(north or 0, name=_north_)
self._east = Scalar(east or 0, name=_east_)
self._down = Scalar(down or 0, name=_down_)
if name:
self.name = name