Obtains the points crossing the specified geometric area from the trajectory sampling points.
Syntax
TABLE(idx integer, inside bool, pnt trajectory, t timestamp, x double precision, y double precision) ST_CrossingPoints(trajectory traj, geometry geom)
Parameters
Parameter | Description |
traj | The trajectory object. |
geom | The geometric area. |
Return values
A data table that contains the following parameters is returned.
Parameter | Description |
idx | The sequence number of the trajectory sampling point, starting from 0. |
inside | Indicates whether the point is inside the geometric area. |
pnt | The point that is in the form of a single-point trajectory and contains attribute information. |
t | The timestamp of the point. |
x | The x-coordinate of the point. |
y | The y-coordinate of the point. |
Description
If the previous sampling point of the trajectory is outside the geometric area and the next sampling point is inside the geometric area, or the previous sampling point is inside the geometric area and the next sampling point is outside the geometric area, the point is crossing the geometric area. This function displays the crossing points in different rows.
Example
Query crossing points of the trajectory object that moves into and then out of the specified geometric area.
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))');
Sample result:
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)