指定された軸上で、第 1 引数が第 2 引数に完全に含まれている場合に true を返します。この関数は ST_ndContains 関数と同様の動作をします。
構文
bool ST_TWithin(tsrange r, trajectory traj);
bool ST_TWithin(trajectory traj, tsrange r);
bool ST_2DWithin(geometry geom, trajectory traj);
bool ST_2DWithin(trajectory traj, geometry geom);
bool ST_2DWithin(geometry geom, trajectory traj, timestamp ts, timestamp te);
bool ST_2DWithin(trajectory traj, geometry geom, timestamp ts, timestamp te);
bool ST_{2D|2DT|3D|3DT}Within(trajectory traj, boxndf box);
bool ST_{2D|2DT|3D|3DT}Within(trajectory traj, boxndf box, timestamp ts, timestamp te);パラメーター
| パラメーター | 説明 |
|---|---|
geom | 比較対象のジオメトリです。 |
traj | 比較対象のトラジェクトリ、またはサブトラジェクトリを抽出する元となるトラジェクトリです。 |
box | 比較対象のバウンディングボックスです。 |
r | 比較対象の時間範囲です。 |
ts | サブトラジェクトリ抽出の時間範囲の開始時刻です(省略可能)。 |
te | サブトラジェクトリ抽出の時間範囲の終了時刻です(省略可能)。 |
説明
この関数ファミリーは、以下の 3 つの軸に対応しています。
ST_TWithin — 時間軸(時系列のみ)における包含関係をチェックします。
ST_2DWithin — 2 次元空間(X/Y)における包含関係をチェックし、任意でタイムウィンドウ [
ts,te] に制限できます。ST_{2DT|3D|3DT}Within —
boxndfバウンディングボックスを用いて、2 次元空間+時間、3 次元空間、または 3 次元空間+時間における包含関係をチェックします。任意でタイムウィンドウに制限できます。
ts および te が指定された場合、関数は全トラジェクトリではなく、そのタイムウィンドウ内に存在するサブトラジェクトリのみを評価します。
説明
POLYHEDRALSURFACE などのジオメトリ型には対応していません。
例
以下の例では、2 次元空間においてジオメトリ (b) がトラジェクトリ (a) 内に含まれるかどうかをチェックします。
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,
'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)'::geometry b
)
SELECT ST_2dWithin(b,a) from traj;
st_2dwithin
-------------
t結果の t(true)より、b が a の 2 次元空間内に含まれることが確認されます。