We present next the functions that compute distance operations for temporal poses. Notice that for these operations only the point component is considered, not the orientation.
Return the smallest distance ever
{geo,pose,tpose} |=| {geo,pose,tpose} → float
SELECT tpose '[Pose(Point(2 2), 0.3)@2001-01-01, Pose(Point(2 2), 0.7)@2001-01-02]' |=| geometry 'Linestring(50 50,55 55)'; -- 67.88225099390856 SELECT tpose '[Pose(Point(2 2), 0.3)@2001-01-01, Pose(Point(2 2), 0.7)@2001-01-02]' |=| pose 'Pose(Point(1 1), 0.5)'; -- 1.4142135623730951 SELECT tpose '[Pose(Point(1 1), 0.3)@2001-01-01, Pose(Point(1 1), 0.5)@2001-01-03]' |=| pose 'Pose(Point(2 2), 0.2)'; -- 1.4142135623730951 SELECT tpose '[Pose(Point(1 1), 0.3)@2001-01-01, Pose(Point(1 1), 0.5)@2001-01-03]' |=| geometry 'Linestring(2 2,2 1,3 1)'; -- 1
The operator |=|
can be used for doing nearest neightbor searches using GiST or SP-GiST indexes (see the section called “Indexing”).
Return the instant of the first temporal pose at which the two arguments are at the nearest distance
SELECT asText(nearestApproachInstant(tpose '[Pose(Point(2 2), 0.3)@2001-01-01, Pose(Point(2 2), 0.7)@2001-01-02]', geometry 'Linestring(50 50,55 55)')); -- Pose(POINT(2 2),0.3)@2001-01-01 SELECT asText(nearestApproachInstant(tpose '[Pose(Point(2 2), 0.3)@2001-01-01, Pose(Point(2 2), 0.7)@2001-01-02]', pose 'Pose(Point(1 1), 0.5)')); -- Pose(POINT(2 2),0.3)@2001-01-01
Return the line connecting the nearest approach point
shortestLine({geo,pose,tpose},{geo,pose,tpose}) → geometry
The function will only return the first line that it finds if there are more than one.
SELECT ST_AsText(shortestLine(tpose '[Pose(Point(2 2), 0.3)@2001-01-01, Pose(Point(2 2), 0.7)@2001-01-02]', geometry 'Linestring(50 50,55 55)')); -- LINESTRING(2 2,50 50) SELECT ST_AsText(shortestLine(tpose '[Pose(Point(2 2), 0.3)@2001-01-01, Pose(Point(2 2), 0.7)@2001-01-02]', pose 'Pose(Point(1 1), 0.5)')); -- LINESTRING(2 2,1 1)
Return the temporal distance
tpose <-> tpose → tfloat
SELECT round(tpose '[Pose(Point(1 1), 0.3)@2001-01-01, Pose(Point(1 1), 0.5)@2001-01-03]' <-> pose 'Pose(Point(2 2), 0.2)', 6); -- [1.414214@2001-01-01, 1.414214@2001-01-03] SELECT round(tpose '[Pose(Point(1 1), 0.3)@2001-01-01, Pose(Point(1 1), 0.5)@2001-01-03]' <-> geometry 'Point(50 50)', 6); -- [69.296465@2001-01-01, 69.296465@2001-01-03] SELECT round(tpose '[Pose(Point(1 1), 0.3)@2001-01-01, Pose(Point(2 2), 0.5)@2001-01-03]' <-> tpose '[Pose(Point(1 2), 0.3)@2001-01-02, Pose(Point(2 1), 0.5)@2001-01-04]', 6); -- [0.707107@2001-01-02, 0.5@2001-01-02 12:00:00+01, 0.707107@2001-01-03]