def _process_parameters(self, coord, radius_m):
"""
Helper function to process test parameters through
the factor_polygon_into_circles function.
"""
radius_km = units.meters_to_km(radius_m)
polygon = Polygon(coord)
points = shapes.factor_polygon_into_circles(polygon, radius_km)
# take the generated points and turn them into "circles" (polygons)
radius_in_deg = units.convert_meters_to_degrees(radius_m)
circles = [Point(point).buffer(radius_in_deg) for point in points]
# convert the list of circles into a multipolyon and merge them
merged_circles = MultiPolygon(circles).cascaded_union
# make sure the merged circles have no holes and completely cover
# the original polygon
self.assertTrue(merged_circles.num_interior_rings == 0,
'The merged circles had %s holes but should have none'
% merged_circles.num_interior_rings)
self.assertTrue(merged_circles.prepared.covers(polygon),
'The merged circles do not cover the polygon')
评论列表
文章目录