def test_no_overlap(self): """Test creation of an overlap object with no intersection.""" poly_df = pd.read_csv(os.path.join(data_dir, 'sample.csv')) polygons = poly_df['PolygonWKT_Pix'].apply(loads).values preds = geometries_internal_intersection(polygons) # there's no overlap, so result should be an empty GeometryCollection assert preds == shapely.geometry.collection.GeometryCollection()
def test_with_overlap(self): poly_df = pd.read_csv(os.path.join(data_dir, 'sample.csv')) # expand the polygons to generate some overlap polygons = poly_df['PolygonWKT_Pix'].apply( lambda x: loads(x).buffer(15)).values preds = geometries_internal_intersection(polygons) with open(os.path.join(data_dir, 'test_overlap_output.txt'), 'r') as f: truth = f.read() f.close() truth = loads(truth) # set a threshold for how good overlap with truth has to be in case of # rounding errors assert truth.intersection(preds).area/truth.area > 0.99