ST_Volume — 计算三维实体的体积。如果应用于曲面(即使是闭合的)几何图形将返回0。
float ST_Volume(
geometry geom1)
;
可用性:2.2.0
This method needs SFCGAL backend.
This function supports 3d and will not drop the z-index.
This function supports Polyhedral surfaces.
This function supports Triangles and Triangulated Irregular Network Surfaces (TIN).
使用WKT创建闭合曲面时,它们将被视为面状而不是实体。要使它们坚固,您需要使用 ST_MakeSolid 。面状几何图形没有体积。下面是一个演示的例子。
SELECT ST_Volume(geom) As cube_surface_vol, ST_Volume(ST_MakeSolid(geom)) As solid_surface_vol FROM (SELECT 'POLYHEDRALSURFACE( ((0 0 0, 0 0 1, 0 1 1, 0 1 0, 0 0 0)), ((0 0 0, 0 1 0, 1 1 0, 1 0 0, 0 0 0)), ((0 0 0, 1 0 0, 1 0 1, 0 0 1, 0 0 0)), ((1 1 0, 1 1 1, 1 0 1, 1 0 0, 1 1 0)), ((0 1 0, 0 1 1, 1 1 1, 1 1 0, 0 1 0)), ((0 0 1, 1 0 1, 1 1 1, 0 1 1, 0 0 1)) )'::geometry) As f(geom); cube_surface_vol | solid_surface_vol ------------------+------------------- 0 | 1