Most functions for temporal types described in the previous chapters can be applied for temporal circular buffer types. Therefore, in the signatures of the functions, the notation base
represents a cbuffer
and the notations ttype
, tpoint
, and tgeompoint
also represent a tcbuffer
. Furthermore, the functions that have an argument of type geometry
accept in addition an argument of type cbuffer
. To avoid redundancy, we only present next some examples of these functions and operators for temporal circular buffers.
Transform a temporal circular buffer to another subtype
tcbufferInst(tcbuffer) → tcbufferInst
tcbufferSeq(tcbuffer) → tcbufferSeq
tcbufferSeqSet(tcbuffer) → tcbufferSeqSet
SELECT asText(tcbufferSeq(tcbuffer 'Cbuffer(Point(1 1), 0.5)@2001-01-01', 'discrete')); -- {Cbuffer(Point(1 1),0.5)@2001-01-01} SELECT asText(tcbufferSeq(tcbuffer 'Cbuffer(Point(1 1), 0.5)@2001-01-01')); -- [Cbuffer(Point(1 1),0.5)@2001-01-01] SELECT asText(tcbufferSeqSet(tcbuffer 'Cbuffer(Point(1 1), 0.5)@2001-01-01')); -- {[Cbuffer(Point(1 1),0.5)@2001-01-01]}
Transform a temporal circular buffer to another interpolation
setInterp(tcbuffer, interp) → tcbuffer
SELECT asText(setInterp(tcbuffer 'Cbuffer(Point(1 1),0.2)@2001-01-01','linear')); -- [Cbuffer(Point(1 1),0.2)@2001-01-01] SELECT asText(setInterp(tcbuffer '{[Cbuffer(Point(1 1),0.1)@2001-01-01], [Cbuffer(Point(1 1),0.2)@2001-01-02]}', 'discrete')); -- {Cbuffer(Point(1 1),0.1)@2001-01-01, Cbuffer(Point(1 1),0.2)@2001-01-02}
Round the fraction of the temporal circular buffer to the number of decimal places
round(tcbuffer,integer) → tcbuffer
SELECT asText(round(tcbuffer '{[Cbuffer(Point(1 1),0.123456789)@2001-01-01, Cbuffer(Point(1 1),0.5)@2001-01-02)}', 6)); /* {[Cbuffer(Point(1 1),0.123457)@2001-01-01, Cbuffer(Point(1 1),0.5)@2001-01-02)} */
Return the values
getValues(tcbuffer) → cbufferset
SELECT asText(getValues(tcbuffer '{[Cbuffer(Point(1 1), 0.3)@2001-01-01, Cbuffer(Point(1 1), 0.5)@2001-01-02)}')); -- {"Cbuffer(Point(1 1),0.3)","Cbuffer(Point(1 1),0.5)"} SELECT asEWKT(getValues(tcbuffer 'SRID=5676;{[Cbuffer(Point(1 1), 0.3)@2001-01-01, Cbuffer(Point(1 1), 0.3)@2001-01-02)}')); -- {"Cbuffer(Point(1 1),0.3)"}
Return the points
points(tcbuffer) → bigintset
SELECT asText(points(tcbuffer '{Cbuffer(Point(3 3), 0.3)@2001-01-01, Cbuffer(Point(1 1), 0.5)@2001-01-02}')); -- {Point(1 1), Point(3 3)}
Return the value at a timestamp
valueAtTimestamp(tcbuffer,timestamptz) → cbuffer
SELECT asText(valueAtTimestamp(tcbuffer '[Cbuffer(Point(1 1), 0.3)@2001-01-01, Cbuffer(Point(3 3), 0.5)@2001-01-03)', '2001-01-02')); -- Cbuffer(Point(2 2),0.4)
Set the spatial reference identifier
setSRID(tcbuffer) → tcbuffer
SELECT asEWKT(setSRID(tcbuffer '[Cbuffer(Point(0 0),1)@2001-01-01, Cbuffer(Point(1 1),2)@2001-01-02)', 4326)); -- SRID=4326;[Cbuffer(POINT(0 0),1)@2001-01-01, Cbuffer(POINT(1 1),2)@2001-01-02)
Transform to a different spatial reference
transform(tcbuffer,integer) → tcbuffer
transform(tcbuffer,pipeline text,to_srid integer,is_forward bool=true) → tcbuffer
The transform
function specifies the transformation with a target SRID. An error is raised when the input temporal circular buffer has an unknown SRID (represented by 0).
The transformPipeline
function specifies the transformation with a defined coordinate transformation pipeline represented with the following string format: urn:ogc:def:coordinateOperation:AUTHORITY::CODE
. The SRID of the input temporal circular buffer is ignored, and the SRID of the output temporal circular buffer will be set to zero unless a value is provided via the optional to_srid
parameter. As stated by the last parameter, the pipeline is executed by default in a forward direction; by setting the parameter to false, the pipeline is executed in the inverse direction.
SELECT asEWKT(transform(tcbuffer 'SRID=4326;Cbuffer(Point(4.35 50.85),1)@2001-01-01', 3812)); -- SRID=3812;Cbuffer(POINT(648679.0180353033 671067.0556381135),1)@2001-01-01
WITH test(tcbuffer, pipeline) AS ( SELECT tcbuffer 'SRID=4326;{Cbuffer(Point(4.3525 50.846667),1)@2001-01-01, Cbuffer(Point(-0.1275 51.507222),2)@2001-01-02}', text 'urn:ogc:def:coordinateOperation:EPSG::16031' ) SELECT asEWKT(transformPipeline(transformPipeline(tcbuffer, pipeline, 4326), pipeline, 4326, false), 6) FROM test; /* SRID=4326;{Cbuffer(POINT(4.3525 50.846667),1)@2001-01-01, Cbuffer(POINT(-0.1275 51.507222),2)@2001-01-02} */
TODO Return the area traversed by the temporal circular buffer
traversedArea(tcbuffer) → geometry
SELECT traversedArea(tcbuffer '[Cbuffer(Point(1 1), 0.3)@2001-01-01, Cbuffer(Point(1 1), 0.5)@2001-01-02]'); -- 54.3757408468784
Construct the bounding box from a cbuffer and, optionally, a timestamp or a period
stbox(cbuffer) → stbox
stbox(cbuffer,{timestamptz,tstzspan}) → stbox
SELECT stbox(cbuffer 'Cbuffer(Point(1 1),0.3)'); -- STBOX X((0.7,0.7),(1.3,1.3)) SELECT stbox(cbuffer 'Cbuffer(Point(1 1),0.3)', timestamptz '2001-01-01'); -- STBOX XT(((0.7,0.7),(1.3,1.3)),[2001-01-01, 2001-01-01]) SELECT stbox(cbuffer 'Cbuffer(Point(1 1),0.3)', tstzspan '[2001-01-01,2001-01-02]'); -- STBOX XT(((0.7,0.7),(1.3,1.3)),[2001-01-01, 2001-01-02])
TODO Return the instant of the first temporal circular buffer at which the two arguments are at the nearest distance
nearestApproachInstant({geo,cbuffer,tpoint},{geo,cbuffer,tpoint}) → tpoint
SELECT nearestApproachInstant(tcbuffer '[Cbuffer(Point(2 2), 0.3)@2001-01-01, Cbuffer(Point(2 2), 0.7)@2001-01-02]', geometry 'Linestring(50 50,55 55)'); -- Cbuffer(Point(2 2),0.349928)@2001-01-01 02:59:44.402905+01 SELECT nearestApproachInstant(tcbuffer '[Cbuffer(Point(2 2), 0.3)@2001-01-01, Cbuffer(Point(2 2), 0.7)@2001-01-02]', cbuffer 'Cbuffer(Point(1 1), 0.5)'); -- Cbuffer(Point(2 2),0.592181)@2001-01-01 17:31:51.080405+01
TODO Return the smallest distance ever between the two arguments
nearestApproachDistance({geo,cbuffer,tpoint},{geo,cbuffer,tpoint}) → float
SELECT nearestApproachDistance(tcbuffer '[Cbuffer(Point(2 2), 0.3)@2001-01-01, Cbuffer(Point(2 2), 0.7)@2001-01-02]', geometry 'Linestring(50 50,55 55)'); -- 1.41793220500979 SELECT nearestApproachDistance(tcbuffer '[Cbuffer(Point(2 2), 0.3)@2001-01-01, Cbuffer(Point(2 2), 0.7)@2001-01-02]', cbuffer 'Cbuffer(Point(1 1), 0.5)'); -- Cbuffer(Point(2 2),0.592181)@2001-01-01 17:31:51.080405+01
Function nearestApproachDistance
has an associated operator |=|
that can be used for doing nearest neightbor searches using a GiST index (see the section called “Indexing”).
TODO Return the line connecting the nearest approach point between the two arguments
shortestLine({geo,cbuffer,tpoint},{geo,cbuffer,tpoint}) → geometry
The function will only return the first line that it finds if there are more than one
SELECT st_astext(shortestLine(tcbuffer '[Cbuffer(Point(2 2), 0.3)@2001-01-01, Cbuffer(Point(2 2), 0.7)@2001-01-02]', geometry 'Linestring(50 50,55 55)')); -- LINESTRING(50.7960725266492 48.8266286733015,50 50) SELECT st_astext(shortestLine(tcbuffer '[Cbuffer(Point(2 2), 0.3)@2001-01-01, Cbuffer(Point(2 2), 0.7)@2001-01-02]', cbuffer 'Cbuffer(Point(1 1), 0.5)')); -- LINESTRING(77.0902838115125 66.6659083092593,90.8134936900394 46.4385792121146)
TODO Restrict to (the complement of) a value
atValue(tcbuffer,base) → tcbuffer
minusValue(tcbuffer,base) → tcbuffer
SELECT atValue(tcbuffer '[Cbuffer(Point(2 2), 0.3)@2001-01-01, Cbuffer(Point(2 2), 0.7)@2001-01-03]', 'Cbuffer(Point(2 2), 0.5)'); -- {[Cbuffer(Point(2 2),0.5)@2001-01-02]} SELECT minusValue(tcbuffer '[Cbuffer(Point(2 2), 0.3)@2001-01-01, Cbuffer(Point(2 2), 0.7)@2001-01-03]', 'Cbuffer(Point(2 2), 0.5)'); /* {[Cbuffer(Point(2 2),0.3)@2001-01-01, Cbuffer(Point(2 2),0.5)@2001-01-02), (Cbuffer(Point(2 2),0.5)@2001-01-02, Cbuffer(Point(2 2),0.7)@2001-01-03]} */
TODO Restrict to a geometry
atGeometry(tcbuffer,geometry) → tcbuffer
minusGeometry(tcbuffer,geometry) → tcbuffer
SELECT atGeometry(tcbuffer '[Cbuffer(Point(2 2), 0.3)@2001-01-01, Cbuffer(Point(2 2), 0.7)@2001-01-03]', 'Polygon((40 40,40 50,50 50,50 40,40 40))'); SELECT minusGeometry(tcbuffer '[Cbuffer(Point(2 2), 0.3)@2001-01-01, Cbuffer(Point(2 2), 0.7)@2001-01-03]', 'Polygon((40 40,40 50,50 50,50 40,40 40))'); /* {(Cbuffer(Point(2 2),0.342593)@2001-01-01 05:06:40.364673+01, Cbuffer(Point(2 2),0.7)@2001-01-03 00:00:00+01]} */
Traditional comparison operators
tcbuffer = tcbuffer → boolean
tcbuffer <> tcbuffer → boolean
tcbuffer < tcbuffer → boolean
tcbuffer > tcbuffer → boolean
tcbuffer <= tcbuffer → boolean
tcbuffer >= tcbuffer → boolean
SELECT tcbuffer '{[Cbuffer(Point(1 1), 0.1)@2001-01-01, Cbuffer(Point(1 1), 0.3)@2001-01-02), [Cbuffer(Point(1 1), 0.3)@2001-01-02, Cbuffer(Point(1 1), 0.5)@2001-01-03]}' = tcbuffer '[Cbuffer(Point(1 1), 0.1)@2001-01-01, Cbuffer(Point(1 1), 0.5)@2001-01-03]'; -- true SELECT tcbuffer '{[Cbuffer(Point(1 1), 0.1)@2001-01-01, Cbuffer(Point(1 1), 0.5)@2001-01-03]}' <> tcbuffer '[Cbuffer(Point(1 1), 0.1)@2001-01-01, Cbuffer(Point(1 1), 0.5)@2001-01-03]'; -- false SELECT tcbuffer '[Cbuffer(Point(1 1), 0.1)@2001-01-01, Cbuffer(Point(1 1), 0.5)@2001-01-03]' < tcbuffer '[Cbuffer(Point(1 1), 0.1)@2001-01-01, Cbuffer(Point(1 1), 0.6)@2001-01-03]'; -- true
Temporal comparison operators
tcbuffer #= tcbuffer → tbool
tcbuffer #<> tcbuffer → tbool
SELECT tcbuffer '[Cbuffer(Point(1 1), 0.2)@2001-01-01, Cbuffer(Point(1 1), 0.4)@2001-01-03)' #= cbuffer 'Cbuffer(Point(1 1), 0.3)'; -- {[f@2001-01-01, t@2001-01-02], (f@2001-01-02, f@2001-01-03)} SELECT tcbuffer '[Cbuffer(Point(1 1), 0.2)@2001-01-01, Cbuffer(Point(1 1), 0.8)@2001-01-03)' #<> tcbuffer '[Cbuffer(Point(1 1), 0.3)@2001-01-01, Cbuffer(Point(1 1), 0.7)@2001-01-03)'; -- {[t@2001-01-01, f@2001-01-02], (t@2001-01-02, t@2001-01-03)}
Ever and always equal operators
tcbuffer ?= tcbuffer → boolean
tcbuffer %= tcbuffer → boolean
SELECT tcbuffer '[Cbuffer(Point(1 1), 0.2)@2001-01-01, Cbuffer(Point(1 1), 0.4)@2001-01-04)' ?= Cbuffer(Point(1 1), 0.3); -- true SELECT tcbuffer '[Cbuffer(Point(1 1), 0.2)@2001-01-01, Cbuffer(Point(1 1), 0.2)@2001-01-04)' &= Cbuffer(Point(1 1), 0.2); -- true
Position operators
tcbuffer << tcbuffer → boolean
tcbuffer &< tcbuffer → boolean
tcbuffer >> tcbuffer → boolean
tcbuffer &> tcbuffer → boolean
tcbuffer <<| tcbuffer → boolean
tcbuffer &<| tcbuffer → boolean
tcbuffer |>> tcbuffer → boolean
tcbuffer |&> tcbuffer → boolean
tcbuffer <<# tcbuffer → boolean
tcbuffer &<# tcbuffer → boolean
tcbuffer #>> tcbuffer → boolean
tcbuffer #&> tcbuffer → boolean
SELECT tcbuffer '[Cbuffer(Point(1 1), 0.3)@2001-01-01, Cbuffer(Point(1 1), 0.5)@2001-01-02]' << cbuffer 'Cbuffer(Point(1 1), 0.2)' -- false SELECT tcbuffer '[Cbuffer(Point(1 1), 0.3)@2001-01-01, Cbuffer(Point(1 1), 0.5)@2001-01-02]' <<| stbox(cbuffer 'Cbuffer(Point(1 1), 0.5)') -- false SELECT tcbuffer '[Cbuffer(Point(1 1), 0.3)@2001-01-01, Cbuffer(Point(1 1), 0.5)@2001-01-02]' &> cbuffer 'Cbuffer(Point(1 1), 0.3)'::geometry -- true SELECT tcbuffer '[Cbuffer(Point(1 1), 0.3)@2001-01-01, Cbuffer(Point(1 1), 0.5)@2001-01-02]' >># tcbuffer '[Cbuffer(Point(1 1), 0.3)@2001-01-03, Cbuffer(Point(1 1), 0.5)@2001-01-05]' -- true
Topological operators
tcbuffer && tcbuffer → boolean
tcbuffer <@ tcbuffer → boolean
tcbuffer @> tcbuffer → boolean
tcbuffer ~= tcbuffer → boolean
tcbuffer -|- tcbuffer → boolean
SELECT tcbuffer '[Cbuffer(Point(1 1), 0.3)@2001-01-01, Cbuffer(Point(1 1), 0.5)@2001-01-02]' && cbuffer 'Cbuffer(Point(1 1), 0.5)' -- true SELECT tcbuffer '[Cbuffer(Point(1 1), 0.3)@2001-01-01, Cbuffer(Point(1 1), 0.5)@2001-01-02]' @> stbox(cbuffer 'Cbuffer(Point(1 1), 0.5)') -- true SELECT cbuffer 'Cbuffer(Point(1 1), 0.5)'::geometry <@ tcbuffer '[Cbuffer(Point(1 1), 0.3)@2001-01-01, Cbuffer(Point(1 1), 0.5)@2001-01-02]' -- true SELECT tcbuffer '[Cbuffer(Point(1 1), 0.3)@2001-01-01, Cbuffer(Point(1 1), 0.5)@2001-01-03]' ~= tcbuffer '[Cbuffer(Point(1 1), 0.3)@2001-01-01, Cbuffer(Point(1 1), 0.35)@2001-01-02, Cbuffer(Point(1 1), 0.5)@2001-01-03]' -- true
TODO Return the smallest distance ever between the two arguments
tgeompoint |=| tcbuffer → float
SELECT tcbuffer '[Cbuffer(Point(1 1), 0.3)@2001-01-01, Cbuffer(Point(1 1), 0.5)@2001-01-03]' |=| cbuffer 'Cbuffer(Point(1 1), 0.2)'; -- 2.34988300875063 SELECT tcbuffer '[Cbuffer(Point(1 1), 0.3)@2001-01-01, Cbuffer(Point(1 1), 0.5)@2001-01-03]' |=| geometry 'Linestring(2 2,2 1,3 1)'; -- 82.2059262761477
TODO Return the temporal distance
tgeompoint <-> tcbuffer → tfloat
SELECT tcbuffer '[Cbuffer(Point(1 1), 0.3)@2001-01-01, Cbuffer(Point(1 1), 0.5)@2001-01-03]' <-> cbuffer 'Cbuffer(Point(1 1), 0.2)'; -- [2.34988300875063@2001-01-02 00:00:00+01, 2.34988300875063@2001-01-03 00:00:00+01] SELECT tcbuffer '[Cbuffer(Point(1 1), 0.3)@2001-01-01, Cbuffer(Point(1 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 tcbuffer '[Cbuffer(Point(1 1), 0.3)@2001-01-01, Cbuffer(Point(1 1), 0.5)@2001-01-03]' <-> tcbuffer '[Cbuffer(Point(1 1), 0.3)@2001-01-02, Cbuffer(Point(1 1), 0.5)@2001-01-04]' -- [2.34988300875063@2001-01-02 00:00:00+01, 2.34988300875063@2001-01-03 00:00:00+01]
TODO Ever and always spatial relationships
eContains(geometry,tcbuffer) → boolean
aContains(geometry,tcbuffer) → boolean
eDisjoint({geometry,cbuffer,tcbuffer},{geometry,cbuffer,tcbuffer}) → boolean
aDisjoint({geometry,cbuffer,tcbuffer},{geometry,cbuffer,tcbuffer}) → boolean
eIntersects({geometry,cbuffer,tcbuffer},{geometry,cbuffer,tcbuffer}) → boolean
aIntersects({geometry,cbuffer,tcbuffer},{geometry,cbuffer,tcbuffer}) → boolean
eTouches({geometry,cbuffer,tcbuffer},{geometry,cbuffer,tcbuffer}) → boolean
aTouches({geometry,cbuffer,tcbuffer},{geometry,cbuffer,tcbuffer}) → boolean
eDwithin({geometry,cbuffer,tcbuffer},{geometry,cbuffer,tcbuffer},float) → boolean
aDwithin({geometry,cbuffer,tcbuffer},{geometry,cbuffer,tcbuffer},float) → boolean
SELECT eContains(geometry 'Polygon((0 0,0 50,50 50,50 0,0 0))', tcbuffer '[Cbuffer(Point(1 1), 0.1)@2001-01-01, Cbuffer(Point(1 1), 0.3)@2001-01-03)'); -- false SELECT eDisjoint(cbuffer 'Cbuffer(Point(2 2), 0.0)', tcbuffer '[Cbuffer(Point(1 1), 0.1)@2001-01-01, Cbuffer(Point(1 1), 0.3)@2001-01-03)'); -- true SELECT eIntersects(tcbuffer '[Cbuffer(Point(1 1), 0.1)@2001-01-01, Cbuffer(Point(1 1), 0.3)@2001-01-03)', tcbuffer '[Cbuffer(Point(2 2), 0.0)@2001-01-01, Cbuffer(Point(2 2), 1)@2001-01-03)'); -- false
TODO Temporal spatial relationships
tContains(geometry,tcbuffer) → boolean
tDisjoint({geometry,cbuffer,tcbuffer},{geometry,cbuffer,tcbuffer}) → boolean
tIntersects({geometry,cbuffer,tcbuffer},{geometry,cbuffer,tcbuffer}) → boolean
tTouches({geometry,cbuffer,tcbuffer},{geometry,cbuffer,tcbuffer}) → boolean
tDwithin({geometry,cbuffer,tcbuffer},{geometry,cbuffer,tcbuffer},float) → boolean
SELECT tDisjoint(geometry 'Polygon((0 0,0 50,50 50,50 0,0 0))', tcbuffer '[Cbuffer(Point(1 1), 0.1)@2001-01-01, Cbuffer(Point(1 1), 0.3)@2001-01-03)'); -- {[t@2001-01-01 00:00:00+01, t@2001-01-03 00:00:00+01)} SELECT tDwithin(tcbuffer '[Cbuffer(Point(1 1), 0.3)@2001-01-01, Cbuffer(Point(1 1), 0.5)@2001-01-03)', tcbuffer '[Cbuffer(Point(1 1), 0.5)@2001-01-01, Cbuffer(Point(1 1), 0.3)@2001-01-03)', 1); /* {[t@2001-01-01 00:00:00+01, t@2001-01-01 22:35:55.379053+01], (f@2001-01-01 22:35:55.379053+01, t@2001-01-02 01:24:04.620946+01, t@2001-01-03 00:00:00+01)} */