名称

ST_3DDWithin — 测试两个 3D 几何图形是否在给定的 3D 距离内

大纲

boolean ST_3DDWithin(geometry g1, geometry g2, double precision distance_of_srid);

描述

如果两个几何值之间的 3D 距离不大于距离 distance_of_srid,则返回 true。 距离以几何空间参考系统定义的单位指定。 为了使此函数有意义,源几何图形必须位于同一坐标系中(具有相同的 SRID)。

[注意]

此功能自动包括利用几何上可用的任何空间索引的边界框比较。

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

该函数支持多面体曲面。

该方法实现了SQL/MM规范。 SQL-MM ?

可用性: 2.0.0

示例

Compare the same transformed point and line in both 3D and 2D. The 3D test fails because the Z difference matters even though the 2D footprints are close enough.

Code
WITH sample AS (
  SELECT ST_Transform('SRID=4326;POINT(-72.1235 42.3521 4)'::geometry, 2163) AS input_point,
         ST_Transform(
           'SRID=4326;LINESTRING(-72.1260 42.45 15,-72.123 42.1546 20)'::geometry,
           2163
         ) AS input_line
)
SELECT ST_3DDWithin(input_point, input_line, 126.8) AS within_dist_3d,
       ST_DWithin(input_point, input_line, 126.8) AS within_dist_2d,
       input_point AS input_point,
       input_line AS input_line
FROM sample;
栅格输出
-[ RECORD 1 ]--+----------------------------------------------------------------------------------------------------------------------------------
within_dist_3d | f
within_dist_2d | t
input_point    | POINT Z (-11774128.9 5237160.2 4)
input_line     | LINESTRING Z (-11774339.5 5243556.8 15,-11773706.7 5215256.3 20)