example/README.md
This document describes how to build the example programs linked against libosrm.
Every command snippet in this document assumes the starting $PWD as the main project's root level.
Assuming you have Node.js installed:
cd test/data/
make all
cd ../../
example.cppAfter building and installing the main project (on this repo's root level):
cd example/
mkdir build && cd build/
cmake ..
cmake --build .
./osrm-example ../test/data/mld/monaco.osrm
The expected output is the distance and duration of the route set in the example.cpp.
example.jsTo run this module in Node.js you need to install node-cmake in the project's repo root level and pass the flag -DENABLE_NODE_BINDINGS=On when building the main project.
Refer to the sub-section on preparing test data for the application in this document.
Install the required packages after building the main project and serve the application:
npm install
cd example/
node example.js
You can reliably change the thread pool size of the process by setting the UV_THREADPOOL_SIZE variable before calling node:
UV_THREADPOOL_SIZE=16 node example.js
See https://nodejs.org/docs/latest-v18.x/api/os.html#osavailableparallelism for more info.
Then you can test it with:
curl 'http://localhost:8888?start=7.419758,43.731142&end=7.419505,43.736825'