Bring back library example#7430
Conversation
There was a problem hiding this comment.
Pull request overview
Reintroduces and documents OSRM “library usage” examples by adding a C++ libosrm sample, a CMake find-module for libosrm, and refreshing the Node.js example and documentation.
Changes:
- Modernize
example/example.jsto ESM imports and update its Monaco query example. - Add a C++
libosrmrouting example (example/example.cpp) plus a CMakeFindLibOSRM.cmake. - Add new documentation (
docs/libosrm.md) and anexample/README.mddescribing how to build/run the examples.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 10 comments.
Show a summary per file
| File | Description |
|---|---|
| example/example.js | Converts the Node.js example to ESM, updates threadpool sizing and example query URL. |
| example/example.cpp | Adds a standalone C++ libosrm “Route” example using EngineConfig + OSRM::Route. |
| example/cmake/FindLibOSRM.cmake | Introduces a pkg-config-based CMake find-module for locating libosrm. |
| example/README.md | Adds instructions for preparing test data and building/running the examples. |
| docs/libosrm.md | Adds introductory documentation for using OSRM as a C++ library. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| OSRM can be used as a library (libosrm) via C++ instead of using it through the HTTP interface and `osrm-routed`. This allows for fine-tuning OSRM and has much less overhead. Here is a quick introduction into how to use `libosrm` in the upcoming v5 release. | ||
|
|
||
| Take a look at the example code that lives in the [example directory](https://github.com/Project-OSRM/osrm-backend/tree/master/example). Here is all you ever wanted to know about `libosrm`, that is a short description of what the types do and where to find documentation on it: | ||
|
|
There was a problem hiding this comment.
This new page isn’t linked from the VitePress nav/sidebar (see docs/.vitepress/config.js), and there don’t appear to be other docs linking to /libosrm yet. Add it to the docs navigation (or at least link it from docs/index.md) so users can discover it in the rendered documentation site.
| For a general overview of OSRM and its HTTP API, see the [main documentation](./index.md). |
|
Looking good. There is one minor nitpick when compiling the example. A warning gets issues on duplicate linker flags: |
I couldn't see the warning, but I found the duplicate entry in Regarding the linking to the libosrm.md, I'm thinking of only adding it on the sidebar, like in the old docs. |
That makes sense. |
Issue
Adresses #7266. No tests or changelog because it doesn't change the library itself, but I think the wiki may be improved.
Tasklist
Requirements / Relations
N/A