Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
'''Convert this cartesian point to a C{Karney}-based
geodetic point.
@kwarg LatLon_datum_kwds: Optional L{LatLon}, B{C{datum}} and
other keyword arguments, ignored if B{C{LatLon=None}}.
Use B{C{LatLon=...}} to override this L{LatLon} class
or specify B{C{LatLon=None}}.
@return: The geodetic point (L{LatLon}) or if B{C{LatLon}}
is C{None}, an L{Ecef9Tuple}C{(x, y, z, lat, lon,
height, C, M, datum)} with C{C} and C{M} if available.
@raise TypeError: Invalid B{C{LatLon}}, B{C{datum}} or other
B{C{LatLon_datum_kwds}}.
'''
kwds = _xkwds(LatLon_datum_kwds, LatLon=LatLon, datum=self.datum)
return CartesianEllipsoidalBase.toLatLon(self, **kwds)
(C{meter}).
@kwarg LatLon: Optional class to return the mean point
(L{LatLon}).
@kwarg LatLon_kwds: Optional, additional B{C{LatLon}} keyword
arguments, ignored if B{C{LatLon=None}}.
@return: Point at geographic mean and mean height (B{C{LatLon}}).
@raise PointsError: Insufficient number of B{C{points}}.
@raise TypeError: Some B{C{points}} are not C{LatLon}.
'''
n, points = _Nvll.points2(points, closed=False)
# geographic mean
m = sumOf(points[i]._N_vector for i in range(n))
kwds = _xkwds(LatLon_kwds, height=height, LatLon=LatLon)
return m.toLatLon(**kwds)
def _toLatLon(self, lat, lon, LatLon, LatLon_kwds):
'''(INTERNAL) Check B{C{LatLon}} and return an instance.
'''
kwds = _xkwds(LatLon_kwds, datum=self.datum)
r = LatLon(lat, lon, **kwds) # handle .classof
B = _LLEB if self.datum.isEllipsoidal else _LLB
_xinstanceof(B, LatLon=r)
return r
'''Convert this point to C{Karney}-based cartesian (ECEF) coordinates.
@kwarg Cartesian_datum_kwds: Optional L{Cartesian}, B{C{datum}}
and other keyword arguments, ignored if B{C{Cartesian=None}}.
Use B{C{Cartesian=...}} to override this L{Cartesian} class
or set B{C{Cartesian=None}}.
@return: The cartesian (ECEF) coordinates (L{Cartesian}) or if
B{C{Cartesian}} is C{None}, an L{Ecef9Tuple}C{(x, y, z,
lat, lon, height, C, M, datum)} with C{C} and C{M} if
available.
@raise TypeError: Invalid B{C{Cartesian}}, B{C{datum}} or other
B{C{Cartesian_datum_kwds}}.
'''
kwds = _xkwds(Cartesian_datum_kwds, Cartesian=Cartesian,
datum=self.datum)
return LatLonEllipsoidalBase.toCartesian(self, **kwds)
def __init__(self, **kwds): # PYCHOK no *args
kwds = _xkwds(kwds, **_Neighbors8Defaults)
_NamedDict.__init__(self, **kwds) # name=...
def _latlon3(lat, lon, height, func, LatLon, **LatLon_kwds):
'''(INTERNAL) Helper for L{intersection}, L{intersections2} and L{meanof}.
'''
if LatLon is None:
r = LatLon3Tuple(lat, lon, height)
else:
kwds = _xkwds(LatLon_kwds, height=height)
r = LatLon(lat, lon, **kwds)
return _xnamed(r, func.__name__)
d1 = gc1.cross(s1).dot(i1) # +ve means p1 bearing points to i1
d2 = gc2.cross(s2).dot(i1) # +ve means p2 bearing points to i1
if d1 > 0 and d2 > 0:
d = 1 # both point to i1
elif d1 < 0 and d2 < 0:
d = -1 # both point to i2
else: # d1, d2 opposite signs
# intersection is at further-away intersection
# point, take opposite intersection from mid-
# point of v1 and v2 [is this always true?]
d = -s1.plus(s2).dot(i1)
i = i1 if d > 0 else gc2.cross(gc1, raiser=_paths_)
h = fmean(hs) if height is None else height
kwds = _xkwds(LatLon_kwds, height=h, LatLon=LatLon)
return i.toLatLon(**kwds) # Nvector(i.x, i.y, i.z).toLatLon(...)
def __init__(self, *args, **kwds):
if args: # args override kwds
if len(args) != 1:
t = unstr(self.classname, *args, **kwds)
raise _ValueError(args=len(args), txt=t)
kwds = _xkwds(dict(args[0]), **kwds)
if _name_ in kwds:
_Named.name.fset(self, kwds.pop(_name_)) # see _Named.name
dict.__init__(self, kwds)
def _latlon4(t, h, n):
if LatLon is None:
r = LatLon4Tuple(t.lat, t.lon, h, t.datum)
else:
kwds = _xkwds(LatLon_kwds, datum=t.datum, height=h)
r = LatLon(t.lat, t.lon, **kwds)
return _xnamed(r, n)