def datum(self, datum): '''Set this point's datum I{without conversion}. @arg datum: New spherical datum (L{Datum}, L{Ellipsoid}, L{Ellipsoid2}, L{a_f2Tuple}) or C{scalar} earth radius). @raise TypeError: If B{C{datum}} invalid or not not spherical. ''' d = _spherical_datum(datum, name=self.name, raiser=True) self._update(d != self._datum) self._datum = d
def __init__(self, lat0, lon0, datum=None, name=NN): '''New azimuthal projection. @arg lat0: Latitude of the center point (C{degrees90}). @arg lon0: Longitude of the center point (C{degrees180}). @kwarg datum: Optional datum or ellipsoid (L{Datum}, L{Ellipsoid}, L{Ellipsoid2} or L{a_f2Tuple}) or I{scalar} earth radius (C{meter}). @kwarg name: Optional name for the projection (C{str}). @raise AzimuthalError: Invalid B{C{lat0}}, B{C{lon0}} or spherical B{C{datum}}. @raise TypeError: Invalid B{C{datum}}. ''' if name: self.name = name if datum not in (None, self._datum): self._datum = _spherical_datum(datum, name=name) self.reset(lat0, lon0)
def __init__(self, lat, lon, height=0, datum=None, name=NN): '''Create a spherical C{LatLon} point frome the given lat-, longitude and height on the given datum. @arg lat: Latitude (C{degrees} or DMS C{[N|S]}). @arg lon: Longitude (C{degrees} or DMS C{str[E|W]}). @kwarg height: Optional elevation (C{meter}, the same units as the datum's half-axes). @kwarg datum: Optional, spherical datum to use (L{Datum}, L{Ellipsoid}, L{Ellipsoid2}, L{a_f2Tuple}) or C{scalar} earth radius). @kwarg name: Optional name (string). @raise TypeError: If B{C{datum}} invalid or not not spherical. @example: >>> p = LatLon(51.4778, -0.0016) # height=0, datum=Datums.WGS84 ''' LatLonBase.__init__(self, lat, lon, height=height, name=name) if datum not in (None, self.datum): self._datum = _spherical_datum(datum, name=self.name, raiser=True)
def intersections2(lat1, lon1, radius1, lat2, lon2, radius2, datum=None, wrap=True): '''Conveniently compute the intersections of two circles each defined by (geodetic/-centric) center point and a radius, using either ... 1) L{vector3d.intersections2} for small distances or if no B{C{datum}} is specified, or ... 2) L{sphericalTrigonometry.intersections2} for a spherical B{C{datum}} or if B{C{datum}} is a C{scalar} representing the earth radius, or ... 3) L{ellipsoidalKarney.intersections2} for an ellipsoidal B{C{datum}} and if I{Karney}'s U{geographiclib<https://PyPI.org/project/geographiclib/>} is installed, or ... 4) L{ellipsoidalVincenty.intersections2} if B{C{datum}} is ellipsoidal otherwise. @arg lat1: Latitude of the first circle center (C{degrees}). @arg lon1: Longitude of the first circle center (C{degrees}). @arg radius1: Radius of the first circle (C{meter}, conventionally). @arg lat2: Latitude of the second circle center (C{degrees}). @arg lon2: Longitude of the second circle center (C{degrees}). @arg radius2: Radius of the second circle (C{meter}, same units as B{C{radius1}}). @kwarg datum: Optional ellipsoidal or spherical datum (L{Datum}, L{Ellipsoid}, L{Ellipsoid2}, L{a_f2Tuple} or C{scalar} earth radius in C{meter}, same units as B{C{radius1}} and B{C{radius2}}) or C{None}. @kwarg wrap: Wrap and unroll longitudes (C{bool}). @return: 2-Tuple of the intersection points, each a L{LatLon2Tuple}C{(lat, lon)}. For abutting circles, the intersection points are the same instance. @raise IntersectionError: Concentric, antipodal, invalid or non-intersecting circles or no convergence. @raise TypeError: Invalid B{C{datum}}. @raise UnitError: Invalid B{C{lat1}}, B{C{lon1}}, B{C{radius1}} B{C{lat2}}, B{C{lon2}} or B{C{radius2}}. ''' if datum is None or euclidean(lat1, lon1, lat1, lon2, radius=R_M, adjust=True, wrap=wrap) < _D_I2_: import pygeodesy.vector3d as m def _V2T(x, y, _, **unused): # _ == z unused return _xnamed(LatLon2Tuple(y, x), intersections2.__name__) r1 = m2degrees(Radius_(radius1=radius1), radius=R_M, lat=lat1) r2 = m2degrees(Radius_(radius2=radius2), radius=R_M, lat=lat2) _, lon2 = unroll180(lon1, lon2, wrap=wrap) t = m.intersections2(m.Vector3d(lon1, lat1, 0), r1, m.Vector3d(lon2, lat2, 0), r2, sphere=False, Vector=_V2T) else: def _LL2T(lat, lon, **unused): return _xnamed(LatLon2Tuple(lat, lon), intersections2.__name__) d = _spherical_datum(datum, name=intersections2.__name__) if d.isSpherical: import pygeodesy.sphericalTrigonometry as m elif d.isEllipsoidal: try: if d.ellipsoid.geodesic: pass import pygeodesy.ellipsoidalKarney as m except ImportError: import pygeodesy.ellipsoidalVincenty as m else: raise _AssertionError(datum=d) t = m.intersections2(m.LatLon(lat1, lon1, datum=d), radius1, m.LatLon(lat2, lon2, datum=d), radius2, wrap=wrap, LatLon=_LL2T, height=0) return t