test_shapes.py 文件源码

python
阅读 19 收藏 0 点赞 0 评论 0

项目:cyphon 作者: dunbarcyber 项目源码 文件源码
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')
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号