ST_ndIntersects函數,判斷指定的兩個對象在指定的座標軸上是否相交。
文法
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 | 如存在,表示按此時間作為結束時間截取子軌跡。 |
描述
在指定維度上,返回需要判斷的兩個對象(即第一個和第二個參數)的相交結果。對於沒有值的維度,將其視為任意值進行判斷。
如果函數包含ts和te參數,表示需要判斷的對象(traj,或traj1和traj2)是在[ts,te]時間段內的子軌跡;如果函數不包含ts和te參數,表示需要判斷的對象(traj,或traj1和traj2)是完整的軌跡。
直接調用ST_Intersects(...)
函數相當於調用ST_2DIntersects(...)
(若前兩個參數其中一個為幾何對象)或ST_3DTIntersects(...)
(若前兩個參數均為軌跡對象)。
樣本
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