def isantipode(lat1, lon1, lat2, lon2, eps=EPS): '''Check whether two points are antipodal, on diametrically opposite sides of the earth. @arg lat1: Latitude of one point (C{degrees}). @arg lon1: Longitude of one point (C{degrees}). @arg lat2: Latitude of the other point (C{degrees}). @arg lon2: Longitude of the other point (C{degrees}). @kwarg eps: Tolerance for near-equality (C{degrees}). @return: C{True} if points are antipodal within the B{C{eps}} tolerance, C{False} otherwise. @see: U{Geosphere<https://CRAN.R-Project.org/web/packages/geosphere/geosphere.pdf>}. ''' return abs(wrap90(lat1) + wrap90(lat2)) < eps and \ abs(abs(wrap180(lon1) - wrap180(lon2)) % 360 - 180) < eps
def antipode(lat, lon): '''Return the antipode, the point diametrically opposite to a given point in C{degrees}. @arg lat: Latitude (C{degrees}). @arg lon: Longitude (C{degrees}). @return: A L{LatLon2Tuple}C{(lat, lon)}. @see: U{Geosphere<https://CRAN.R-Project.org/web/packages/geosphere/geosphere.pdf>}. ''' return LatLon2Tuple(-wrap90(lat), wrap180(lon + 180))
def _direct(self, distance, bearing, llr, height=None): '''(INTERNAL) Direct Karney method. ''' g = self.datum.ellipsoid.geodesic m = g.AZIMUTH if llr: m |= g.LATITUDE | g.LONGITUDE r = g.Direct(self.lat, self.lon, bearing, distance, m) t = wrap360(r['azi2']) if llr: a, b = wrap90(r['lat2']), wrap180(r['lon2']) h = self.height if height is None else height t = self.classof(a, b, height=h, datum=self.datum), t return t
def _direct(self, distance, bearing, LL, height): '''(INTERNAL) Karney's C{Direct} method. @return: A L{Destination2Tuple}C{(destination, final)} or a L{Destination3Tuple}C{(lat, lon, final)} if B{C{LL}} is C{None}. ''' g = self.datum.ellipsoid.geodesic r = g.Direct3(self.lat, self.lon, bearing, distance) if LL: h = self.height if height is None else height d = LL(wrap90(r.lat), wrap180(r.lon), height=h, datum=self.datum) r = Destination2Tuple(self._xnamed(d), wrap360(r.final)) return r