CG_GenerateHippedRoof — Generate a hipped roof from a footprint polygon.
geometry CG_GenerateHippedRoof(geometry geom, float8 height);
Generate a hipped roof as a 3D PolyhedralSurface Z
from a 2D footprint polygon. All sides slope upward to meet at a ridge
or apex. The roof height is given by height
(default 3.0).
Availability: 3.7.0 - requires SFCGAL >= 2.3.0.
This method needs SFCGAL backend.
This function supports Polyhedral surfaces.
The footprint and hipped roof are shown side-by-side so the generated 3D faces do not hide behind the input footprint.
WITH data AS (
SELECT 'POLYGON((0 0,5 0,5 4,0 4,0 0))'::geometry AS input_footprint
)
SELECT input_footprint AS input_footprint,
CG_GenerateHippedRoof(input_footprint, 2.0) AS hipped_roof
FROM data;
POLYGON((0 0,5 0,5 4,0 4,0 0)) | POLYHEDRALSURFACE Z (((0 4 0,5 4 0,5 0 0,0 0 0,0 4 0)),((0 4 0,0 0 0,2 2 2,0 4 0)),((0 0 0,5 0 0,3 2 2,2 2 2,0 0 0)),((5 0 0,5 4 0,3 2 2,5 0 0)),((5 4 0,0 4 0,2 2 2,3 2 2,5 4 0)))