osrm-backend
osrm-backend copied to clipboard
After merging 2 .pbf files, routing only works in the first one's region
I'm using OSRM backend using docker-compose, image version 5.26.
Here is my process to merge the files:
- Downloaded the GCC file and Southern India files from https://download.geofabrik.de/.
- Run
osmium merge gcc-states-latest.osm.pbf southern-zone-latest.osm.pbf -o ./osrm/regions.osm.pbf
(./osrm is mapped to the /data in docker-compose vols)
- Run the following to create the graph using ch algorithm:
docker run -t -v "${PWD}/osrm:/data" osrm/osrm-backend osrm-extract -p /opt/car.lua /data/regions.osm.pbf
docker run -t -v "${PWD}/osrm:/data" osrm/osrm-backend osrm-contract /data/regions.osrm
- Restart the container.
Here is my test script:
def get_route(*locations):
formatted_waypoints = ';'.join([f'{location[1]},{location[0]}' for location in locations])
url = f'{OSRM_URL}/route/v1/car/{formatted_waypoints}'
res = requests.get(url)
res_json = res.json()
res.raise_for_status()
route = res_json['routes'][0]
return route
## INDIA - CHENNAI
locations = [(13.090104, 80.2775051), (13.0868953, 80.278404), (13.0859636, 80.27742940000002), (13.0989185, 80.27912119999999), (13.0917094, 80.2785951), (13.0853048, 80.27913850000002)]
r = get_route(*locations)
print(r)
## GCC
locations = [(23.592288, 58.4220798), (23.5962129, 58.4185424), (23.5954943, 58.4168216), (23.5952863, 58.4194225), (23.5952172, 58.4176552), (23.5952863, 58.4194225), (23.5957209, 58.4196654), (23.5942147, 58.4220484), (23.5898237, 58.4209546), (23.5952145, 58.4176696), (23.5923294, 58.4213253), (23.5908808, 58.4204167)]
r = get_route(*locations)
print(r)
Output:
{'geometry': 'gxufCif`lJ??????????', 'legs': [{'steps': [], 'distance': 0, 'duration': 0, 'summary': '', 'weight': 0}, {'steps': [], 'distance': 0, 'duration': 0, 'summary': '', 'weight': 0}, {'steps': [], 'distance': 0, 'duration': 0, 'summary': '', 'weight': 0}, {'steps': [], 'distance': 0, 'duration': 0, 'summary': '', 'weight': 0}, {'steps': [], 'distance': 0, 'duration': 0, 'summary': '', 'weight': 0}], 'distance': 0, 'duration': 0, 'weight_name': 'routability', 'weight': 0}
{'geometry': 'm{~nCwoqcJyBiA@yB_@?Cm]TwBOc@c@GULKd@p@pC@pc@UL_OAI~GWpBAzEAbBoA@UZjAdLzAKDeE@oFxEA`C}CSe@kFgDc@`AQl@`B|@NCn@yA~BvARd@aC|C@lAqAA@[nAHAy@`C}CSe@_CwA{@~AeB_APm@b@aAEIk@\\j@]I{@~@?@_HrB@?wBh@?z@?AvBtB?NLErINvBz@`BjGhH`BaB~DeBj@i@pGmJqF{CqIyEy@IwDyBeB?Cm]TwBOc@o@CUn@l@pBJjNIbd@O\\sBv@u@t@yArB@lAqAC@YnAHAy@xAsBt@u@`Cy@THdErFtBzBHKqGsH{@uBA{DdBFxAqDh@mAxE~BgA~Bx@d@', 'legs': [{'steps': [], 'distance': 2089.7, 'duration': 239.6, 'summary': '', 'weight': 239.6}, {'steps': [], 'distance': 488.3, 'duration': 57.7, 'summary': '', 'weight': 57.7}, {'steps': [], 'distance': 571.9, 'duration': 79.9, 'summary': '', 'weight': 79.9}, {'steps': [], 'distance': 455.3, 'duration': 67.1, 'summary': '', 'weight': 78.6}, {'steps': [], 'distance': 459.8, 'duration': 74.3, 'summary': '', 'weight': 85.8}, {'steps': [], 'distance': 75.5, 'duration': 45.4, 'summary': '', 'weight': 45.4}, {'steps': [], 'distance': 394.2, 'duration': 65.8, 'summary': '', 'weight': 65.8}, {'steps': [], 'distance': 1303, 'duration': 159.3, 'summary': '', 'weight': 159.3}, {'steps': [], 'distance': 2280.3, 'duration': 249.6, 'summary': '', 'weight': 261.4}, {'steps': [], 'distance': 1111, 'duration': 151.5, 'summary': '', 'weight': 162.7}, {'steps': [], 'distance': 297.5, 'duration': 52.5, 'summary': '', 'weight': 52.5}], 'distance': 9526.5, 'duration': 1242.7, 'weight_name': 'routability', 'weight': 1288.7}
As you can see the GCC route returns expected values but the India one doesn't.
Any help would be appreciated.