すべてのプロダクト
Search
ドキュメントセンター

ApsaraDB RDS:ST_{Z|T|2D|2DT|3D|3DT}Intersects

最終更新日:Mar 29, 2026

指定されたディメンションで2つの空間時間オブジェクトが少なくとも1つのポイントを共有する場合、trueを返します。この関数ファミリーは、Z、T、2D、2DT、3D、および3DTの6つのディメンションバリアントをカバーしており、単一のクエリで空間交差、時間的重複、またはその両方をテストできます。

構文

bool ST_{2D|3D}Intersects(geometry geom, trajectory traj);
bool ST_{2D|3D}Intersects(trajectory traj, geometry geom);
bool ST_{2D|3D}Intersects(geometry geom, trajectory traj, timestamp ts, timestamp te);
bool ST_{2D|3D}Intersects(trajectory traj, geometry geom, timestamp ts, timestamp te);
bool ST_{Z|T|2D|2DT|3D|3DT}Intersects(boxndf box, trajectory traj);
bool ST_{Z|T|2D|2DT|3D|3DT}Intersects(trajectory traj, boxndf box);
bool ST_{Z|T|2D|2DT|3D|3DT}Intersects(boxndf box, trajectory traj, timestamp ts, timestamp te);
bool ST_{Z|T|2D|2DT|3D|3DT}Intersects(trajectory traj, boxndf box, timestamp ts, timestamp te);
bool ST_{2D|2DT|3D|3DT}Intersects(trajectory traj1, trajectory traj2);
bool ST_{2D|2DT|3D|3DT}Intersects(trajectory traj1, trajectory traj2, timestamp ts, timestamp te);

パラメータ

パラメータ説明
geom比較するジオメトリ。
traj比較するトラジェクトリ、または比較するサブトラジェクトリを含む元のトラジェクトリ。
traj1比較するトラジェクトリ、または比較するサブトラジェクトリを含む元のトラジェクトリ。
traj2比較するトラジェクトリ、または比較するサブトラジェクトリを含む元のトラジェクトリ。
box比較するバウンディングボックス。
tsサブトラジェクトリを抽出するための時間範囲の開始。オプション。
teサブトラジェクトリを抽出するための時間範囲の終了。オプション。

説明

ディメンションがバリアント名に含まれていない場合、それは制約なしです。関数はそのディメンションを任意の値と一致するものとして扱います。

時間範囲の動作

tsteを使用する場合:関数は、指定された時間範囲で2つのオブジェクトからサブトラジェクトリを抽出し、それらのサブトラジェクトリが交差するかどうかをテストします。

tsteを使用しない場合:関数は完全なトラジェクトリを比較します。

等価性

ST_Intersects(...)は、次のものと同じ効果を提供します。

  • 1つの引数がgeometryである場合のST_2DIntersects(...)

  • 両方の引数がトラジェクトリである場合のST_3DTIntersects(...)

次のクエリは、単一のパスで2つのトラジェクトリに対して4つのディメンションバリアントをテストします。トラジェクトリaは2000-01-01の03:15から05:16まで実行され、トラジェクトリbは同日の02:17から03:43まで実行されます。

WITH traj AS(
    SELECT (' {"trajectory":{"version":1,"type":"STPOINT","leafcount":6,"start_time":"2000-01-01 03:15:42","end_time":"2000-01-01 05:16:43",' ||
            '"spatial":"LINESTRING(2 2 0,33.042158099636 36.832684322819 0,47.244002354518 47.230026333034 0,64.978971942887 60.618813472986 0,77.621717839502 78.012496630661 0,80 78 0)",' ||
            '"timeline":["2000-01-01 03:15:42","2000-01-01 03:39:54","2000-01-01 04:04:06","2000-01-01 04:28:18","2000-01-01 04:52:31","2000-01-01 05:16:43"]}}')::trajectory a,
           ('{"trajectory":{"version":1,"type":"STPOINT","leafcount":4,"start_time":"2000-01-01 02:17:58.656079","end_time":"2000-01-01 03:43:59.620923",' ||
            '"spatial":"LINESTRING(40 2 0,15.17549143297 51.766017656152 0,1.444002354518 69.630026333034 0,3 70 0)","timeline":["2000-01-01 02:17:58.656079",' ||
            '"2000-01-01 02:46:38.977693","2000-01-01 03:15:19.299307","2000-01-01 03:43:59.620923"]}}')::trajectory b
)
SELECT ST_2dIntersects(a,b), ST_2dtIntersects(a,b), ST_3dIntersects(a,b), ST_3dtIntersects(a,b) from traj;

結果:

 st_2dintersects | st_2dtintersects | st_3dintersects | st_3dtintersects
-----------------+------------------+-----------------+------------------
 t               | f                | t               | f

2Dおよび3Dバリアントは両方ともtを返します。これは、abのパスがXY平面とXYZ空間で交差するためです。2DTおよび3DTバリアントはfを返します。これは、2つのトラジェクトリが時間的に重複しているにもかかわらず (03:15~03:43)、その共有ウィンドウ中にパスが交差しないため、両方のオブジェクトが同時に同じ位置に存在しないことを意味します。