The implementation of this point-in-polygon function is mostly correct, but may not be bulletproof. It ought to work for relatively small regions anywhere on the sky, but for instance it may get the sense wrong for regions that extend to cover both poles.
lon1
, lat1
,
lon2
, lat2
, ...,
lonN
, latN
)
giving (longitude, latitude) vertices of
an N-sided polygon in degrees