Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Edit Json output #7071

Open
Cactustory opened this issue Nov 19, 2024 · 1 comment
Open

Edit Json output #7071

Cactustory opened this issue Nov 19, 2024 · 1 comment
Labels

Comments

@Cactustory
Copy link

Cactustory commented Nov 19, 2024

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
Copy link

jcoupey commented Nov 20, 2024

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 #5707 (comment).

Also related #5325.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants