
import shapely
import numpy as np

import smartcarb as sc


def overlaps_with_area(lon, lat, area):
    points = np.transpose([lon, lat])
    points = shapely.geometry.MultiPoint(points)
    return points.intersects(area)



def overlaps_with_origin(data, origin):

    lon_o, lat_o, radius = sc.misc.get_source_origin(origin)

    lon = np.array(data.lon)[np.isfinite(data.lon)]
    lat = np.array(data.lat)[np.isfinite(data.lat)]

    area = sc.misc.get_circle(lon_o, lat_o, radius)

    return overlaps_with_area(lon, lat, area)
