def nearestOn3(self, points, closed=False, radius=R_M, **options): '''Locate the point on a polygon closest to this point. Distances are approximated by function L{equirectangular_}, subject to the supplied I{options}. @param points: The polygon points (L{LatLon}[]). @keyword closed: Optionally, close the polygon (C{bool}). @keyword radius: Optional, mean earth radius (C{meter}). @keyword options: Optional keyword arguments for function L{equirectangular_}. @return: 3-Tuple (I{closest}, I{distance}, I{angle}) of the closest point (L{LatLon}) on the polygon, the distance and the compass angle to the I{closest} point. The I{distance} is the L{equirectangular_} distance between this and the I{closest} point in C{meter}, same units as I{radius}. The I{angle} from this to the I{closest} point is in compass C{degrees360}, like function L{compassAngle}. @raise LimitError: Lat- and/or longitudinal delta exceeds I{limit}, see function L{equirectangular_}. @raise TypeError: Some I{points} are not C{LatLon}. @raise ValueError: Insufficient number of I{points}. @see: Functions L{compassAngle}, L{equirectangular_} and L{nearestOn4}. ''' a, b, d, c = nearestOn4(self, points, closed=closed, **options) return self.classof(a, b), degrees2m(d, radius=radius), c
def nearestOn2(point, points, closed=False, radius=R_M, LatLon=LatLon, **options): '''Locate the point on a polygon closest to an other point. Distances are approximated by function L{equirectangular_}, subject to the supplied I{options}. @param point: The other, reference point (L{LatLon}). @param points: The polygon points (L{LatLon}[]). @keyword closed: Optionally, close the polygon (C{bool}). @keyword radius: Optional, mean earth radius (C{meter}). @keyword LatLon: Optional (sub-)class for the closest point (L{LatLon}) or C{None}. @keyword options: Optional keyword arguments for function L{equirectangular_}. @return: 2-Tuple (I{closest}, I{distance}) of the closest point on the polygon and the distance to that point. The I{closest} as I{LatLon} or a 2-tuple (lat, lon) if I{LatLon} is C{None}. The I{distance} is the L{equirectangular_} distance between the I{closest} and reference I{point} in C{meter}, same units as I{radius}. @raise LimitError: Lat- and/or longitudinal delta exceeds I{limit}, see function L{equirectangular_}. @raise TypeError: Some I{points} are not C{LatLon}. @raise ValueError: Insufficient number of I{points}. @see: Functions L{equirectangular_} and L{nearestOn3}. ''' a, b, d, _ = nearestOn4(point, points, closed=closed, **options) ll = (a, b) if LatLon is None else LatLon(a, b) return ll, degrees2m(d, radius=radius)