Research Article

Road Traffic Monitoring System Based on Mobile Devices and Bluetooth Low Energy Beacons

Algorithm 3

Aggregation function.
1Input: Records, window_size
2Output: Aggregates
3create table Aggregates
4with columns time, min_1_1, max_1_1,..., min_m_n, max_m_n
5Times:= Select time from Records
6for each t in Times do
7begin
8for refPos:= 1..m do
9for bID:= 1..n do
10begin
11RSSI_data:= Select RSSI from Records
12where time is between t - window_size and t
13and distance(position, refPos) <= d_max
14and beacon_ID = bID
15min_refPos_bID:= min(RSSI_data)
16max_refPos_bID:= max(RSSI_data)
17end
18Insert t, min_1_1, max_1_1,..., min_m_n, max_m_n into Aggregates
19End