This is a fork of OSRM backend with project specific customizations for the smart transit project. Please refer to OSRM-README.md for details about the OSRM project and the instructions for general compilation.
Follow these instructions for the use of the router with smart transit project.
Make sure you have docker and a tool that will crop OSM data osm cropping tools.
osmconvert
is much faster than osmosis
however osmosis
is cross-platform and I could only get
osmconvert
to work on linux.
To install osmosis with mac: brew install osmosis
.
Download all US south data:
wget http://download.geofabrik.de/north-america/us-south-latest.osm.pbf
Crop the OSM to be a bounding box around the extended Tennessee region.
# if using osmconvert
osmconvert us-south-latest.osm.pbf -b=-90.9733,34.5341,-81.106,37.081 --complete-ways -o=tennessee-latest.osm.pbf
# or using osmosis
osmosis --rb us-south-latest.osm.pbf --bounding-box left=-90.9733 right=-81.106 bottom=34.5341 top=37.081 --wb tennessee-latest.osm.pbf
See the bounding box at http://bboxfinder.com/#34.534100,-90.973300,37.081000,-81.106000
Move tennessee-latest.osm.pbf
to tn/
folder and delete us-south-latest.osm.pdf
.
mkdir tn && mv tennessee-latest.osm.pbf tn/
rm us-south-latest.osm.pbf
docker build . -t t_osrm -f docker/smarttransitDockerfile --build-arg BUILD_CONCURRENCY=20
Run the docker image (the command -m is asking 10g of local memory. see the note below on docker resources)
docker run -m=10g -t -i -p 5000:5000 t_osrm
Test it. Open a browser and visit the following. Note that only TN coordinates will work.
http://127.0.0.1:5000/route/v1/driving/-86.79426670074463,36.12473806954196;-86.7641830444336,36.13808266878191?overview=full&annotations=true&geometries=geojson
Here is the response.
Click to expand the route response
{
"code": "Ok",
"routes": [
{
"geometry": {
"coordinates": [
[
-86.794267,
36.124741
],
[
-86.794257,
36.12474
],
[
-86.794246,
36.124812
],
[
-86.794196,
36.125041
],
[
-86.794111,
36.125424
],
[
-86.794052,
36.125712
],
[
-86.794011,
36.125709
],
[
-86.79329,
36.125635
],
[
-86.792306,
36.125532
],
[
-86.791842,
36.125474
],
[
-86.791779,
36.125466
],
[
-86.791725,
36.12546
],
[
-86.790331,
36.125313
],
[
-86.789576,
36.125232
],
[
-86.789461,
36.125218
],
[
-86.789452,
36.125249
],
[
-86.789411,
36.12541
],
[
-86.789355,
36.125623
],
[
-86.789336,
36.125697
],
[
-86.789313,
36.125799
],
[
-86.78927,
36.126314
],
[
-86.789266,
36.126416
],
[
-86.789218,
36.126806
],
[
-86.789163,
36.127255
],
[
-86.789132,
36.127548
],
[
-86.789124,
36.127612
],
[
-86.789104,
36.127844
],
[
-86.789091,
36.127993
],
[
-86.789035,
36.128621
],
[
-86.789024,
36.12871
],
[
-86.788928,
36.129196
],
[
-86.788881,
36.129657
],
[
-86.788805,
36.130395
],
[
-86.78879,
36.130542
],
[
-86.788763,
36.130802
],
[
-86.788712,
36.131293
],
[
-86.788676,
36.131639
],
[
-86.78866,
36.131795
],
[
-86.788652,
36.131919
],
[
-86.788646,
36.132035
],
[
-86.78865,
36.132262
],
[
-86.788673,
36.13247
],
[
-86.788705,
36.132703
],
[
-86.78872,
36.132807
],
[
-86.788765,
36.133291
],
[
-86.788768,
36.13332
],
[
-86.788825,
36.133861
],
[
-86.788913,
36.134441
],
[
-86.788929,
36.13457
],
[
-86.78896,
36.134875
],
[
-86.788971,
36.134933
],
[
-86.788976,
36.13506
],
[
-86.788974,
36.135191
],
[
-86.788964,
36.135321
],
[
-86.788949,
36.135454
],
[
-86.788899,
36.135631
],
[
-86.788864,
36.13573
],
[
-86.788837,
36.135808
],
[
-86.788755,
36.136033
],
[
-86.788704,
36.136172
],
[
-86.788537,
36.136156
],
[
-86.788325,
36.136134
],
[
-86.787489,
36.136062
],
[
-86.787326,
36.136026
],
[
-86.787174,
36.135991
],
[
-86.787052,
36.135962
],
[
-86.786696,
36.135832
],
[
-86.786142,
36.13545
],
[
-86.786008,
36.135362
],
[
-86.785864,
36.13527
],
[
-86.785587,
36.135092
],
[
-86.78489,
36.13489
],
[
-86.784132,
36.13479
],
[
-86.784028,
36.134777
],
[
-86.783313,
36.134678
],
[
-86.783228,
36.134666
],
[
-86.783166,
36.134658
],
[
-86.782293,
36.134542
],
[
-86.7822,
36.134529
],
[
-86.781627,
36.134445
],
[
-86.780805,
36.134333
],
[
-86.78056,
36.134298
],
[
-86.7799,
36.134235
],
[
-86.779536,
36.134247
],
[
-86.779231,
36.134257
],
[
-86.779132,
36.134255
],
[
-86.77898,
36.134256
],
[
-86.778561,
36.134259
],
[
-86.776629,
36.134274
],
[
-86.776387,
36.134271
],
[
-86.774692,
36.134259
],
[
-86.774553,
36.13425
],
[
-86.77412,
36.134228
],
[
-86.774014,
36.134222
],
[
-86.77334,
36.134156
],
[
-86.773169,
36.134136
],
[
-86.772992,
36.134115
],
[
-86.772902,
36.134104
],
[
-86.772603,
36.134076
],
[
-86.772445,
36.134062
],
[
-86.772358,
36.134048
],
[
-86.772249,
36.134025
],
[
-86.772117,
36.133989
],
[
-86.772041,
36.13396
],
[
-86.771731,
36.133803
],
[
-86.771305,
36.133579
],
[
-86.771087,
36.133523
],
[
-86.770441,
36.133445
],
[
-86.770328,
36.133434
],
[
-86.770061,
36.133407
],
[
-86.76974,
36.133374
],
[
-86.769646,
36.133364
],
[
-86.769257,
36.133325
],
[
-86.768882,
36.133285
],
[
-86.76879,
36.133275
],
[
-86.768078,
36.133203
],
[
-86.76714,
36.133114
],
[
-86.766015,
36.132989
],
[
-86.765899,
36.13298
],
[
-86.765811,
36.132972
],
[
-86.765734,
36.132966
],
[
-86.76526,
36.13292
],
[
-86.764999,
36.132878
],
[
-86.764988,
36.132961
],
[
-86.764958,
36.133251
],
[
-86.764865,
36.133816
],
[
-86.764847,
36.133926
],
[
-86.764798,
36.134227
],
[
-86.764716,
36.134736
],
[
-86.764715,
36.134742
],
[
-86.764566,
36.135663
],
[
-86.764559,
36.135707
],
[
-86.764533,
36.135811
],
[
-86.764394,
36.136566
],
[
-86.764352,
36.136797
],
[
-86.764313,
36.137072
],
[
-86.764231,
36.137578
],
[
-86.764154,
36.13808
]
],
"type": "LineString"
},
"legs": [
{
"annotation": {
"metadata": {
"datasource_names": [
"lua profile"
]
},
"nodes": [
8544339562,
202279759,
4103484420,
4103484053,
202279753,
202279750,
4103484108,
202439183,
202439180,
8544339572,
202285748,
8544339569,
4587814881,
4103484094,
202342884,
4591276250,
6687214715,
8536045501,
6783134408,
4103484096,
6783134409,
202265845,
6973398054,
6372074704,
6783134410,
202342880,
7130572881,
7130622691,
6783134411,
202302869,
202342879,
4605993422,
202218202,
5258711353,
202309943,
5895340458,
6071182363,
202342877,
5264029792,
5264029791,
2473560091,
2473560100,
6071182364,
202247349,
202247358,
6071182365,
4591427231,
202321213,
6783134412,
202342875,
3586115649,
5264029790,
5264029788,
5264029789,
2473560108,
5264029784,
7246786334,
5264029783,
6783134407,
202342873,
6783134405,
3017253406,
202494753,
3017253407,
6998262920,
2473959314,
202494749,
3017253408,
202454223,
4619037844,
2473959312,
202328811,
7033043863,
202494744,
7033108139,
7033938738,
6687319176,
202390238,
7033043848,
7033043850,
202321177,
202494741,
5160106183,
7439622905,
5443701187,
202494739,
5443701189,
2473616035,
202429618,
1763399157,
202233258,
5074388156,
6995742538,
202456261,
202494727,
202494724,
5612710865,
5778519220,
6690634056,
5778519216,
202494722,
5611837270,
5994267674,
5150841926,
202427117,
202494720,
202494718,
202326075,
5627244250,
5617538642,
5617538643,
5627234690,
202391963,
5150841913,
202294330,
202494716,
202279540,
202494712,
6129391413,
5143433671,
5143433659,
6650950813,
202416497,
6129391419,
5150320870,
202416495,
7936241602,
6264878515,
5817898503,
5836087528,
5443702883,
202416492,
202416489,
4604678824,
202303125,
202303099,
202248140,
202340949
],
"datasources": [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
],
"speed": [
9.1,
11.5,
11.2,
11.1,
11.2,
7.4,
6.9,
7,
6.9,
7.2,
7,
6.9,
6.9,
7,
17.7,
15.2,
15.1,
14,
14.4,
15.1,
16.2,
15,
15.2,
15.6,
14.3,
15.2,
15.1,
15.2,
14.2,
15.2,
15.1,
15.3,
14.9,
15.3,
15.2,
15.4,
15.8,
15.3,
16.1,
14.9,
15.5,
15.3,
14.6,
15.4,
16.2,
15.1,
15.1,
16,
15.5,
16.3,
15.7,
14.6,
16.1,
14.9,
15.5,
16.4,
15,
15.3,
14.7,
15.1,
14.8,
15.4,
15.2,
15.8,
16.3,
15.3,
15.2,
15.5,
15,
15.1,
15.1,
15.3,
15.8,
15.2,
15.5,
14.1,
15.3,
14.1,
15.4,
15.3,
14.9,
15.3,
15.6,
15.2,
14.8,
15.2,
15.1,
15.2,
15.5,
15.2,
15.7,
15,
15.9,
15.2,
15.5,
14.6,
16.4,
15,
15.9,
15.9,
14.5,
15.6,
15.1,
14.9,
15.2,
15.8,
15.4,
14.6,
15.1,
15.3,
14.2,
15.3,
15.4,
16.7,
15.3,
15.2,
15.2,
15,
15.9,
13.9,
15.3,
14.9,
11.6,
11.2,
11.1,
11.2,
11.3,
11.2,
6.7,
11.1,
12.3,
10.7,
11.2,
11.3,
11,
11.1,
11.3
],
"weight": [
0.1,
0.7,
2.3,
3.9,
2.9,
0.5,
9.4,
12.8,
6.1,
0.8,
0.7,
18.2,
9.9,
1.5,
0.2,
1.2,
1.6,
0.6,
0.8,
3.8,
0.7,
2.9,
3.3,
2.1,
0.5,
1.7,
1.1,
4.6,
0.7,
3.6,
3.4,
5.4,
1.1,
1.9,
3.6,
2.5,
1.1,
0.9,
0.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,
4.2,
5.6,
6.7,
0.7,
0.5,
0.5,
2.8,
1.6,
0.8,
2.9,
5.7,
1.1,
3,
5.1,
0.1,
9.3,
0.4,
1.1,
7.6,
2.3,
2.8,
5.1,
5
],
"distance": [
0.905273,
8.069041,
25.863902,
43.278723,
32.468762,
3.698536,
65.295728,
89.142238,
42.182233,
5.729474,
4.897078,
126.300691,
68.425517,
10.448387,
3.541552,
18.282346,
24.219511,
8.405886,
11.531722,
57.411663,
11.350773,
43.592075,
50.184452,
32.708088,
7.154673,
25.86698,
16.613819,
70.031055,
9.948343,
54.739638,
51.448874,
82.368461,
16.405701,
29.020379,
54.803955,
38.619945,
17.410733,
13.810772,
12.913504,
25.250927,
23.227149,
26.074672,
11.645754,
53.985092,
3.236801,
60.390892,
64.993788,
14.420001,
34.038125,
6.526363,
14.132879,
14.571753,
14.487295,
14.854337,
20.192902,
11.451455,
9.008295,
26.087425,
16.124935,
15.106524,
19.20018,
75.522353,
15.179677,
14.198055,
11.423913,
35.096028,
65.435821,
15.514361,
16.493505,
31.798173,
66.520462,
68.99349,
9.453547,
65.16551,
7.751333,
5.640097,
79.475985,
8.478417,
52.313811,
74.88401,
22.350106,
59.700798,
32.725548,
27.42088,
8.896004,
13.654693,
37.640469,
173.560575,
21.741544,
152.268577,
12.526506,
38.97352,
9.545397,
60.989233,
15.52128,
16.070678,
8.176816,
27.039335,
14.278422,
7.968896,
10.120225,
12.515489,
7.550772,
32.869873,
45.663857,
20.549922,
58.676013,
10.224423,
24.172282,
29.068582,
8.517104,
35.212689,
33.979381,
8.339021,
64.459564,
84.841697,
102.012773,
10.468481,
7.955136,
6.949183,
42.886672,
23.907028,
9.284517,
32.368013,
63.395738,
12.341279,
33.767236,
57.091377,
0.673376,
103.310127,
4.934188,
11.80096,
84.899046,
25.968792,
30.7872,
56.760469,
56.262371
]
},
"steps": [],
"distance": 4533.1,
"duration": 373.3,
"summary": "",
"weight": 373.3
}
],
"distance": 4533.1,
"duration": 373.3,
"weight_name": "routability",
"weight": 373.3
}
],
"waypoints": [
{
"hint": "gA8DgCYPA4ABAAAADgAAAAAAAABRAAAAJTRoP2OjFUEAAAAATKhiQgEAAAAOAAAAAAAAAFEAAADTAAAA5Z_T-kU4JwLln9P6QjgnAgAAXxEOjx5Q",
"distance": 0.332876,
"name": "Sweetbriar Avenue",
"location": [
-86.794267,
36.124741
]
},
{
"hint": "QAcDgDh1JYAyAAAABgAAAAAAAAAAAAAA_oVgQnOXvUAAAAAAAAAAADIAAAAGAAAAAAAAAAAAAADTAAAAhhXU-mBsJwJpFdT6Y2wnAgAAfwAOjx5Q",
"distance": 2.631813,
"name": "Rains Avenue",
"location": [
-86.764154,
36.13808
]
}
]
}
Here is an example of the table (travel time and distance matrix)
http://127.0.0.1:5000/table/v1/driving/-86.79426670074463,36.12473806954196;-86.7641830444336,36.13808266878191
Click to expand the table (travel time) response
{
"code": "Ok",
"durations": [
[
0,
373.3
],
[
369.7,
0
]
],
"destinations": [
{
"hint": "gA8DgCYPA4ABAAAADgAAAAAAAABRAAAAJTRoP2OjFUEAAAAATKhiQgEAAAAOAAAAAAAAAFEAAADTAAAA5Z_T-kU4JwLln9P6QjgnAgAAXxEOjx5Q",
"distance": 0.332876,
"name": "Sweetbriar Avenue",
"location": [
-86.794267,
36.124741
]
},
{
"hint": "QAcDgDh1JYAyAAAABgAAAAAAAAAAAAAA_oVgQnOXvUAAAAAAAAAAADIAAAAGAAAAAAAAAAAAAADTAAAAhhXU-mBsJwJpFdT6Y2wnAgAAfwAOjx5Q",
"distance": 2.631813,
"name": "Rains Avenue",
"location": [
-86.764154,
36.13808
]
}
],
"sources": [
{
"hint": "gA8DgCYPA4ABAAAADgAAAAAAAABRAAAAJTRoP2OjFUEAAAAATKhiQgEAAAAOAAAAAAAAAFEAAADTAAAA5Z_T-kU4JwLln9P6QjgnAgAAXxEOjx5Q",
"distance": 0.332876,
"name": "Sweetbriar Avenue",
"location": [
-86.794267,
36.124741
]
},
{
"hint": "QAcDgDh1JYAyAAAABgAAAAAAAAAAAAAA_oVgQnOXvUAAAAAAAAAAADIAAAAGAAAAAAAAAAAAAADTAAAAhhXU-mBsJwJpFdT6Y2wnAgAAfwAOjx5Q",
"distance": 2.631813,
"name": "Rains Avenue",
"location": [
-86.764154,
36.13808
]
}
]
}
Note - read about docker resource management. you have to enable resources in the docker system setting. by default the docker containers are limited to around 2 GB memory and a few system cores. You should change it if you want good performance.