The three aggregate functions for temporal circular buffers are illustrated next.
Temporal count
tCount(tcbuffer) → {tintSeq,tintSeqSet}
WITH Temp(temp) AS (
SELECT tcbuffer '[Cbuffer(Point(1 1), 0.1)@2001-01-01,
Cbuffer(Point(1 1), 0.3)@2001-01-03)' UNION
SELECT tcbuffer '[Cbuffer(Point(1 1), 0.2)@2001-01-02,
Cbuffer(Point(1 1), 0.4)@2001-01-04)' UNION
SELECT tcbuffer '[Cbuffer(Point(1 1), 0.3)@2001-01-03,
Cbuffer(Point(1 1), 0.5)@2001-01-05)' )
SELECT tCount(Temp) FROM Temp;
-- {[1@2001-01-01, 2@2001-01-02, 1@2001-01-04, 1@2001-01-05)}
Window count
wCount(tcbuffer) → {tintSeq,tintSeqSet}
WITH Temp(temp) AS (
SELECT tcbuffer '[Cbuffer(Point(1 1), 0.1)@2001-01-01,
Cbuffer(Point(1 1), 0.3)@2001-01-03)' UNION
SELECT tcbuffer '[Cbuffer(Point(1 1), 0.2)@2001-01-02,
Cbuffer(Point(1 1), 0.4)@2001-01-04)' UNION
SELECT tcbuffer '[Cbuffer(Point(1 1), 0.3)@2001-01-03,
Cbuffer(Point(1 1), 0.5)@2001-01-05)' )
SELECT wCount(Temp, '1 day') FROM Temp;
/* {[1@2001-01-01, 2@2001-01-02, 3@2001-01-03, 2@2001-01-04, 1@2001-01-05,
1@2001-01-06)} */
Aggregate the centres of a set of temporal circular buffers into their temporal centroid, by casting to tgeompoint
tCentroid(tcbuffer::tgeompoint) → tgeompoint
The aggregate belongs to the tgeompoint type: a circular buffer's centre trajectory is a temporal point, so the cast reaches the aggregate rather than the buffer type carrying its own copy of it.
WITH Temp(temp) AS (
SELECT tcbuffer '[Cbuffer(Point(1 1), 0.1)@2001-01-01,
Cbuffer(Point(1 1), 0.3)@2001-01-03)' UNION
SELECT tcbuffer '[Cbuffer(Point(3 3), 0.2)@2001-01-01,
Cbuffer(Point(3 3), 0.4)@2001-01-03)' )
SELECT asText(tCentroid(temp::tgeompoint)) FROM Temp;
-- {[POINT(2 2)@2001-01-01, POINT(2 2)@2001-01-03)}