CG_3DBuffer — 计算几何体周围的三维缓冲区。
geometry CG_3DBuffer(geometry geom, float8 radius, integer segments, integer buffer_type);
生成以输入几何 geom 为中心、半径为 radius 的 3D 缓冲区,在三维空间中构建体积缓冲表示。segments 用于逼近曲面弧段,最少为 4;buffer_type 用于指定缓冲类型:0 为圆角(默认)、1 为平面、2 为方形
输入几何对象必须为 Point(点)或 LineString(线串)类型。
可用性:3.6.0 - 需要 SFCGAL>= 2.0.0
该方法需要SFCGAL后端。
SELECT ST_AsText(CG_3DBuffer('POINT(0 0 0)', 1, 8, 0));
-- Result: POLYHEDRALSURFACE Z (((0 0 1, 0.5 -0.5 0.71, 0 -0.71 0.71, 0 0 1)), ... )
下一张图片是通过将 ST_AsX3D 查询的输出粘贴到 X3D Viewer 中进行绘制的结果。
SELECT string_agg('<Shape
>' || ST_AsX3D(cgbuffer3d_output) || '<Appearance>
<Material diffuseColor="0 0.8 0.2" specularColor="0 1 0"/>
</Appearance>
</Shape
>', '');
segments=32(球形缓冲区)
SELECT CG_3DBuffer(ST_GeomFromText('POINT(100 90)'), 50,32,0);
|
5边形球
SELECT CG_3DBuffer(
ST_GeomFromText('POINT(100 90)'),
50,5,0);
|
32边球形
SELECT CG_3DBuffer(
ST_GeomFromText(
'LINESTRING(50 50,150 150,150 50)'
),
10,32,0);
|
32边方形
SELECT CG_3DBuffer(
ST_GeomFromText(
'LINESTRING(50 50,150 150,150 50)'
),
10,32,2);
|