Project-OSRM / osrm-backend

Open Source Routing Machine - C++ backend
http://map.project-osrm.org
BSD 2-Clause "Simplified" License
6.42k stars 3.4k forks source link

how to run it as a c++ library libosrm? #5597

Closed bsnyh closed 3 months ago

bsnyh commented 5 years ago

Hi. I really like this software and I'd like to know more about it. More specifically, I'd like to know how to run it as a c++ library libosrm and eventually, I might consider integrate it with julia. Now, here is what I have done so far. Firstly, I followed this link to build it in my ubuntu workstation. https://github.com/Project-OSRM/osrm-backend/wiki/Building-on-Ubuntu Then, I followed this link https://lists.openstreetmap.org/pipermail/osrm-talk/2016-October/001366.html to try to run it as libosrm using data myMapData.osm.pbf, which is downloaded from the internet. After trying the following command, many files are created in the desktop,

~$ osrm-contract /home/Desktop/myMapData.osrm

Many different files have been created in the desktop. For example, myMapData.osrm.properties, myMapData.osrm.names, myMapData.osrm.nbg_nodes, myMapData.osrm.cnbg, myMapData.osrm.turn_penalties_index, myMapData.osrm.cnbg_to_ebg, myMapData.osrm.turn_weight_penalties, myMapData.osrm.turn_duration_penalties, myMapData.osrm.restrictions, myMapData.osrm.maneuver_overrides, myMapData.osrm.icd, myMapData.osrm.tls, myMapData.osrm.tld, myMapData.osrm.geometry, myMapData.osrm.enw, myMapData.osrm.edges, myMapData.osrm.fileIndex, myMapData.osrm.ramIndex, myMapData.osrm.ebg_nodes, myMapData.osrm.datasource_names, myMapData.osrm.hsgr

I was a bit confused and need more comments or references. Any reply is greatly appreciated.

SegfaultCreator commented 5 years ago

Did you use the osrm-extract method before osrm-contract, as suggested in the example.cpp?

 // We support two routing speed up techniques:
    // - Contraction Hierarchies (CH): requires extract+contract pre-processing
    // - Multi-Level Dijkstra (MLD): requires extract+partition+customize pre-processing
config.algorithm = EngineConfig::Algorithm::CH;

you can then request routes using osrm-routed in terminal with "myMapData.orsm" as a program argument

bsnyh commented 5 years ago

@SegfaultCreator, I tried the command "osrm-routed" as the following: $ osrm-routed /home/Desktop/myMapData.osm

[info] starting up engines, v5.22.0 [info] Threads: 12 [info] IP address: 0.0.0.0 [info] IP port: 5000 [info] http 1.1 compression handled by zlib version 1.2.11 [info] Listening on: 0.0.0.0:5000 [info] running and waiting for requests

SegfaultCreator commented 5 years ago

@bsnyh The server is now running. You have to use another terminal to start your requests, e.g.:

curl "http://127.0.0.1:5000/nearest/v1/driving/7.42191,43.7331?number=1"

(Returns the closest road to a given position)

bsnyh commented 5 years ago

@SegfaultCreator, thank you very much. How to use another terminal to start the requests? Moreover, I'd like to use it as a c++ library in a new framework written in Python or Julia, more than likely without the server support. Do you happen to have any suggestions?

bsnyh commented 5 years ago

@bsnyh The server is now running. You have to use another terminal to start your requests, e.g.:

curl "http://127.0.0.1:5000/nearest/v1/driving/7.42191,43.7331?number=1"

(Returns the closest road to a given position)

Could you kindly explain more about the parameters of the url link?

danpat commented 5 years ago

@bsnyh You should read the API documentation which is available here:

http://project-osrm.org/docs/v5.22.0/api/

It describes how to construct URLs to make queries against a running OSRM server.

bsnyh commented 5 years ago

@danpat, thank you for your quick reply. is it possible to get it running as a c++ library, without internet connection? Moreover, I'd like to import it in a python or julia framework, do you have any suggestions about that?

github-actions[bot] commented 4 months ago

This issue seems to be stale. It will be closed in 30 days if no further activity occurs.