Return the smallest distance ever
{geo,npoint,tnpoint} |=| {geo,npoint,tnpoint} → float
The operator |=|
can be used for doing nearest neightbor searches using a GiST or an SP-GiST index (see the section called “Indexing”).
SELECT tnpoint '[NPoint(2, 0.3)@2001-01-01, NPoint(2, 0.7)@2001-01-02]' |=| geometry 'SRID=5676;Linestring(50 50,55 55)'; -- 31.69220882252415 SELECT tnpoint '[NPoint(2, 0.3)@2001-01-01, NPoint(2, 0.7)@2001-01-02]' |=| npoint 'NPoint(1, 0.5)'; -- 19.49691305292373 SELECT tnpoint '[NPoint(2, 0.3)@2001-01-01, NPoint(2, 0.7)@2001-01-02]' |=| tnpoint '[NPoint(1, 0.3)@2001-01-01, NPoint(1, 0.7)@2001-01-02]'; -- 5.231180723735304
Return the instant of the first temporal network point at which the two arguments are at the nearest distance
nearestApproachInstant({geo,npoint,tnpoint},{geo,npoint,tnpoint}) → tnpoint
SELECT nearestApproachInstant(tnpoint '[NPoint(2, 0.3)@2001-01-01, NPoint(2, 0.7)@2001-01-02]', geometry 'Linestring(50 50,55 55)'); -- NPoint(2,0.349928)@2001-01-01 02:59:44.402905+01 SELECT nearestApproachInstant(tnpoint '[NPoint(2, 0.3)@2001-01-01, NPoint(2, 0.7)@2001-01-02]', npoint 'NPoint(1, 0.5)'); -- NPoint(2,0.592181)@2001-01-01 17:31:51.080405+01
Return the line connecting the nearest approach point between the two arguments
shortestLine({geo,npoint,tpoint},{geo,npoint,tpoint}) → geometry
The function will only return the first line that it finds if there are more than one
SELECT ST_AsText(shortestLine(tnpoint '[NPoint(2, 0.3)@2001-01-01, NPoint(2, 0.7)@2001-01-02]', geometry 'Linestring(50 50,55 55)')); -- LINESTRING(50.7960725266492 48.8266286733015,50 50) SELECT ST_AsText(shortestLine(tnpoint '[NPoint(2, 0.3)@2001-01-01, NPoint(2, 0.7)@2001-01-02]', npoint 'NPoint(1, 0.5)')); -- LINESTRING(77.0902838115125 66.6659083092593,90.8134936900394 46.4385792121146)
Return the temporal distance
tnpoint <-> tnpoint → tfloat
SELECT tnpoint '[NPoint(1, 0.3)@2001-01-01, NPoint(1, 0.5)@2001-01-03]' <-> npoint 'NPoint(1, 0.2)'; -- [2.34988300875063@2001-01-02 00:00:00+01, 2.34988300875063@2001-01-03 00:00:00+01] SELECT tnpoint '[NPoint(1, 0.3)@2001-01-01, NPoint(1, 0.5)@2001-01-03]' <-> geometry 'Point(50 50)'; -- [25.0496666945044@2001-01-01 00:00:00+01, 26.4085688426232@2001-01-03 00:00:00+01] SELECT tnpoint '[NPoint(1, 0.3)@2001-01-01, NPoint(1, 0.5)@2001-01-03]' <-> tnpoint '[NPoint(1, 0.3)@2001-01-02, NPoint(1, 0.5)@2001-01-04]' -- [2.34988300875063@2001-01-02 00:00:00+01, 2.34988300875063@2001-01-03 00:00:00+01]