Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
class Destination2Tuple(_NamedTuple): # .ellipsoidalKarney.py, -Vincenty.py
'''2-Tuple C{(destination, final)}, C{destination} in C{LatLon}
and C{final} bearing in compass C{degrees360}.
'''
_Names_ = ('destination', _final_)
class Destination3Tuple(_NamedTuple): # .karney.py
'''3-Tuple C{(lat, lon, final)}, destination C{lat}, C{lon} in
and C{final} bearing in C{degrees}.
'''
_Names_ = (_lat_, _lon_, _final_)
class Distance2Tuple(_NamedTuple): # .datum.py, .ellipsoidalBase.py
'''2-Tuple C{(distance, initial)}, C{distance} in C{meter} and
C{initial} bearing in compass C{degrees360}.
'''
_Names_ = (_distance_, _initial_)
class Distance3Tuple(_NamedTuple): # .ellipsoidalKarney.py, -Vincenty.py
'''3-Tuple C{(distance, initial, final)}, C{distance} in C{meter}
and C{initial} and C{final} bearing, both in compass C{degrees360}.
'''
_Names_ = (_distance_, _initial_, _final_)
class Distance4Tuple(_NamedTuple): # .formy.py, .points.py
'''4-Tuple C{(distance2, delta_lat, delta_lon, unroll_lon2)} with
the distance in C{degrees squared}, the latitudinal C{delta_lat}
is C{""} or the (longitudinal) UTM band C{'C'|'D'..'W'|'X'}
or the (polar) UPS band C{'A'|'B'|'Y'|'Z'}.
'''
_Names_ = (_zone_, _hemipole_, _easting_, _northing_,
_band_, _datum_, _convergence_, _scale_)
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)
class UtmUpsLatLon5Tuple(_NamedTuple):
'''5-Tuple C{(zone, band, hemipole, lat, lon)} as C{int},
C{str}, C{str}, C{degrees90} and C{degrees180}, where
C{zone} is C{1..60} for UTM or C{0} for UPS, C{band} is
C{""} or the (longitudinal) UTM band C{'C'|'D'..'W'|'X'}
or (polar) UPS band C{'A'|'B'|'Y'|'Z'} and C{hemipole}
C{'N'|'S'} is the UTM hemisphere or the UPS pole.
'''
_Names_ = (_zone_, _band_, _hemipole_, _lat_, _lon_)
def __new__(cls, z, B, h, lat, lon, Error=None):
if Error is not None:
lat = Lat(lat, Error=Error)
lon = Lon(lon, Error=Error)
return _NamedTuple.__new__(cls, z, B, h, lat, lon)
class Distance4Tuple(_NamedTuple): # .formy.py, .points.py
'''4-Tuple C{(distance2, delta_lat, delta_lon, unroll_lon2)} with
the distance in C{degrees squared}, the latitudinal C{delta_lat}
= B{C{lat2}}-B{C{lat1}}, the wrapped, unrolled and adjusted
longitudinal C{delta_lon} = B{C{lon2}}-B{C{lon1}} and the
C{unroll_lon2} unrollment for B{C{lon2}}.
@note: Use Function L{degrees2m} to convert C{degrees squared}
to C{meter} as M{degrees2m(sqrt(distance2), ...)} or
M{degrees2m(hypot(delta_lat, delta_lon), ...)}.
'''
_Names_ = ('distance2', 'delta_lat', 'delta_lon', 'unroll_lon2')
class EasNor2Tuple(_NamedTuple): # .css.py, .osgr.py, .ups.py, .utm.py, .utmupsBase.py
'''2-Tuple C{(easting, northing)}, both in C{meter}.
'''
_Names_ = (_easting_, _northing_)
class EasNor3Tuple(_NamedTuple): # .css.py, .lcc.py
'''3-Tuple C{(easting, northing, height)}, all in C{meter}.
'''
_Names_ = (_easting_, _northing_, _height_)
class LatLon2Tuple(_NamedTuple):
'''2-Tuple C{(lat, lon)} in C{degrees90} and C{degrees180}.
'''
_Names_ = (_lat_, _lon_)
C{str}, C{meter}, C{meter} and C{band} letter, where C{zone}
is C{1..60} for UTM or C{0} for UPS, C{hemipole} C{'N'|'S'} is
the UTM hemisphere or the UPS pole and C{band} is C{""} or the
(longitudinal) UTM band C{'C'|'D'..'W'|'X'} or the (polar) UPS
band C{'A'|'B'|'Y'|'Z'}.
'''
_Names_ = (_zone_, _hemipole_, _easting_, _northing_, _band_)
def __new__(cls, z, h, e, n, B, Error=None):
if Error is not None:
e = Easting( e, Error=Error)
n = Northing(n, Error=Error)
return _NamedTuple.__new__(cls, z, h, e, n, B)
class UtmUps8Tuple(_NamedTuple):
'''8-Tuple C{(zone, hemipole, easting, northing, band, datum,
convergence, scale)} as C{int}, C{str}, C{meter}, C{meter},
C{band} letter, C{Datum}, C{degrees} and C{float}, where
C{zone} is C{1..60} for UTM or C{0} for UPS, C{hemipole}
C{'N'|'S'} is the UTM hemisphere or the UPS pole and C{band}
is C{""} or the (longitudinal) UTM band C{'C'|'D'..'W'|'X'}
or the (polar) UPS band C{'A'|'B'|'Y'|'Z'}.
'''
_Names_ = (_zone_, _hemipole_, _easting_, _northing_,
_band_, _datum_, _convergence_, _scale_)
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)
def to4Tuple(self, height, datum):
'''Extend this L{PhiLam2Tuple} to a L{PhiLam4Tuple}.
@arg height: The height to add (C{scalar}).
@arg datum: The datum to add (C{Datum}).
@return: A L{PhiLam4Tuple}C{(phi, lam, height, datum)}.
@raise TypeError: If B{C{datum}} not a C{Datum}.
@raise ValueError: Invalid B{C{height}}.
'''
return self.to3Tuple(height).to4Tuple(datum)
class PhiLam3Tuple(_NamedTuple): # .nvector.py, extends -2Tuple
'''3-Tuple C{(phi, lam, height)} with latitude C{phi} in
C{radians[PI_2]}, longitude C{lam} in C{radians[PI]} and
C{height} in C{meter}.
@note: Using C{phi/lambda} for lat-/longitude in C{radians}
follows Chris Veness' U{convention
}.
'''
_Names_ = (_phi_, _lam_, _height_)
def to4Tuple(self, datum):
'''Extend this L{PhiLam3Tuple} to a L{PhiLam4Tuple}.
@arg datum: The datum to add (C{Datum}).
@return: A L{PhiLam4Tuple}C{(phi, lam, height, datum)}.
from pygeodesy.utily import unrollPI
from math import radians
from random import Random
__all__ = _ALL_LAZY.hausdorff
__version__ = '20.07.08'
class HausdorffError(PointsError):
'''Hausdorff issue.
'''
pass
class Hausdorff6Tuple(_NamedTuple):
'''6-Tuple C{(hd, i, j, mn, md, units)} with the U{Hausdorff
} distance C{hd},
indices C{i} and C{j}, the total count C{mn}, the C{I{mean}
Hausdorff} distance C{md} and the name of the distance C{units}.
For C{directed Hausdorff} distances, count C{mn} is the number
of model points considered. For C{symmetric Hausdorff} distances
count C{mn} twice that.
Indices C{i} and C{j} are the C{model} respectively C{target}
point with the C{hd} distance.
Mean distance C{md} is C{None} if an C{early break} occurred and
U{early breaking}
was enabled by keyword argument C{early=True}.
'''
n = Northing(n, Error=Error)
return _NamedTuple.__new__(cls, z, di, e, n)
def to6Tuple(self, band, datum):
'''Extend this L{Mgrs4Tuple} to a L{Mgrs6Tuple}.
@arg band: The band to add (C{str} or C{None}).
@arg datum: The datum to add (L{Datum} or C{None}).
@return: A L{Mgrs6Tuple}C{(zone, digraph, easting,
northing, band, datum)}.
'''
return self._xtend(Mgrs6Tuple, band, datum)
class Mgrs6Tuple(_NamedTuple): # XXX only used in the line above
'''6-Tuple C{(zone, digraph, easting, northing, band, datum)},
C{zone}, C{digraph} and C{band} as C{str}, C{easting} and
C{northing} in C{meter} and C{datum} a L{Datum}.
'''
_Names_ = Mgrs4Tuple._Names_ + (_band_, _datum_)
def parseMGRS(strMGRS, datum=Datums.WGS84, Mgrs=Mgrs, name=NN):
'''Parse a string representing a MGRS grid reference,
consisting of zoneBand, grid, easting and northing.
@arg strMGRS: MGRS grid reference (C{str}).
@kwarg datum: Optional datum to use (L{Datum}).
@kwarg Mgrs: Optional class to return the MGRS grid
reference (L{Mgrs}) or C{None}.
@kwarg name: Optional B{C{Mgrs}} name (C{str}).
raise _IsnotError('NumPy', array=type(array))
_Array2LatLon.__init__(self, array, ilat=ilat, ilon=ilon,
LatLon=LatLon, shape=s)
@property_RO
def isNumpy2(self):
'''Is this a Numpy2 wrapper?
'''
return True # isinstance(self, (Numpy2LatLon, ...))
def _subset(self, indices):
return self._array[indices] # NumPy special
class Point3Tuple(_NamedTuple):
'''3-Tuple C{(x, y, ll)} in C{meter}, C{meter} and C{LatLon}.
'''
_Names_ = (_x_, _y_, 'll')
class Shape2Tuple(_NamedTuple):
'''2-Tuple C{(nrows, ncols)}, the number of rows and columns,
both C{int}.
'''
_Names_ = ('nrows', 'ncols')
class Tuple2LatLon(_Array2LatLon):
'''Wrapper for tuple sequences as "on-the-fly" C{LatLon} points.
'''
def __init__(self, tuples, ilat=0, ilon=1, LatLon=None):
def _xtend(self, NamedTuple, *items):
'''(INTERNAL) Extend this C{_Tuple} with C{items} to an other C{NamedTuple}.
'''
if not (issubclassof(NamedTuple, _NamedTuple) and
(len(self._Names_) + len(items)) == len(NamedTuple._Names_)
and self._Names_ == NamedTuple._Names_[:len(self)]):
raise TypeError('%s%r vs %s%r' % (self.classname, self._Names_,
NamedTuple.__name__, NamedTuple._Names_))
return self._xnamed(NamedTuple(*(self + items)))
C{(x, y)}) in (C{degrees}.
@arg start_end: Optional C{[start[, end]]} index (C{int}).
@return: Index or -1 if not found (C{int}).
@raise TypeError: Invalid B{C{xy}}.
'''
return self._rfind(xy, start_end)
def _slicekwds(self):
'''(INTERNAL) Slice kwds.
'''
return dict(closed=self._closed, radius=self._radius, wrap=self._wrap)
class NearestOn5Tuple(_NamedTuple):
'''5-Tuple C{(lat, lon, distance, angle, height)} all in C{degrees},
except C{height}. The C{distance} is the L{equirectangular_}
distance between the closest and the reference B{C{point}} in
C{degrees}. The C{angle} from the reference B{C{point}} to
the closest point is in compass C{degrees360}, see function
L{compassAngle}. The C{height} is the (interpolated) height
at the closest point in C{meter} or C{0}.
'''
_Names_ = ('lat', 'lon', 'distance', 'angle', 'height')
class Numpy2LatLon(_Array2LatLon): # immutable, on purpose
'''Wrapper for C{NumPy} arrays as "on-the-fly" C{LatLon} points.
'''
def __init__(self, array, ilat=0, ilon=1, LatLon=None):
'''Handle a C{NumPy} array as a sequence of C{LatLon} points.