Name

CG_GenerateGableRoof — Generate a gable roof from a footprint polygon.

Synopsis

geometry CG_GenerateGableRoof(geometry geom, float8 height, float8 slope_angle);

Description

Generate a gable roof as a 3D PolyhedralSurface Z from a 2D footprint polygon. Two opposite sides are vertical gable ends; the other two sides slope to a horizontal ridge. height sets the ridge height above the ground (default 3.0) and slope_angle controls the pitch in degrees (default 30.0). The SRID of the input geometry is preserved.

Availability: 3.7.0 - requires SFCGAL >= 2.3.0.

This method needs SFCGAL backend.

This function supports Polyhedral surfaces.

Examples

Generate a gable roof using a height of 2 and a 30 degree slope.

Code
WITH data AS (
  SELECT 'POLYGON((0 0,5 0,5 4,0 4,0 0))'::geometry AS footprint
)
SELECT CG_GenerateGableRoof(footprint, 2.0, 30.0) AS roof
FROM data;
Output
POLYHEDRALSURFACE Z (((5 4 0,5 0 0,0 0 0,0 4 0,5 4 0)),((0 4 0,0 0 0,0 2 1.155,0 4 0)),((0 0 0,5 0 0,5 2 1.155,0 2 1.155,0 0 0)),((5 0 0,5 4 0,5 2 1.155,5 0 0)),((5 4 0,0 4 0,0 2 1.155,5 2 1.155,5 4 0)))
Figure
Geometry figure for visual-cg-generategableroof-01