-
Notifications
You must be signed in to change notification settings - Fork 0
/
residential_and_buildings.lua
87 lines (78 loc) · 3.11 KB
/
residential_and_buildings.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
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
local tables = {}
tables.landuse = osm2pgsql.define_area_table('landuse', {
{ column = 'landuse', type = 'text' },
{ column = 'geom', type = 'geometry' },
})
tables.building = osm2pgsql.define_area_table('building', {
{ column = 'building', type = 'text' },
{ column = 'geom', type = 'geometry' },
})
tables.administrative = osm2pgsql.define_area_table('administrative', {
{ column = 'name', type = 'text' },
{ column = 'admin_level', type = 'text' },
{ column = 'geom', type = 'geometry' },
})
tables.highway = osm2pgsql.define_way_table('highway', {
{ column = 'highway', type = 'text' },
{ column = 'geom', type = 'linestring' },
})
tables.unwanted = osm2pgsql.define_area_table('unwanted', {
{ column = 'kind', type = 'text' },
{ column = 'geom', type = 'geometry' },
})
function building_type(object)
building_value = object.tags.building or object.tags['building:part'] or
object.tags['abandoned:building'] or object.tags['demolished:building'] or
object.tags['removed:building'] or object.tags['razed:building']
if object.tags.man_made then
man_made = object.tags.man_made
if man_made == 'bunker_silo' or man_made == 'storage_tank' or
man_made == 'wastewater_plant' then
building_value = man_made
end
end
return building_value
end
function osm2pgsql.process_way(object)
if object.tags.landuse then
row = { geom = { create = 'area' }, landuse = object.tags.landuse }
tables.landuse:add_row(row)
end
building_value = building_type(object)
if building_value then
row = { geom = { create = 'area' }, building = building_value }
tables.building:add_row(row)
end
if object.tags.highway then
tables.highway:add_row{ highway = object.tags.highway }
end
if object.tags.leisure or object.tags.amenity or object.tags.natural then
kind = object.tags.leisure or object.tags.amenity or object.tags.natural
row = { geom = { create = 'area' }, kind = kind }
tables.unwanted:add_row(row)
end
end
function osm2pgsql.process_relation(object)
if object.tags.type == 'multipolygon' and object.tags.landuse then
row = { geom = { create = 'area' }, landuse = object.tags.landuse }
tables.landuse:add_row(row)
end
building_value = building_type(object)
if object.tags.type == 'multipolygon' and building_value then
row = { geom = { create = 'area' }, building = building_value }
tables.building:add_row(row)
end
if object.tags.type == 'boundary' and object.tags.boundary == 'administrative' then
row = {
geom = { create = 'area' },
name = object.tags.name,
admin_level = object.tags.admin_level
}
tables.administrative:add_row(row)
end
if object.tags.type == 'multipolygon' and (object.tags.leisure or object.tags.amenity or object.tags.natural) then
kind = object.tags.leisure or object.tags.amenity or object.tags.natural
row = { geom = { create = 'area' }, kind = kind }
tables.unwanted:add_row(row)
end
end