-
Notifications
You must be signed in to change notification settings - Fork 3.5k
/
Copy pathdebug_example.lua
50 lines (40 loc) · 1.39 KB
/
debug_example.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
--
-- 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()