名前

ST_3DDWithin — 二つの3次元ジオメトリが与えらえれた3次元距離内にあるかどうかをテストします。

概要

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

説明

二つのジオメトリ値の3次元距離がdistance_of_srid以下ならTRUEを返します。距離の単位はジオメトリの空間参照系の単位です。この関数から意味のある結果を得るには、引数に使うジオメトリを同じ座標系 (同じSRIDを持つ)にしなければなりません。

[注記]

この関数を実行すると、対象ジオメトリにおいて使用できるインデックスを使用したバウンディングボックスによる比較が自動的に行われます。

この関数は3次元に対応し、Z値を削除しません。

この関数は多面体サーフェスに対応しています。

このメソッドはSQL/MM仕様の実装です。 SQL-MM ?

Availability: 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)