ST_CrossingPoints

求轨迹的所有采样点中,所有穿过指定几何区域的点。

语法

TABLE(idx integer, inside bool, pnt trajectory, t timestamp, x double precision, y double precision) ST_CrossingPoints(trajectory traj, geometry geom)

参数

参数名称

描述

traj

轨迹对象。

geom

几何区域。

返回值

返回一个数据表,包含以下参数:

参数名称

描述

idx

轨迹采样点的序号,从0开始。

inside

此点是否在区域中。

pnt

此轨迹点,以单点轨迹的形式输出,包含属性信息。

t

此点的时间戳。

x

此点的x坐标。

y

此点的y坐标。

描述

如果轨迹的前一个采样点在区域外,而后一个采样点在区域中,或前一个采样点在区域中,而后一个采样点在区域外,则认为此点是轨迹对于区域的跨越点。本函数按行输出所有的跨越点。

示例

轨迹进入一个区域,再移出:

SELECT * FROM ST_CrossingPoints(
               '{"trajectory":{"version":1,"type":"STPOINT","leafcount":7,"start_time":"2000-01-01 00:00:00","end_time":"2000-01-07 00:00:00","spatial":"LINESTRING(0 0,2 1,0 0,3 3,0 0,1 4,0 0)","timeline":["2000-01-01 00:00:00","2000-01-02 00:00:00","2000-01-03 00:00:00","2000-01-04 00:00:00","2000-01-05 00:00:00","2000-01-06 00:00:00","2000-01-07 00:00:00"]}}',
               'POLYGON((2 2, 2 3, 3 3, 3 2, 2 2))');

结果:

 idx | inside |                                                                                            pnt                                                                                            |          t          | x | y 
-----+--------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+---------------------+---+---
   3 | t      | {"trajectory":{"version":1,"type":"STPOINT","leafcount":1,"start_time":"2000-01-04 00:00:00","end_time":"2000-01-04 00:00:00","spatial":"POINT(3 3)","timeline":["2000-01-04 00:00:00"]}} | 2000-01-04 00:00:00 | 3 | 3
   4 | f      | {"trajectory":{"version":1,"type":"STPOINT","leafcount":1,"start_time":"2000-01-05 00:00:00","end_time":"2000-01-05 00:00:00","spatial":"POINT(0 0)","timeline":["2000-01-05 00:00:00"]}} | 2000-01-05 00:00:00 | 0 | 0
(2 rows)