名称

CG_ApproximateMedialAxis — 计算几何区域的近似中轴。

大纲

geometry CG_ApproximateMedialAxis(geometry geom);

geometry CG_ApproximateMedialAxis(geometry geom, boolean projected);

描述

基于直骨架,返回实际输入的近似中心轴。如果在支持的版本(1.2.0+)下构建,将使用 SFCGAL 特有的 API;否则,此函数将是 CG_StraightSkeleton(较慢的情况)函数的封装。

When projected is true, free endpoints of the medial axis are extended to reach the polygon boundary (projected medial axis). Requires SFCGAL 2.3.0+. When built against an older SFCGAL version, a notice is emitted and the non-projected result is returned instead.

可用性:3.5.0

Availability: 3.7.0 - projected parameter. Requires SFCGAL >= 2.3.0 for projected result; falls back to non-projected with a notice on older versions.

[注意]

此函数忽略 Z 维度。 即使在 3D 几何体上使用时,它也始终给出 2D 结果。

该方法需要SFCGAL后端。

该函数支持多面体曲面。

此函数支持三角形和不规则三角网面 (TIN)。

示例

A polygon and its approximate medial axis.

Code
WITH data AS (
  SELECT 'POLYGON((190 190,10 190,10 10,190 10,190 20,160 30,60 30,60 130,190 140,190 190))'::geometry AS polygon
)
SELECT polygon AS input_polygon,
       CG_ApproximateMedialAxis(polygon) AS medial_axis
FROM data;
栅格输出
POLYGON((190 190,10 190,10 10,190 10,190 20,160 30,60 30,60 130,190 140,190 190)) | MULTILINESTRING((184.189 15.811,158.377 20),(50 20,158.377 20),(50 20,35 35),(35 153.151,35 35),(35 153.151,40.697 159.303),(164.04 164.04,40.697 159.303))
Figure
Geometry figure for visual-cg-approximatemedialaxis-01

This example computes the projected medial axis with free endpoints extended to the polygon boundary.

Code
SELECT CG_ApproximateMedialAxis('POLYGON((0 0,2 0,2 1,0 1,0 0))', true);
栅格输出
MULTILINESTRING((0 0.5,0.5 0.5,1.5 0.5,2 0.5))
Figure
Geometry figure for visual-cg-approximatemedialaxis-02