Professional Documents
Culture Documents
Data Science Project Report
Data Science Project Report
In the first, map_graph – the main function here, is called in order to show map on the
figure. Prefabricated Sejong University campus map image was received from
https://www.openstreetmap.org. Obtained image is being read using MATLAB in-built
‘imread’ function, which stores it as MxNx3 array. Next we set the axes so that the
coordinates are displayed correctly on map. This can be done with use of the same
website as above.
GUI figure for this part consists of eight main elements (4 Push buttons, 3 static texts, and
1 axis):
When this figure is launched for the first time, buttons other than ‘Close’ and ‘Show
Central Point’ are disabled so the user cannot accidentally choose wrong option. Pressing
this button allows the user to mark three points on the map, which are the positions of
three people. This is done by using ‘ginputax’ from Pedro Teodoro from mathworks
community (https://www.mathworks.com/matlabcentral/fileexchange/39799-ginput-
funtion-to-be-used-in-guis) . ‘ginputax’ is advanced version of MATLAB standard function
‘ginput’, used to get position from plot. The main advantage of this is the fact that using
this function cursor will not crawl out of map (Figure 2.3.3). Position of these three points
is stored in n1, n2, n3 variables. These points form a triangle together, which is displayed
using MATLAB ‘plot’ function. Along with these lines, center of this triangle will appear on
the map.
Figure 2.3.3 a) Cursor without
‘ginputax’ function; b) cursor
with ‘ginputax’ function
In the next step, ‘Show Central Point’ button is disabled and button ‘Find Nearest
Building’ becomes available. Firstly, we need to load buildings data from predefined file
‘buildings.mat’, which consists of 6 buildings. In the next step, we delete 3 points forming
triangle. NearestBldFinder function is called then and its output is assigned to handles.bld.
After finding nearest building to the central point, name of the building is being written in
the figure and position of building is being displayed (Figure 2.3.4, Figure 2.3.5). ‘Find
nearest building’ button is being disabled, and user can click ‘Show way to the restaurant’
button from this moment.
1페이지
Figure 2.3.5 Name of the nearest building
After showing nearest building, user can finally find way to the restaurant. From
rest_name.mat we load name of the user chosen restaurant. Then, RestaurantRouteReader
function is called in order to find route to the restaurant. When route data is obtained,
‘plot’ function along with ‘pause’ is used in order to show “moving” route from building
to the restaurant. In the end, user can choose whether to return back to restaurant or to
close figure.
DataReader function is used for retrieving GPS data from txt. file. NMEA format for data
was chosen to be GGA (GPGGA or GNGGA). It was also decided to use decimal degree
(DD; ddd.ddddd) coordinate format since it is more understandable for users. Output of
this function is array structure consisting of latitude and longitude coordinates. The
algorithm is as follows: firstly, file is being read and data from first line is stored in the
buffer. Then it checks, whether it is EOF (End of file), or not. Next step is to be sure, that
we read right NMEA format, which is, as stated earlier, XXGGA (where XX may denote
either GN or GP) (Figure 2.3.8). If format is valid, we are ready to scan coordinates
(latitude and longitude). XXGGA gives coordinates only in degrees and decimal
minutes(ddd mm.mmmm), so we need to convert them to decimal degree as well (Figure
2.3.7). When first line is read and stored, steps from second are repeated again until we
reach end of the file. Finally, when data reading is finished, we write all acquired
coordinates to structure called ‘data’.
2페이지
Another important function is CenterFinder. It is utilized to find center of 3 points chosen
by user. It is not exact center, but rather centroid, which can be found using formula (1)
and (2):
p 1lat + p2lat + p 3lat
(1) C lat =
3
Figure 2.3.9 User chooses position of 3 points (red) and CenterFinder function calculates center(centroid) of
final triangle
(3) √
D= {( Clon −Blon ) + ( Clat −Blat )
2 2
}
3페이지
Where D is distance between central point and particular building, C and B are
coordinates of center and building, respectively.
The last function in this part is RestaurantRouteReader, which has a purpose of reading
route from building to the restaurant, chosen by user before. It takes nearest building,
defined using NearestBldFinder function, and name of restaurant as input. It is
implemented using standard ‘switch’ expression. Firstly, nearest building name is checked,
and then, using restaurant name, route to this restaurant is determined (Route is being
read from prepared .txt files). Function returns ‘restaurant’ structure containing
coordinates of path to the restaurant.
4페이지
This part is devoted to plotting route from Dasangwan to the restaurant. After
clicking 안내 button on restaurant menu, map with route from Dasangwan to the
restaurant will be displayed. This is implemented using only PlotRestaurantRoute function.
PlotRestaurantRoute begins from resetting previous axes in order to remove food image
from figure. Then, map data is loaded and map image is plotted on figure. In the next
step, RestaurantRouteReader is called to find way to the restaurant. It takes restaurant
name as an input. Final step is to plot route using MATLAB ‘plot’ function. ‘pause’ is used
as well, so line appears like “moving”.
5페이지
Figure 2.3.4 Part of PlotRestaurantRoute function
6페이지