forked from osm2pgsql-dev/osm2pgsql
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_output_flex.lua
More file actions
133 lines (117 loc) · 3.08 KB
/
Copy pathtest_output_flex.lua
File metadata and controls
133 lines (117 loc) · 3.08 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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
local tables = {}
tables.point = osm2pgsql.define_node_table('osm2pgsql_test_point', {
{ column = 'tags', type = 'hstore' },
{ column = 'geom', type = 'point' },
})
tables.line = osm2pgsql.define_table{
name = 'osm2pgsql_test_line',
ids = { type = 'way', id_column = 'osm_id' },
columns = {
{ column = 'tags', type = 'hstore' },
{ column = 'name', type = 'text' },
{ column = 'geom', type = 'linestring' },
},
cluster = 'auto'
}
tables.polygon = osm2pgsql.define_table{
name = 'osm2pgsql_test_polygon',
ids = { type = 'area', id_column = 'osm_id' },
columns = {
{ column = 'tags', type = 'hstore' },
{ column = 'name', type = 'text' },
{ column = 'geom', type = 'geometry' },
{ column = 'area', type = 'area' },
}
}
tables.route = osm2pgsql.define_table{
name = 'osm2pgsql_test_route',
ids = { type = 'relation', id_column = 'osm_id' },
columns = {
{ column = 'tags', type = 'hstore' },
{ column = 'geom', type = 'multilinestring' },
}
}
function is_polygon(tags)
if tags.aeroway
or tags.amenity
or tags.area
or tags.building
or tags.harbour
or tags.historic
or tags.landuse
or tags.leisure
or tags.man_made
or tags.military
or tags.natural
or tags.office
or tags.place
or tags.power
or tags.public_transport
or tags.shop
or tags.sport
or tags.tourism
or tags.water
or tags.waterway
or tags.wetland
or tags['abandoned:aeroway']
or tags['abandoned:amenity']
or tags['abandoned:building']
or tags['abandoned:landuse']
or tags['abandoned:power']
or tags['area:highway']
then
return true
else
return false
end
end
local delete_keys = {
'odbl',
'created_by',
'source'
}
local clean_tags = osm2pgsql.make_clean_tags_func(delete_keys)
function osm2pgsql.process_node(object)
if clean_tags(object.tags) then
return
end
tables.point:add_row({
tags = object.tags
})
end
function osm2pgsql.process_way(object)
if clean_tags(object.tags) then
return
end
if is_polygon(object.tags) then
tables.polygon:add_row({
tags = object.tags,
name = object.tags.name,
geom = { create = 'area' }
})
else
tables.line:add_row({
tags = object.tags,
name = object.tags.name
})
end
end
function osm2pgsql.process_relation(object)
if clean_tags(object.tags) then
return
end
if object.tags.type == 'multipolygon' or object.tags.type == 'boundary' then
tables.polygon:add_row({
tags = object.tags,
name = object.tags.name,
geom = { create = 'area', split_at = 'multi' }
})
return
end
if object.tags.type == 'route' then
tables.route:add_row({
tags = object.tags,
geom = { create = 'line' }
})
end
end