PIVOT
gts
The PIVOT
function generates a set of Geo Time Series™ from two lists of input Geo Time Series™.
Geo Time Series™ from the first list will provide datapoints (value, location and elevation), and those from the second list will generate labels.
For each tick of GTS from the first list, the GTS from the second list are inspected. For each value encountered, a label with the GTS class as name and the encountered value is created.
Then for each GTS from the first list with a value at the given tick, the datapoint is copied to a GTS with the same class name and a set of labels equal to those of that GTS merged with the labels created above.
As an example, consider the following input:
Tick | C1 | C2 | C3 | C4 |
0 | A | B | 1 | 10 |
1 | C | | 2 | |
2 | | F | | 30 |
3 | A | B | 4 | 40 |
4 | | | 5 | 50 |
With the first list of GTS being those with classes C3
and C4
and the second list C1
and C2
, the result of the PIVOT
function being applied is:
0// C3{C1=A,C2=B} 1
0// C4{C1=A,C2=B} 10
1// C3{C1=C} 2
2// C4{C2=F} 30
3// C3{C1=A,C2=B} 4
3// C4{C1=A,C2=B} 40
4// C3{} 5
4// C4{} 50
PIVOT is available since version 2.2.0.
See also
Signatures
Examples
// there are three GTS per access control event:
// one stores the event type (in/out), the other stores the car license plate, the third one the gate number
NEWGTS 'event' RENAME
0 NaN NaN NaN 'in' ADDVALUE
1 NaN NaN NaN 'in' ADDVALUE
10 NaN NaN NaN 'in' ADDVALUE
11 NaN NaN NaN 'in' ADDVALUE
13 NaN NaN NaN 'out' ADDVALUE
14 NaN NaN NaN 'out' ADDVALUE
23 NaN NaN NaN 'out' ADDVALUE
24 NaN NaN NaN 'out' ADDVALUE
'events' STORE
NEWGTS 'licensePlate' RENAME
0 NaN NaN NaN 'BK243VV' ADDVALUE
1 NaN NaN NaN 'AA42AA' ADDVALUE
10 NaN NaN NaN 'Z5XX' ADDVALUE
11 NaN NaN NaN '42-42' ADDVALUE
13 NaN NaN NaN 'Z5XX' ADDVALUE
14 NaN NaN NaN 'BK243VV' ADDVALUE
23 NaN NaN NaN '42-42' ADDVALUE
24 NaN NaN NaN 'AA42AA' ADDVALUE
'licensePlate' STORE
NEWGTS 'gateNumber' RENAME
0 NaN NaN NaN 1 ADDVALUE
1 NaN NaN NaN 1 ADDVALUE
10 NaN NaN NaN 2 ADDVALUE
11 NaN NaN NaN 2 ADDVALUE
13 NaN NaN NaN 1 ADDVALUE
14 NaN NaN NaN 1 ADDVALUE
23 NaN NaN NaN 2 ADDVALUE
24 NaN NaN NaN 2 ADDVALUE
'gateNumber' STORE
//create events labelled by licensePlate
[ $events ] [ $licensePlate ] PIVOT
//create events labelled by licensePlate and gateNumber
// [ $events ] [ $gateNumber $licensePlate ] PIVOT
// one gts per stack level, for output readability
LIST-> DROP