[OSRM-talk] Compiling OSRM Code

BATEESH . bateesh at gmail.com
Tue Jul 30 08:40:13 UTC 2019


Hi,

I am trying to compile project which uses osrm libraries and was written in
2017.I installed osrm server on my system yesterday and trying to make the
application run.But while compiling on ubuntu 18.04 i am getting
compilation errors.For eg,for the following code block

long long int OSRM_INTERFACE::viarouteCall(
        vector<pair<float, float> > locations) {

    // The following shows how to use the Route service; configure this service
    osrm::RouteParameters route_parameters;
    // route is in Monaco
    route_parameters.service = "route";//route bateesh made chanfe
from viaroutes to route

    for (unsigned int i = 0; i < locations.size(); i++) {

        route_parameters.AddCoordinate(locations[i].first, locations[i].second);
    }

    osrm::json::Object json_result;
    const int result_code = (*routing_machine).RunQuery(route_parameters,
            json_result);
    //std::cout << "result code: " << result_code << std::endl;

    long long int duration = 0;

    // 2xx code

    if (result_code / 100 == 2) {
        // Extract data out of JSON structure
        auto& summary = json_result.values["route_summary"].get<
                osrm::json::Object>();
        duration = summary.values["total_time"].get<osrm::json::Number>().value;
//      auto distance =
//
summary.values["total_distance"].get<osrm::json::Number>().value;
//      //std::cout << "duration: " << duration << std::endl;
        //std::cout << "distance: " << distance << std::endl;
    }
    //delete osrm;
    return duration;
}

I am getting error during compilation like:-

error: ‘struct osrm::engine::api::RouteParameters’ has no member named
‘service’; did you mean ‘overview’?
  route_parameters.service = "viaroute";
                   ^~~~~~~
                   overview
src/osrm_interface.cpp:47:20: error: ‘struct
osrm::engine::api::RouteParameters’ has no member named
‘AddCoordinate’; did you mean ‘coordinates’?
   route_parameters.AddCoordinate(locations[i].first, locations[i].second);
                    ^~~~~~~~~~~~~
                    coordinates
src/osrm_interface.cpp:51:45: error: ‘class osrm::OSRM’ has no member
named ‘RunQuery’
  const int result_code = (*routing_machine).RunQuery(route_parameters,


It seems to me as some API has changed and my machine is using new
APIs and the code is built on old API.Can you tell me how can I see
which parameters changes if i am correct?How do I make changes in the
current code to use member names of new API?


Thanks and Regards,

Bateesh
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openstreetmap.org/pipermail/osrm-talk/attachments/20190730/5b6d6d24/attachment.html>


More information about the OSRM-talk mailing list