All Products
Search
Document Center

PolarDB:ST_intersects

Last Updated:Mar 28, 2026

Returns true if two trajectory objects share any spatial overlap within the specified time range.

Syntax

boolean ST_intersects(trajectory traj1, trajectory traj2);
boolean ST_intersects(trajectory traj1, trajectory traj2, tsrange range);
boolean ST_intersects(trajectory traj1, trajectory traj2, timestamp t1, timestamp t2);

The first overload evaluates spatial intersection across the full extent of both trajectories. The second and third overloads restrict the check to the specified time range.

Parameters

ParameterDescription
traj1, traj2The trajectory objects to compare.
rangeThe time range, expressed as a tsrange value.
t1The start timestamp of the time range.
t2The end timestamp of the time range.

Examples

Check whether two trajectories intersect between 13:00 and 14:00 on January 1, 2010:

SELECT ST_intersects(
    (SELECT traj FROM traj_table WHERE id = 1),
    (SELECT traj FROM traj_table WHERE id = 2),
    '2010-1-1 13:00:00',
    '2010-1-1 14:00:00'
);