Name

CG_Volume — 计算 3D 实体的体积。 如果应用于表面(甚至闭合)几何图形将返回 0。

Synopsis

float CG_Volume(geometry geom1);

描述

可用性:3.5.0

该方法需要SFCGAL后端。

该函数支持 3d 并且不会丢失 z-index。

该函数支持多面体曲面。

此函数支持三角形和不规则三角网面 (TIN)。

该方法实现了SQL/MM规范。 SQL-MM IEC 13249-3: 9.1 (same as CG_3DVolume)

示例

When closed surfaces are created with WKT, they are treated as areal rather than solid. To make them solid, you need to use CG_MakeSolid. Areal geometries have no volume. Here is an example to demonstrate.

SELECT CG_Volume(geom) As cube_surface_vol,
    CG_Volume(CG_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