名称

ST_MaximumInscribedCircle — 计算几何体中包含的最大圆。

大纲

(geometry, geometry, double precision) ST_MaximumInscribedCircle(geometry geom);

描述

查找(多)多边形内包含的最大圆,或者不与任何线和点重叠的最大圆。 返回包含字段的记录:

  • center-圆的中心点

  • nearest-几何上最接近中心的点

  • radius-圆的半径

对于多边形输入,圆内接于边界环内,使用内环作为边界。 对于线性和点输入,圆内切于输入的凸包内,使用输入线和点作为进一步的边界。

可用性:3.1.0。

需要GEOS >= 3.9.0。

示例

Maximum inscribed circle of a polygon. Center, nearest point, radius, circle, and radius line are returned.

Code
WITH mic AS (
  SELECT * FROM ST_MaximumInscribedCircle(
    'POLYGON ((40 180,110 160,180 180,180 120,140 90,160 40,80 10,70 40,20 50,40 180),
              (60 140,50 90,90 140,60 140))')
)
SELECT round(radius::numeric, 3) AS radius,
       ST_SnapToGrid(center, 1) AS center,
       ST_SnapToGrid(nearest, 1) AS nearest,
       ST_SnapToGrid(ST_Buffer(center, radius), 1) AS circle,
       ST_SnapToGrid(ST_MakeLine(center, nearest), 1) AS radius_line
FROM mic;
栅格输出
-[ RECORD 1 ]-----
radius      | 45.189
center      | POINT(97 76)
nearest     | POINT(62 105)
circle      | POLYGON((142 76,141 68,139 59,135 51,129 44,122 39,114 35,106 32,97 31,88 32,80 35,72 39,65 44,59 51,55 59,53 68,52 76,53 85,55 94,59 101,65 108,72 114,80 118,88 121,97 122,106 121,114 118,122 114,129 108,135 101,139 94,141 85,142 76))
radius_line | LINESTRING(97 76,62 105)
Figure
Geometry figure for visual-st-maximuminscribedcircle-01

Maximum inscribed circle of a MultiLineString.

Code
WITH mic AS (
  SELECT * FROM ST_MaximumInscribedCircle(
    'MULTILINESTRING((100 40,10 150),(10 160,100 150),(190 150,80 40))')
)
SELECT round(radius::numeric, 3) AS radius,
       ST_SnapToGrid(center, 1) AS center,
       ST_SnapToGrid(nearest, 1) AS nearest,
       ST_SnapToGrid(ST_Buffer(center, radius), 1) AS circle,
       ST_SnapToGrid(ST_MakeLine(center, nearest), 1) AS radius_line
FROM mic;
栅格输出
-[ RECORD 1 ]-----
radius      | 39.924
center      | POINT(94 110)
nearest     | POINT(63 85)
circle      | POLYGON((134 110,133 103,131 95,127 88,122 82,116 77,109 74,102 71,94 71,86 71,79 74,72 77,66 82,61 88,57 95,55 103,54 110,55 118,57 126,61 133,66 139,72 144,79 147,86 150,94 150,102 150,109 147,116 144,122 139,127 133,131 126,133 118,134 110))
radius_line | LINESTRING(94 110,63 85)
Figure
Geometry figure for visual-st-maximuminscribedcircle-02