CG_Extrude — 将曲面挤出到相关体积
geometry CG_Extrude(geometry geom, float x, float y, float z);
Extrudes the input along the vector (x, y, z) and connects it to its translated copy. Extrusion can raise the dimensionality of the result, for example from a surface to a volume.
可用性:3.5.0
该方法需要SFCGAL后端。
该函数支持 3d 并且不会丢失 z-index。
该函数支持多面体曲面。
此函数支持三角形和不规则三角网面 (TIN)。
The figures use ST_Affine to project Z diagonally into XY after extrusion. The returned geometry from CG_Extrude remains a 3D PolyhedralSurface.
Extruding an octagonal Polygon 30 units along Z.
WITH data AS (
SELECT ST_Buffer('POINT(100 90)'::geometry, 50, 'quad_segs=2') AS geom
), projected AS (
SELECT ST_Force2D(ST_Affine(geom,
1, 0, 0.5, 0, 1, 0.5, 0, 0, 0, 0, 0, 0)) AS input_geom,
ST_Force2D(ST_Affine(CG_Extrude(geom, 0, 0, 30),
1, 0, 0.5, 0, 1, 0.5, 0, 0, 0, 0, 0, 0)) AS output_geom
FROM data
)
SELECT input_geom AS input_geometry,
output_geom AS extruded_projection
FROM projected;
POLYGON((150 90,135.355 54.645,100 40,64.645 54.645,50 90,64.645 125.355,100 140,135.355 125.355,150 90)) | POLYHEDRALSURFACE(((150 90,135.355 54.645,100 40,64.645 54.645,50 90,64.645 125.355,100 140,135.355 125.355,150 90)),((165 105,150.355 140.355,115 155,79.645 140.355,65 105,79.645 69.645,115 55,150.355 69.645,165 105)),((150 90,165 105,150.355 69.645,135.355 54.645,150 90)),((135.355 54.645,150.355 69.645,115 55,100 40,135.355 54.645)),((100 40,115 55,79.645 69.645,64.645 54.645,100 40)),((64.645 54.645,79.645 69.645,65 105,50 90,64.645 54.645)),((50 90,65 105,79.645 140.355,64.645 125.355,50 90)),((64.645 125.355,79.645 140.355,115 155,100 140,64.645 125.355)),((100 140,115 155,150.355 140.355,135.355 125.355,100 140)),((135.355 125.355,150.355 140.355,165 105,150 90,135.355 125.355)))
Extruding a LineString 10 units along Z.
WITH data AS (
SELECT 'LINESTRING(50 50,100 90,95 150)'::geometry AS geom
), projected AS (
SELECT ST_Force2D(ST_Affine(geom,
1, 0, 0.5, 0, 1, 0.5, 0, 0, 0, 0, 0, 0)) AS input_geom,
ST_Force2D(ST_Affine(CG_Extrude(geom, 0, 0, 10),
1, 0, 0.5, 0, 1, 0.5, 0, 0, 0, 0, 0, 0)) AS output_geom
FROM data
)
SELECT input_geom AS input_geometry,
output_geom AS extruded_projection
FROM projected;
LINESTRING(50 50,100 90,95 150) | POLYHEDRALSURFACE(((50 50,100 90,105 95,55 55,50 50)),((100 90,95 150,100 155,105 95,100 90)))