This repo contains the final project of the 1st Udacity Nanodegree C++ course. The project is an extension of the IO2D map display code that uses A* algorithm to find a path between two points on the map.
- compiler support for C++17 (gcc/g++ >= 5.4).
- cmake >= 3.11
- make >= 4.1 (Linux, Mac), 3.81 (Windows)
- additional libraries
pugixml
andio2d
installed.
git clone https://github.com/Agnieszka1994/OpenStreetMap-Route-Planner
cd OpenStreetMap-Route-Planner/
mkdir build && cd build/
cmake ..
make
./OSM_A_star_search
Testing
./test
Once the program is compiled and run, it asks the user for 4 coordinates ranging from 0 to 99: start x
, start y
, end x
and end y
. Then it calculates the distance between these two points and renders the road from the start
point to the end
on the map. The map in .osm
format must be named map.osm
and placed in the project directory. A sample map is attached to the repo, but you can download your own from the page below.
Usage: [executable] [-f filename.osm]
Reading OpenStreetMap data from the following file: Warsaw_old_town.osm
Enter start x btw. 0 - 99: 20
Enter start y btw. 0 - 99: 20
Enter end x btw. 0 - 99: 60
Enter end y btw. 0 - 99: 70
Program output:
Distance: 1190.83 meters.
Usage: [executable] [-f filename.osm]
Reading OpenStreetMap data from the following file: Warsaw_Praga.osm
Enter start x btw. 0 - 99: 10
Enter start y btw. 0 - 99: 10
Enter end x btw. 0 - 99: 80
Enter end y btw. 0 - 99: 90
Program output:
Distance: 2002.04 meters.
- Main creates a
RoutModel
object with the data - The
RoutModel
class is a data structure that holds all of the OpenStreetMap data in a convinient format and provide some methods for using the data - The
RoutModel
class has a subclass calledNode
, that represents a single point on the map data. - The
RoutModel
provides the methodfind_closest_node
, that finds the closest node in the store data to the coordinates provided by the user. - After Main has created a route model, it will create a
RoutePlanner
object. TheRoutePlanner
class provides all of the methods needed to conduct theA* Search
. - The
RoutePlanner
contains thea_star_search
method, which is called by Main.