Database Reference
In-Depth Information
We can determine the distance between two moving objects or a moving
object and a static object.
query distance(train7, mehringdamm)
Clearly as
train7
is moving, the distance to
mehringdamm
is time dependent.
Hence the result is a real number varying with time. There is a data type for this
called
moving real
(
mreal
)andthedistance operation has signature
distance:
mpoint
×
point
→
mreal
It would be nice if we could determine when and where the speed of
train7
has been higher than 50 km/h. We can write it as follows.
2
query speed(train7) > 50
Here a time-dependent speed, obviously an
mreal
, is compared to a
real
constant.
The result is a time-dependent Boolean value, represented in a type
mbool
. Hence
the two operations used have signatures:
speed:
mpoint
→
mreal
<
:
mreal
×
real
→
mbool
We can determine the position of a moving object at any instant of time (it
may be undefined if the
mpoint
function is not defined at that time). We can also
reduce it to a given time interval (or set of time intervals).
let six30 = theInstant(2003, 11, 20, 6, 30);
let kmh = 1000 / 3600;
query val(train7 atinstant six30)
query trajectory(train7 atperiods
deftime( (speed(train7) > (50 * kmh)) at TRUE ) )
Here we define
six30
as 6:30 A.M. on the day when trains are defined. We
also introduce
kmh
as the factor to convert km/h to m/s. The first query then
determines the position of
train7
at 6:30. The second reduces
train7
to the
periods of time when its speed was higher than 50 km/h. The signatures used
are the following.
2
To be honest, one has to be a bit careful with the units used. In the
berlintest
database, geometries
are given in units of meters, hence the speed of
train7
will be returned in m/s rather than km/h
and one needs to apply the appropriate factor to the constant, omitted here for clarity.