Davidnet / osm-route-planner

Open Street Maps Route Planner using A* Algorithm implemented in C++

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Route Planning Project

This repo contains the code for a route planner that is able to generate a route between two points from Open Street Maps data. The algorithm used for route planning is A* search.

Install

Dependencies

  • cmake >= 3.11.3
  • make >= 4.1 (Linux, Mac), 3.81 (Windows)
  • gcc/g++ >= 7.4.0
  • IO2D
    • For linux:

      git clone --recurse-submodules https://github.com/cpp-io2d/P0267_RefImpl
      cd P0267_RefImpl
      mkdir Debug
      cd Debug
      cmake --config Debug "-DCMAKE_BUILD_TYPE=Debug" ..
      cmake --build .
      make install # Optional: If you want to be able to include this
                   # in your project from anywhere

      In case cmake--build . fails when compailing the SVG sample (at 66%), update the svgpp repository inside P0267 to its current version. (This happened to me in Ubuntu 20.04)

      # Run only if cmake--build .* fails
      cd P0267_RefImpl/P0267_RefImpl/Samples/svg/external/svgpp
      git checkout master
      cd ../../../../../Debug/
      cmake --build .
    • Installation instructions for other operating systems can be found here

    • This library must be built in a place where CMake find_package will be able to find it (or installed using make install)

Cloning

When cloning this project, be sure to use the --recurse-submodules flag. Using HTTPS:

git clone https://github.com/jdgalviss/osm-route-planner.git --recurse-submodules

or with SSH:

git clone git@github.com:jdgalviss/osm-route-planner.git --recurse-submodules

Compiling and Running

Compiling

To compile the project, first, create a build directory and change to that directory:

mkdir build && cd build

From within the build directory, then run cmake and make as follows:

cmake ..
make

Running

The executable will be placed in the build directory. From within build, you can run the project as follows:

./OSM_A_star_search

Or to specify a map file:

./OSM_A_star_search -f ../<your_osm_file.osm>

Once you run it, the program will ask you to enter the x and y coordinates of the start and goal points. (this are giving as a percentage of the map height and width). For instance:

./OSM_A_star_search

To specify a map file use the following format: 
Usage: [executable] [-f filename.osm]
Reading OpenStreetMap data from the following file: ../map.osm
Enter the START x-coordinate: 40
Enter the START y-coordinate: 40
Enter the END x-coordinate: 10
Enter the END y-coordinate: 90

Gives the following result:

Testing

The testing executable is also placed in the build directory. From within build, you can run the unit tests as follows:

./test

About

Open Street Maps Route Planner using A* Algorithm implemented in C++

License:Apache License 2.0


Languages

Language:C++ 80.2%Language:CMake 19.8%