Skip to content

Commit

Permalink
Updates to OSM project.
Browse files Browse the repository at this point in the history
  • Loading branch information
swwelch committed Jul 21, 2019
1 parent 0d7c4f0 commit 3bf4b8e
Show file tree
Hide file tree
Showing 37 changed files with 323 additions and 1,143 deletions.
49 changes: 30 additions & 19 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,39 +1,50 @@
cmake_minimum_required(VERSION 3.11.3)

if(NOT TESTING)
set(TESTING "notest")
endif()

message("TESTING = ${TESTING}")

set(CMAKE_CXX_STANDARD 17)
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/cmake)

# Use the CMakeLists.txt's parent-directory-name for the project's id/name
get_filename_component(PROJECT_ID ${CMAKE_CURRENT_SOURCE_DIR} NAME)
string(REPLACE " " "_" PROJECT_ID ${PROJECT_ID})
project(${PROJECT_ID})
project(OSM_A_star_search)

#
# Project Output Paths
#
set(MAINFOLDER ${PROJECT_SOURCE_DIR})
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${MAINFOLDER}/bin")
set(LIBRARY_OUTPUT_PATH "${MAINFOLDER}/lib")

#
# Locate Project Prerequisites
#
find_package(io2d REQUIRED)
find_package(Cairo)
find_package(GraphicsMagick)

#
# Add Build Targets
#
set(IO2D_WITHOUT_SAMPLES 1)
set(IO2D_WITHOUT_TESTS 1)
add_subdirectory(src)
add_subdirectory(test)
add_subdirectory(thirdparty/pugixml)
add_subdirectory(thirdparty/googletest)

# Find all executables
file(GLOB project_SRCS src/*.cpp src/*.h)

# Add project executable
add_executable(OSM_A_star_search ${project_SRCS})

target_link_libraries(OSM_A_star_search
PRIVATE io2d::io2d
PUBLIC pugixml
)

if( ${CMAKE_SYSTEM_NAME} MATCHES "Linux" )
target_link_libraries(OSM_A_star_search PUBLIC pthread)
endif()

if(MSVC)
target_compile_options(OSM_A_star_search PUBLIC /D_SILENCE_CXX17_ALLOCATOR_VOID_DEPRECATION_WARNING /wd4459)
endif()

# Create a library for unit tests
add_library(route_planner OBJECT src/route_planner.cpp src/model.cpp src/route_model.cpp)
target_include_directories(route_planner PRIVATE thirdparty/pugixml/src)

# Add testing executable
add_executable(test test/utest_rp_a_star_search.cpp)
target_link_libraries(test gtest_main route_planner pugixml)
add_test(NAME test COMMAND test)
unset(TESTING CACHE)
51 changes: 27 additions & 24 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# Route Planning Project Starter Code
# Route Planning Project

This is the starter code for the Route Planning project. Instructions for each exercise can be found in the `instructions` directory, and unit tests for some exercises in the `test` directory.
This repo contains the starter code for the Route Planning project.

<img src="map.png" width="600" height="450" />

## Cloning

Expand All @@ -13,6 +15,21 @@ or with SSH:
git clone [email protected]:udacity/CppND-Route-Planning-Project.git --recurse-submodules
```

## Dependencies for Running Locally
* cmake >= 3.11.3
* All OSes: [click here for installation instructions](https://cmake.org/install/)
* make >= 4.1 (Linux, Mac), 3.81 (Windows)
* Linux: make is installed by default on most Linux distros
* Mac: [install Xcode command line tools to get make](https://developer.apple.com/xcode/features/)
* Windows: [Click here for installation instructions](http://gnuwin32.sourceforge.net/packages/make.htm)
* gcc/g++ >= 7.4.0
* Linux: gcc / g++ is installed by default on most Linux distros
* Mac: same instructions as make - [install Xcode command line tools](https://developer.apple.com/xcode/features/)
* Windows: recommend using [MinGW](http://www.mingw.org/)
* IO2D
* Installation instructions for all operating systems can be found [here](https://github.com/cpp-io2d/P0267_RefImpl/blob/master/BUILDING.md)
* This library must be built in a place where CMake `find_package` will be able to find it

## Compiling and Running

### Compiling
Expand All @@ -26,33 +43,19 @@ cmake ..
make
```
### Running
The executables will be placed in the `bin` directory. From within `build`, you can run the project as follows:
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:
```
../bin/<name-of-parent-directory> -f ../map.osm
./OSM_A_star_search -f ../<your_osm_file.osm>
```

## Testing

For exercises that have unit tests, the project must be built with the approprate test cpp file. This can be done by passing a string with the `-DTESTING` flag in `cmake`. For example, from the build directory:
The testing executable is also placed in the `build` directory. From within `build`, you can run the unit tests as follows:
```
cmake -DTESTING="RouteModel" ..
make
```
Those commands will build the code with the tests for the "Fill Out Route Model" exercise. The tests can then be run from the `build` directory as follows:
./test
```
../bin/test
```
Exercises with tests will specify which string to pass with `-DTESTING`, but a table is given below with the complete list for reference:

| Exercise Name | `-DTESTING` String Value |
|-----------------------------|:------------------------:|
| Fill Out Route Model | "RouteModel" |
| Fill Out Node Class | "RMNodeClass" |
| Create RouteModel Nodes | "RMSNodes" |
| Write the Distance Function | "NodeDist" |
| Create Road to Node Hashmap | "NodeToRoad" |
| Write FindNeighbors | "FindNeighbors" |
| Find the Closest Node | "FindClosest" |
| Write the A\* Search Stub | "AStarStub" |
| Finish A\* Search | "AStarSearch" |

1 change: 0 additions & 1 deletion instructions/add_user_input.md

This file was deleted.

23 changes: 0 additions & 23 deletions instructions/complete_AStarSearch.md

This file was deleted.

6 changes: 0 additions & 6 deletions instructions/create_RouteModel_Nodes.md

This file was deleted.

9 changes: 0 additions & 9 deletions instructions/fill_RoutePlanner_constructor.md

This file was deleted.

22 changes: 0 additions & 22 deletions instructions/fill_out_Node_class.md

This file was deleted.

11 changes: 0 additions & 11 deletions instructions/fill_out_RouteModel_class.md

This file was deleted.

13 changes: 0 additions & 13 deletions instructions/fill_out_RoutePlanner_header.md

This file was deleted.

16 changes: 0 additions & 16 deletions instructions/write_AStarSearch_stub.md

This file was deleted.

16 changes: 0 additions & 16 deletions instructions/write_AddNeighbors.md

This file was deleted.

8 changes: 0 additions & 8 deletions instructions/write_CalculateHValue.md

This file was deleted.

15 changes: 0 additions & 15 deletions instructions/write_ConstructFinalPath.md

This file was deleted.

Loading

0 comments on commit 3bf4b8e

Please sign in to comment.