ST_ndContains函數(shù),判斷第一個(gè)參數(shù)所對(duì)應(yīng)的對(duì)象在指定的坐標(biāo)軸上是否包含第二個(gè)參數(shù)所對(duì)應(yīng)的對(duì)象。

語(yǔ)法

bool ST_TContains(tsrange r, trajectory traj);
bool ST_TContains(trajectory traj, tsrange r);
bool ST_2DContains(geometry geom, trajectory traj);
bool ST_2DContains(trajectory traj, geometry geom);
bool ST_2DContains(geometry geom, trajectory traj, timestamp ts, timestamp te);
bool ST_2DContains(trajectory traj, geometry geom, timestamp ts, timestamp te);
bool ST_{2D|2DT|3D|3DT}Contains(boxndf box, trajectory traj);
bool ST_{2D|2DT|3D|3DT}Contains(boxndf box, trajectory traj, timestamp ts, timestamp te);

參數(shù)

參數(shù)名稱 描述
geom 需要判斷的幾何對(duì)象。
traj 需要判斷的軌跡對(duì)象,或者產(chǎn)生子軌跡的原始軌跡。
box 需要判斷的外包框?qū)ο蟆?/td>
r 需要判讀的時(shí)間范圍。
ts 如存在,表示按此時(shí)間作為開(kāi)始時(shí)間截取子軌跡。
te 如存在,表示按此時(shí)間作為結(jié)束時(shí)間截取子軌跡。

描述

判斷第一個(gè)參數(shù)是否包含第二個(gè)參數(shù)。

  • 對(duì)于geometry類型,目前僅支持二維的操作,即判斷軌跡或一定時(shí)間段內(nèi)的子軌跡的二維投影,是否包含或被包含于給定的geom內(nèi)。
  • 對(duì)于boxndf作為第一個(gè)參數(shù),trajectory作為第二個(gè)參數(shù)的Contains函數(shù),將判斷各個(gè)維度軌跡(或子軌跡)在指定的維度上是否在給定的外包框范圍內(nèi)。如果外包框、軌跡或子軌跡不包含某個(gè)給定的維度,則此維度將取任意值,即對(duì)此坐標(biāo)軸自動(dòng)滿足contains條件。
說(shuō)明 部分geometry類型(如POLYHEDRALSURFACE)目前不支持ST_Contains操作。

示例

WITH traj AS(
    Select ST_makeTrajectory('STPOINT', 'LINESTRING(0 0, 50 50, 100 100)'::geometry,
                             ('[' || ST_PGEpochToTS(0) || ',' || ST_PGEpochToTS(100) || ')')::tsrange,
                             '{"leafcount":3,"attributes":{"velocity": {"type": "integer", "length": 2,"nullable" : true,"value": [120,130,140]}, "accuracy": {"type": "float", "length": 4, "nullable" : false,"value": [120,130,140]}, "bearing": {"type": "float", "length": 8, "nullable" : false,"value": [120,130,140]}, "acceleration": {"type": "string", "length": 20, "nullable" : true,"value": ["120","130","140"]}, "active": {"type": "timestamp", "nullable" : false,"value": ["Fri Jan 01 11:35:00 2010", "Fri Jan 01 12:35:00 2010", "Fri Jan 01 13:30:00 2010"]}}, "events": [{"2" : "Fri Jan 02 15:00:00 2010"}, {"3" : "Fri Jan 02 15:30:00 2010"}]}') b,
           ST_MakeBox3dt(0,0,0,ST_PgEpochToTS(0), 50,50,50, ST_PgEpochToTS(49)) a
)
SELECT ST_2dContains(a,b,ST_PGEpochToTS(0), ST_PGEpochToTS(49)), ST_3dContains(a,b,ST_PGEpochToTS(0), ST_PGEpochToTS(49)),
       ST_2dtContains(a,b,ST_PGEpochToTS(0), ST_PGEpochToTS(49)), ST_3dtContains(a,b,ST_PGEpochToTS(0), ST_PGEpochToTS(49)),
       ST_2dContains(a,b,ST_PGEpochToTS(0), ST_PGEpochToTS(50)), ST_3dContains(a,b,ST_PGEpochToTS(0), ST_PGEpochToTS(50)),
       ST_2dtContains(a,b,ST_PGEpochToTS(0), ST_PGEpochToTS(50)), ST_3dtContains(a,b,ST_PGEpochToTS(0), ST_PGEpochToTS(50)),
       ST_2dContains(a,b,ST_PGEpochToTS(0), ST_PGEpochToTS(70)), ST_3dContains(a,b,ST_PGEpochToTS(0), ST_PGEpochToTS(70)),
       ST_2dtContains(a,b,ST_PGEpochToTS(0), ST_PGEpochToTS(70)), ST_3dtContains(a,b,ST_PGEpochToTS(0), ST_PGEpochToTS(70)) from traj;
 st_2dcontains | st_3dcontains | st_2dtcontains | st_3dtcontains | st_2dcontains | st_3dcontains | st_2dtcontains | st_3dtcontains | st_2dcontains | st_3dcontains | st_2dtcontains | st_3dtcontains 
---------------+---------------+----------------+----------------+---------------+---------------+----------------+----------------+---------------+---------------+----------------+----------------
 t             | t             | t              | t              | t             | t             | f              | f              | f             | f             | f              | f