Database Reference
In-Depth Information
3.4.1 Loading Data
First, we show how the raw trajectory data from a CSV text file
Traj.csv
can
be imported to a SECONDO database.
6
We assume the text file has the schema
(Id: int, Line: int, Up: bool, Time: instant, PosX: real,
PosY: real)
whichwould correspond to rawdata observed for the
Trains
relation introduced
in Section
3.2
.
let TrainsRaw = [const rel(tuple([Id: int, Line: int, Up: bool,
Time: instant, PosX: real, PosY: real])) value ()]
csvimport['Traj.csv', 0, "", ","]
projectextend[Id, Line, Up, Time; Pos: makepoint(.PosX, .PosY)]
consume;
This creates a relation
TrainsRaw(Id: int, Line: int, Up: bool, Time: instant, Pos: point)
where attribute
Pos
contains the position data as a
point
(easting, northing). In
the following, we briefly investigate two different ways to represent trajectories
more effectively according to the data model of Section
3.2
within SECONDO:
the
compact representation
and the
unit representation
.
3.4.2 Compact Representation
In
TrainsRaw
the information on a vehicle is distributed among many tuples.
Using the model of spatio-temporal data types (Section
3.2
), we now express the
same data in a relation with only a single tuple per vehicle. The data type
mpoint
is used to capture the temporal development of attribute
Pos
. We achieve this
by grouping
TrainsRaw
by
Id
and applying the approximate operator to each
group. Using
Time
as the least significant sorting criterion prior to grouping
guarantees that the positions for each train enter the approximate operator in
increasing temporal order:
let Trains = TrainsRaw feed
sortby[Id, Line, Up, Time]
groupby[Id, Line, Up; Trip: group feed approximate[Time, Pos] ]
consume;
The result is the relation
Trains
with the schema shown earlier. This is what
we call the
compact representation
of moving object data. It is easy to apply
6
It is also possible to import NMEA recordings using an operator mneaimport.