daniel-j-h / libosrmc

Pure C bindings for libosrm
MIT License
18 stars 8 forks source link

Converting output to JSON #22

Closed mster429 closed 3 years ago

mster429 commented 3 years ago

Hi, I am hoping to use this library in one of my go applications. My requirement is to output the JSON formatted response of route, table services. As for my understanding this library doesn't support for this requirement. Can you help me in understanding what are the available options for me in this matter ?

daniel-j-h commented 3 years ago

The distance table library functions allow you to get the distances between all sources and destinations

https://github.com/daniel-j-h/libosrmc/blob/master/libosrmc/osrmc.h#L198

From there you can construct a json response on your own.

This library does not know and should not know about json, it's working on a layer below.

Note: you might want to interact with osrm's http service directly, instead of going through libosrmc -> libosrm. Only use this lib if you know what you are doing and you need e.g. the api/abi stability or the improved performance. Otherwise make http queries against osrm's http server, it's simpler.

Best, Dani ✌️

On May 29, 2021 7:05:44 PM UTC, Mahendra Bandara @.***> wrote:

Hi, I am hoping to use this library in one of my go applications. My requirement is to output the JSON formatted response of route, table services. As for my understanding this library doesn't support for this requirement. Can you help me in understanding what are the available options for me in this matter ?

mster429 commented 3 years ago

Using the http api introduces the additional network overhead and it doesn't meet with my performance requirements. What is your opinion in using new flatbuffer output to construct the json response compared to using the exisitng json variant ? Will using flatbuffers make my task easy ? I am quite new to this domain and your opinion in this would be of great help to me. Thanks.

daniel-j-h commented 3 years ago

The new osrm flatbuffer feature is not supported in this project (yet?) b cause they're breaking the libosrm api

https://github.com/daniel-j-h/libosrmc/pull/17

This project uses the libosrm objects, transforming to a json string is then up to you.

On May 30, 2021 1:39:48 PM UTC, Mahendra Bandara @.***> wrote:

Using the http api introduces the additional network overhead and it doesn't meet with my performance requirements. What is your opinion in using new flatbuffer output to construct the json response compared to using the exisitng json variant ? Will using flatbuffers make my task easy ? I am quite new to this domain and your opinion in this would be of great help to me. Thanks.

mster429 commented 3 years ago

Ok thanks for your help.

mster429 commented 3 years ago

For this task I am using osrm v5.24 and added

params_typed>format.emplace(osrm::engine::api::BaseParameters::OutputFormatType::FLATBUFFERS);

to osrmc_params_add_coordinate function. And I added the changes here #17 to support the new flatbuffers format. (I already added functions to set the geometries to geojson and overview to full) Is there any way that I can parse the output flatbuffers to my go application and decode it there or do I have to do that within osrmc? (My requirement is to output the geojson route response in json format from my go application without using the http api)

daniel-j-h commented 3 years ago

Osrm has added flatbuffers after I left and dropped all involvement with them, so you're on your own there.

I don't see why you'd need flatbuffers either. The libosrmc api as is returns you C types (ints, floats, etc) and concerting those to JSON is up to you.

Best, Dani

On June 4, 2021 4:25:51 PM UTC, Mahendra Bandara @.***> wrote:

For this task I am using osrm v5.24 and added

params_typed->format.emplace(osrm::engine::api::BaseParameters::OutputFormatType::FLATBUFFERS);

to osrmc_params_add_coordinate function. And I added the changes here

17 to support the new flatbuffers format. (I already added functions

to set the geometries to geojson and overview to full) Is there any way that I can parse the output flatbuffers to my go application and decode it there or do I have to do that within osrmc? (My requirement is to output the geojson route response in json format from my go application without using the http api)