Hello, dear friend, you can consult us at any time if you have any questions, add WeChat: THEend8_
Assignment
1 Learning Outcomes
In this assignment you will demonstrate your understanding of loops and if statements by writing a program that
sequentially processes input data. You are also expected to make use of functions and arrays (strings).
2 The Story...
Vehicle trajectories provide insights for improving the transport system, such as understanding people’s commute
patters, identifying traffic congestions, detecting bottlenecks of the road network, etc. Figure 1 below illustrates
trajectories of 50 trucks delivering concrete to several construction sites around Athens, Greece, where each trajectory
is illustrated with a line of a different colour.
Figure 1: Truck trajectories
A truck trajectory is represented by a sequence of location points of the truck reported at different time. Here,
we show an example trajectory that consists of location points reported at a 30-second interval. Every location
point (a line) has five columns, which represent the date (day/month/year), time (hour:minute:second), latitude,
longitude, and unique id (6 characters) of the location point, respectively.
10/9/02 9:15:59 23.845089 38.018470 DXUYHu
10/9/02 9:16:29 23.845179 38.018069 tKoPTx
10/9/02 9:16:59 23.845530 38.018241 JPQbNb
10/9/02 9:17:29 23.845499 38.017440 aEWdXS
10/9/02 9:17:59 23.844780 38.015609 gqeEjx
10/9/02 9:18:29 23.844780 38.014018 aQArkX
10/9/02 9:18:59 23.844869 38.012569 fhQIAS
10/9/02 9:19:29 23.845360 38.011600 BhngfQ
10/9/02 9:19:59 23.845550 38.010650 rgwehm
10/9/02 9:20:29 23.845100 38.010478 jdBgpN
For example, the first line of the sequence represents a location point reported at 9:15:59 on 10/9/02 with a
coordinate of h23.845089, 38.018470i. This data point has a unique id of “DXUYHu”.
1
3 Your Task
In this assignment, your task is to analyse properties such as length and vehicle speed of a trajectory. You will
be given a sequence of location points that represent a trajectory like the one shown above. Particularly, each line
of the sequence contains the information of a location point separated by spaces (‘ ’), including the date (three
integers in the format of day/month/year, between 1/1/02 and 1/9/18), time (three integers in the format of
hour:minute:second, between 0:0:0 and 23:59:59), latitude (a real number with 6 digits after the decimal point),
longitude (a real number with 6 digits after the decimal point), and the unique id (a 6-character string containing
only English letters) of the location point.
You may assume that the sequence will always be correctly formatted and contain at least 2 and at most 99 location
points.