Project-OSRM / osrm-backend

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

Edit Json output #7071

Open Cactustory opened 2 days ago

Cactustory commented 2 days ago

Hello I need to add way_id to json output. I edited car.lua to have way_id( result.way_id = way:id()). I dont know if its correct or not. Now how can I add it json output?

function process_way(profile, way, result, relations) -- the intial filtering of ways based on presence of tags -- affects processing times significantly, because all ways -- have to be checked. -- to increase performance, prefetching and intial tag check -- is done in directly instead of via a handler.

-- in general we should try to abort as soon as -- possible if the way is not routable, to avoid doing -- unnecessary work. this implies we should check things that -- commonly forbids access early, and handle edge cases later.

-- data table for storing intermediate values during processing local data = { -- prefetch tags highway = way:get_value_by_key('highway'), bridge = way:get_value_by_key('bridge'), route = way:get_value_by_key('route') } result.way_id = way:id()

-- perform an quick initial check and abort if the way is -- obviously not routable. -- highway or route tags must be in data table, bridge is optional if (not data.highway or data.highway == '') and (not data.route or data.route == '') then return end

jcoupey commented 1 day ago

The "usual" workaround for this is to embed the way id in the name in order to be able to get it back in output, see https://github.com/Project-OSRM/osrm-backend/issues/5707#issuecomment-609910157.

Also related #5325.