名称

CG_GenerateRoof — Generate a roof of the requested type from a footprint polygon.

大纲

geometry CG_GenerateRoof(geometry geom, text roof_type, float8 height, float8 slope_angle, integer primary_edge_index);

描述

Generate a roof as a 3D PolyhedralSurface Z from a 2D footprint polygon. The roof_type parameter selects the roof style (default 'HIPPED'):

  • FLAT — flat box roof.

  • HIPPED — hipped roof (all sides slope to apex).

  • GABLE — gable roof (two sloping sides, two vertical ends).

  • SKILLION — single-slope (shed) roof.

height sets the roof height (default 3.0), slope_angle sets the pitch in degrees (default 30.0), and primary_edge_index selects the reference edge for skillion roofs (default 0).

Availability: 3.7.0 - requires SFCGAL >= 2.3.0.

该方法需要SFCGAL后端。

该函数支持多面体曲面。

示例

The generic dispatcher returns the same 3D roofs as the specialized helpers for the same footprint.

Code
WITH data AS (
  SELECT 'POLYGON((0 0,4 0,4 4,0 4,0 0))'::geometry AS input_footprint
)
SELECT input_footprint AS input_footprint,
       CG_GenerateRoof(input_footprint, 'HIPPED', 2.0, 30.0, 0) AS hipped_roof,
       CG_GenerateRoof(input_footprint, 'FLAT', 2.0, 30.0, 0) AS flat_roof
FROM data;
栅格输出
POLYGON((0 0,4 0,4 4,0 4,0 0)) | POLYHEDRALSURFACE Z (((0 4 0,4 4 0,4 0 0,0 0 0,0 4 0)),((0 4 0,0 0 0,2 2 2,0 4 0)),((0 0 0,4 0 0,2 2 2,0 0 0)),((4 0 0,4 4 0,2 2 2,4 0 0)),((4 4 0,0 4 0,2 2 2,4 4 0))) | POLYHEDRALSURFACE Z (((0 0 0,0 4 0,4 4 0,4 0 0,0 0 0)),((0 0 2,4 0 2,4 4 2,0 4 2,0 0 2)),((0 0 0,0 0 2,0 4 2,0 4 0,0 0 0)),((0 4 0,0 4 2,4 4 2,4 4 0,0 4 0)),((4 4 0,4 4 2,4 0 2,4 0 0,4 4 0)),((4 0 0,4 0 2,0 0 2,0 0 0,4 0 0)))
Figure
Geometry figure for visual-cg-generateroof-01