Назва

CG_ApproximateMedialAxis — Обчисліть приблизну медіальну вісь плоскої геометрії.

Короткий огляд

geometry CG_ApproximateMedialAxis(geometry geom);

geometry CG_ApproximateMedialAxis(geometry geom, boolean projected);

Опис

Повертає приблизну медіальну вісь для введеної площі на основі її прямого скелета. Використовує специфічний API SFCGAL, якщо побудований на основі сумісної версії (1.2.0+). В іншому випадку функція є лише обгорткою навколо 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. Вона завжди дає двовимірний результат, навіть якщо використовується для тривимірної геометрії.

This method needs SFCGAL backend.

This function supports Polyhedral surfaces.

This function supports Triangles and Triangulated Irregular Network Surfaces (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