ST_LargestEmptyCircle — 计算不与几何图形重叠的最大圆。
(geometry, geometry, double precision) ST_LargestEmptyCircle(geometry geom, double precision tolerance=0.0, geometry boundary=POINT EMPTY);
找到不与一组点和线障碍物重叠的最大圆。 (多边形几何图形可以作为障碍物包含在内,但仅使用它们的边界线。)圆的中心被限制位于多边形边界内,默认情况下,多边形边界是输入几何图形的凸包。 圆心是边界内部距离障碍物最远的点。 圆本身由中心点和位于确定圆半径的障碍物上的最近点提供。
使用迭代算法将圆心确定为由距离容差指定的给定精度。 如果未指定精度距离,则使用合理的默认值。
返回包含字段的记录:
center-圆的中心点
nearest-几何上最接近中心的点
radius-圆的半径
要查找多边形内部最大的空圆,请参见ST_MaximumInscribedCircle。
可用性:3.4.0。
需要GEOS >= 3.9.0。
Largest empty circle within a set of lines.
WITH obstacles(geom) AS (VALUES ('MULTILINESTRING (
(10 100,60 180,130 150,190 160),
(20 50,70 70,90 20,110 40),
(160 30,100 100,180 100))'::geometry)),
circle AS (
SELECT result.*
FROM obstacles
CROSS JOIN LATERAL ST_LargestEmptyCircle(obstacles.geom) AS result
)
SELECT round(radius::numeric, 6) AS radius,
ST_SnapToGrid(center, 1) AS center,
ST_SnapToGrid(nearest, 1) AS nearest,
ST_SnapToGrid(ST_MakeLine(center, nearest), 1) AS radius_line,
ST_SnapToGrid(ST_Buffer(center, radius), 1) AS circle
FROM circle;
-[ RECORD 1 ]----- radius | 39.260545 center | POINT(62 108) nearest | POINT(70 70) radius_line | LINESTRING(62 108,70 70) circle | POLYGON((101 108,100 101,98 93,94 87,89 81,83 76,77 72,69 70,62 69,54 70,47 72,40 76,34 81,29 87,25 93,23 101,22 108,23 116,25 123,29 130,34 136,40 141,47 145,54 147,62 148,69 147,77 145,83 141,89 136,94 130,98 123,100 116,101 108))
Largest empty circle within a set of points, constrained to lie in a polygon. The constraint polygon boundary is included both as an obstacle and as the constraint for the circle center.
WITH inputs(points, boundary) AS (VALUES (
'MULTIPOINT ((70 50),(60 130),(130 150),(80 90))'::geometry,
'POLYGON ((90 190,10 100,60 10,190 40,120 100,190 180,90 190))'::geometry
)),
circle AS (
SELECT result.*
FROM inputs
CROSS JOIN LATERAL ST_LargestEmptyCircle(
ST_Collect(points, boundary), 0, boundary
) AS result
)
SELECT round(radius::numeric, 6) AS radius,
ST_SnapToGrid(center, 1) AS center,
ST_SnapToGrid(nearest, 1) AS nearest,
ST_SnapToGrid(ST_MakeLine(center, nearest), 1) AS radius_line,
ST_SnapToGrid(ST_Buffer(center, radius), 1) AS circle
FROM circle;
-[ RECORD 1 ]----- radius | 19.903876 center | POINT(97 100) nearest | POINT(80 90) radius_line | LINESTRING(97 100,80 90) circle | POLYGON((117 100,117 96,116 92,114 89,111 86,108 83,105 82,101 80,97 80,93 80,90 82,86 83,83 86,81 89,79 92,78 96,77 100,78 104,79 108,81 111,83 114,86 116,90 118,93 119,97 120,101 119,105 118,108 116,111 114,114 111,116 108,117 104,117 100))