osrm-backend/profiles/debug_example.lua
Thanabodee Charoenpiriyakij 2c13f2f735 Fix profiles/debug_example.lua cannot interprete by lua
After run `lua5.1 profiles/debug_example.lua`, I got result:

```
lua5.1: debug_example.lua:41: attempt to call field 'way_function' (a nil value)
stack traceback:
        debug_example.lua:41: in main chunk
        [C]: ?
```

This is because Debug has not way_function in the module. This changes
change it to process_way and it's works!!
2020-04-09 16:05:37 +07:00

51 lines
1.4 KiB
Lua

--
-- Example of how to use debug.lua to debug profiles in a pure lua environment.
-- It makes it easy to manually set tags, run the way processing and check the result.
--
-- To use, make a copy of this file and gitignore your copy. (If you use the name ndebug.lua,
-- it's already gitignored.)
--
-- You run your copy via the lua command line:
-- > cd profiles
-- > lua5.1 debug.lua
--
-- You can then modify the input tags and rerun the file to check the output.
--
-- TODO: there are a few helper methods that are implemented in C++, which are currently
-- just mocked as empty methods in LUA. Tag processing that uses these helpers will
-- not yet work correctly in this pure LUA debugging environment.
-- for better printing
local pprint = require('lib/pprint')
-- require the debug tool
local Debug = require('lib/profile_debugger')
-- load the profile we want to debug
Debug.load_profile('foot')
-- define some input tags. they would normally by extracted from OSM data,
-- but here we can set them manually which makes debugging the profile eaiser
local way = {
highway = 'primary',
name = 'Magnolia Boulevard',
["access:forward"] = 'no'
}
-- output will go here
local result = {}
-- call the way function
Debug.process_way(way,result)
-- print input and output
pprint(way)
print("=>")
pprint(result)
print("\n")
-- report what tags where fetched, and how many times
Debug.report_tag_fetches()