try rtree to handle the distance.