Skip to content

Commit f89bec8

Browse files
committed
Add steps for using OSRM to readme
1 parent a8461b6 commit f89bec8

File tree

2 files changed

+46
-8
lines changed

2 files changed

+46
-8
lines changed

examples/README.md

Lines changed: 40 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -86,14 +86,43 @@ This can be changed via the `--output_image` & `--output_map` parameters.
8686
The map plot should look like [this](https://nextmv-io.github.io/nextplot/plots/dortmund-route):
8787
![dortmund-route.json.html.png](https://nextmv-io.github.io/nextplot/plots/dortmund-route/dortmund-route.json.html.png)
8888

89-
## Route plotting with routingkit support
89+
## Route plotting with OSRM support
9090

91-
Next, we're gonna plot routes using the road network. We do this with the
92-
support of [go-routingkit](go-routingkit).
91+
Next, we will plot routes using the road network. We do this with the support of
92+
[OSRM][osrm]. Make sure a server with a suitable region and profile is running.
9393

94-
### Pre-requisites
94+
### Pre-requisites for OSRM
9595

96-
1. Install [go-routingkit](go-routingkit) standalone:
96+
1. Spin up an OSRM server with a suitable region and profile. Follow the
97+
[steps][osrm-install] provided by OSRM to get started.
98+
99+
### Plot route paths via OSRM
100+
101+
The command is similar to the one above, but specifies some extra options (refer
102+
to the full list [below](#additional-information)). The `osrm_host` option
103+
activates OSRM driven plotting.
104+
105+
```bash
106+
nextplot route \
107+
--input_route data/kyoto-route.json \
108+
--jpath_route "vehicles[*].route" \
109+
--jpath_x "position.lon" \
110+
--jpath_y "position.lat" \
111+
--output_map kyoto-route.html \
112+
--output_image kyoto-route.png \
113+
--osrm_host http://localhost:5000
114+
```
115+
116+
## Route plotting with RoutingKit support
117+
118+
Another option to plot routes is to use the [go-routingkit][go-rk] library which
119+
comes with a standalone binary. This approach does not need a running server,
120+
but takes longer to compute the routes (as it needs to preprocess the osm file
121+
on each run).
122+
123+
### Pre-requisites for RoutingKit
124+
125+
1. Install [go-routingkit][go-rk] standalone:
97126

98127
```bash
99128
go install github.com/nextmv-io/go-routingkit/cmd/routingkit@latest
@@ -106,7 +135,7 @@ support of [go-routingkit](go-routingkit).
106135
wget -N http://download.geofabrik.de/asia/japan/kansai-latest.osm.pbf
107136
```
108137

109-
### Plot route paths
138+
### Plot route paths via RoutingKit
110139

111140
The command is similar to the one above, but specifies some extra options (refer
112141
to the full list [below](#additional-information)). The `rk_osm` option
@@ -299,6 +328,9 @@ handle certain data formats. Find an outline of these options here:
299328
- `--stats_file <path-to-file>`:
300329
If provided, statistics will be written to the given file in addition to
301330
stdout.
331+
- `osrm_host` (route only):
332+
Host of the OSRM server to be used for routing. If provided, routes will be
333+
generated via OSRM. Example: `http://localhost:5000`.
302334
- `rk_bin` (route only):
303335
Path to the [go-routingkit][go-rk] standalone binary. Alternatively,
304336
`routingkit` command will be used at default (requires go-routingkit
@@ -315,5 +347,7 @@ handle certain data formats. Find an outline of these options here:
315347
316348
[go-rk]: https://github.com/nextmv-io/go-routingkit/tree/stable/cmd/routingkit
317349
[go-rk-install]: https://github.com/nextmv-io/go-routingkit/tree/stable/cmd/routingkit#install
350+
[osrm]: https://project-osrm.org/
351+
[osrm-install]: https://github.com/Project-OSRM/osrm-backend?tab=readme-ov-file#quick-start
318352
[custom-layers]: http://leaflet-extras.github.io/leaflet-providers/preview/
319353
[folium-tiles]: https://deparkes.co.uk/2016/06/10/folium-map-tiles/

examples/gallery/README.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -121,8 +121,10 @@ suitable region file via:
121121
wget -N http://download.geofabrik.de/north-america/us/texas-latest.osm.pbf
122122
```
123123

124-
This route plot uses routingkit for plotting road paths. Furthermore, unassigned
125-
points are plotted in addition to the route stops.
124+
This route plot uses routingkit for plotting road paths. Alternatively, spin up
125+
a local OSRM server and use the `--osrm_host` flag to use it (see
126+
[osrm-steps][osrm-steps]). Furthermore, unassigned points are plotted in
127+
addition to the route stops.
126128

127129
```bash
128130
nextplot route \
@@ -270,3 +272,5 @@ Interactive result: [link](https://nextmv-io.github.io/nextplot/gallery/fleet-cl
270272
Image result:
271273

272274
![fleet-cloud-comparison.png](https://nextmv-io.github.io/nextplot/gallery/fleet-cloud-comparison/fleet-cloud-comparison.png)
275+
276+
[osrm-steps]: ../README.md#route-plotting-with-osrm-support

0 commit comments

Comments
 (0)