全部產品
Search
文件中心

ApsaraDB RDS:ST_CrossingPoints

更新時間:Nov 26, 2024

求軌跡的所有採樣點中,所有穿過指定幾何地區的點。

文法

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)