-
-
Notifications
You must be signed in to change notification settings - Fork 480
Expand file tree
/
Copy pathtest_output_flex_node.lua
More file actions
86 lines (73 loc) · 2.15 KB
/
Copy pathtest_output_flex_node.lua
File metadata and controls
86 lines (73 loc) · 2.15 KB
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
local tables = {}
tables.t1 = osm2pgsql.define_node_table('osm2pgsql_test_t1', {
{ column = 'tags', type = 'hstore' },
{ column = 'geom', type = 'point', not_null = true },
})
tables.t2 = osm2pgsql.define_node_table('osm2pgsql_test_t2', {
{ column = 'tags', type = 'hstore' },
{ column = 'rel_ids', type = 'text' },
{ column = 'geom', type = 'point', not_null = true },
})
tables.tboth = osm2pgsql.define_node_table('osm2pgsql_test_tboth', {
{ column = 'tags', type = 'hstore' },
{ column = 'rel_ids', type = 'text' },
{ column = 'geom', type = 'point', not_null = true },
})
local n2r = {}
local function get_ids(data)
if data then
local ids = {}
for rel_id, _ in pairs(data) do
ids[#ids + 1] = rel_id
end
table.sort(ids)
return '{' .. table.concat(ids, ',') .. '}'
end
end
function osm2pgsql.process_node(object)
if object.tags.t1 then
tables.t1:insert{
tags = object.tags,
geom = object:as_point()
}
end
if osm2pgsql.stage == 2 and object.tags.t2 then
local ids = get_ids(n2r[object.id])
if ids then
tables.t2:insert{
rel_ids = ids,
geom = object:as_point()
}
end
end
if object.tags.tboth then
local ids = get_ids(n2r[object.id])
tables.tboth:insert{
tags = object.tags,
rel_ids = ids,
geom = object:as_point()
}
end
end
local function node_member_ids(relation)
local ids = {}
for _, member in ipairs(relation.members) do
if member.type == 'n' and member.role == 'mark' then
ids[#ids + 1] = member.ref
end
end
return ids
end
function osm2pgsql.select_relation_members(relation)
return { nodes = node_member_ids(relation) }
end
function osm2pgsql.process_relation(object)
for _, member in ipairs(object.members) do
if member.type == 'n' and member.role == 'mark' then
if not n2r[member.ref] then
n2r[member.ref] = {}
end
n2r[member.ref][object.id] = true
end
end
end