AGENT.md
OSRM (Open Source Routing Machine) is a high performance routing engine written in C++ designed to run on OpenStreetMap data. It provides various routing services including route finding, distance/duration tables, GPS trace matching, and traveling salesman problem solving. It is accessible via HTTP API, C++ library interface, and Node.js wrapper. OSRM supports two routing algorithms: Contraction Hierarchies (CH) and Multi-Level Dijkstra (MLD).
We target C++20 but need to deal with older compilers that only have partial support.
Use ./scripts/format.sh to format the code. Ensure clang-format-15 is available on the system.
Specific practices to follow (see wiki):
using namespace: Always use explicit std:: prefixes, never using namespace std; (especially in headers)UpperCamelCase (e.g. TextFileReader)lower_case_with_underscores, private members start with m_ (e.g. m_node_count)lowerCamelCase verb phrases (e.g. openFile(), isValid())UpperCamelCase (e.g. VK_Argument)// comments, not C style /* */. Use #if 0 / #endif to comment out blocksint/unsigned for 32-bit, or precise-width types like int16_t, int64_tdynamic_cast<> and exceptions (except for IO operations)BOOST_ASSERT to check preconditions and assumptionsThis project uses CMake. The build directory should be build or build-{something} or build/{something}/. For example:
./build./build-gcc-debug./build/gcc-debug./build/gcc./build/clang-debug./build-clang-releaseUse cmake --build ${BUILD_DIR} --target ${TARGET} -j $(nproc --ignore=2) to build a target.
OSRM supports two data preparations: Contraction Hierarchies (CH) and Multi-Level Dijkstra (MLD).
For CH:
./${BUILD_DIR}/osrm-extract -p profiles/car.lua data.osm.pbf./${BUILD_DIR}/osrm-partition data.osrm (optional, improves CH performance due to cache locality of node reordering)./${BUILD_DIR}/osrm-contract data.osrm./${BUILD_DIR}/osrm-routed -a CH data.osrmFor MLD:
./${BUILD_DIR}/osrm-extract -p profiles/car.lua data.osm.pbf./${BUILD_DIR}/osrm-partition data.osrm./${BUILD_DIR}/osrm-customize data.osrm./${BUILD_DIR}/osrm-routed -a MLD data.osrmA dataset can be both MLD and CH if both osrm-contract and osrm-customize are executed:
./${BUILD_DIR}/osrm-extract -p profiles/car.lua data.osm.pbf./${BUILD_DIR}/osrm-partition data.osrm./${BUILD_DIR}/osrm-contract data.osrm./${BUILD_DIR}/osrm-customize data.osrm./${BUILD_DIR}/osrm-routed -a CH data.osrm OR ./${BUILD_DIR}/osrm-routed -a MLD data.osrmUnit tests are contained in unit_tests/ using boost test and can be build with:
cmake --build ${BUILD_DIR} --target tests
This will create various tests in ${BUILD_DIR}/unit_tests/.
Integration tests are contained in features/ using cucumber-js
To run cucumber tests with the full test matrix across different algorithms (CH, MLD) and load methods (mmap, directly, datastore).
npm test
To run cucumber tests for a specific configuration:
npx cucumber-js -p home -p ch -p datastore
npx cucumber-js -p home -p mld -p mmap
Python bindings live under src/python/ using nanobind + scikit-build-core.
src/python/CMakeLists.txt — nanobind module definition, installs everything under osrm/ namespacesrc/python/osrm/ — Python package (__init__.py, __main__.py, .pyi stubs)src/python/src/ — C++ nanobind source files (16 files)src/python/include/python/ — C++ binding headers (.hpp)ENABLE_PYTHON_BINDINGS=ON triggers add_subdirectory(src/python) in root CMakeLists.txtosrm target directly (no FetchContent)#include "python/..." prefix; OSRM headers use engine/... paths (not the osrm/ forwarding headers), except osrm/osrm.hpposrm_ext target (nanobind NB_MAKE_OPAQUE + GCC LTO + -Werror = ODR violation)osrm/bin/, profiles to osrm/share/profiles/; wheel.exclude filters out root CMake install artifacts (lib/, include/, bin/, share/)__main__.py finds executables: osrm/bin/ (wheel) → build/*/ (editable) → PATHosrm_ext.pyi) auto-generated by nanobind_add_stub(); rebuild + commit after C++ changes.pre-commit-config.yaml).github/workflows/release-monthly.yml, .github/workflows/osrm-backend.yml Python steps), update docs/python/development.md in the same changepip install -e ".[dev]" # editable install
cd test/data && make # build test data
python -m osrm datastore test/data/ch/monaco
pytest test/python/
Use the PR template to build the PR description.
Remove irrelevant tasks, but NEVER remove review or submit it checked.
Ensure the description includes which AI tool and model was used, add a robot emoji to the description.