ST_3DMaxDistance — 返回两个几何体在投影单位下的 3D 笛卡尔最大距离(基于空间参考)。
float ST_3DMaxDistance(geometry g1, geometry g2);
返回两个几何体在投影单位(空间参考单位)下的 3 维笛卡尔最大距离。
此函数支持 3D,并且不会删除 z 索引。
此函数支持多面体表面。
可用性: 2.0.0
已更改: 2.2.0 - 在 2D 和 3D 的情况下,对于缺失的 Z 值,不再假定 Z 为 0。
-- Geometry example - units in meters (SRID: 2163 US National Atlas Equal area) (3D point and line compared 2D point and line)
-- Note: currently no vertical datum support so Z is not transformed and assumed to be same units as final.
SELECT ST_3DMaxDistance(
ST_Transform(ST_GeomFromEWKT('SRID=4326;POINT(-72.1235 42.3521 10000)'),2163),
ST_Transform(ST_GeomFromEWKT('SRID=4326;LINESTRING(-72.1260 42.45 15, -72.123 42.1546 20)'),2163)
) As dist_3d,
ST_MaxDistance(
ST_Transform(ST_GeomFromEWKT('SRID=4326;POINT(-72.1235 42.3521 10000)'),2163),
ST_Transform(ST_GeomFromEWKT('SRID=4326;LINESTRING(-72.1260 42.45 15, -72.123 42.1546 20)'),2163)
) As dist_2d;
dist_3d | dist_2d
------------------+------------------
24383.7467488441 | 22247.8472107251