forked from osm2pgsql-dev/osm2pgsql
-
Notifications
You must be signed in to change notification settings - Fork 1
/
style.lua
178 lines (143 loc) · 5.34 KB
/
style.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
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
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
polygon_keys = { 'building', 'landuse', 'amenity', 'harbour', 'historic', 'leisure',
'man_made', 'military', 'natural', 'office', 'place', 'power',
'public_transport', 'shop', 'sport', 'tourism', 'waterway',
'wetland', 'water', 'aeroway' }
generic_keys = {'access','addr:housename','addr:housenumber','addr:interpolation','admin_level','aerialway','aeroway','amenity','area','barrier',
'bicycle','brand','bridge','boundary','building','capital','construction','covered','culvert','cutting','denomination','disused','ele',
'embarkment','foot','generation:source','harbour','highway','historic','hours','intermittent','junction','landuse','layer','leisure','lock',
'man_made','military','motor_car','name','natural','office','oneway','operator','place','poi','population','power','power_source','public_transport',
'railway','ref','religion','route','service','shop','sport','surface','toll','tourism','tower:type', 'tracktype','tunnel','water','waterway',
'wetland','width','wood','type'}
function add_z_order(keyvalues)
z_order = 0
if (keyvalues["layer"] ~= nil and tonumber(keyvalues["layer"])) then
z_order = 10*keyvalues["layer"]
end
zordering_tags = {{ 'railway', nil, 5, 1}, { 'boundary', 'administrative', 0, 1},
{ 'bridge', 'yes', 10, 0 }, { 'bridge', 'true', 10, 0 }, { 'bridge', 1, 10, 0 },
{ 'tunnel', 'yes', -10, 0}, { 'tunnel', 'true', -10, 0}, { 'tunnel', 1, -10, 0},
{ 'highway', 'minor', 3, 0}, { 'highway', 'road', 3, 0 }, { 'highway', 'unclassified', 3, 0 },
{ 'highway', 'residential', 3, 0 }, { 'highway', 'tertiary_link', 4, 0}, { 'highway', 'tertiary', 4, 0},
{ 'highway', 'secondary_link', 6, 1}, { 'highway', 'secondary', 6, 1},
{ 'highway', 'primary_link', 7, 1}, { 'highway', 'primary', 7, 1},
{ 'highway', 'trunk_link', 8, 1}, { 'highway', 'trunk', 8, 1},
{ 'highway', 'motorway_link', 9, 1}, { 'highway', 'motorway', 9, 1},
}
for i,k in ipairs(zordering_tags) do
if ((k[2] and keyvalues[k[1]] == k[2]) or (k[2] == nil and keyvalues[k[1]] ~= nil)) then
if (k[4] == 1) then
roads = 1
end
z_order = z_order + k[3]
end
end
keyvalues["z_order"] = z_order
return keyvalues, roads
end
function filter_tags_generic(keyvalues, nokeys)
filter = 0
tagcount = 0
if nokeys == 0 then
filter = 1
return filter, keyvalues
end
delete_tags = { 'FIXME', 'note', 'source' }
for i,k in ipairs(delete_tags) do
keyvalues[k] = nil
end
for k,v in pairs(keyvalues) do
for i, k2 in ipairs(generic_keys) do if k2 == k then tagcount = tagcount + 1; end end
end
if tagcount == 0 then
filter = 1
end
return filter, keyvalues
end
function filter_tags_node (keyvalues, nokeys)
return filter_tags_generic(keyvalues, nokeys)
end
function filter_basic_tags_rel (keyvalues, nokeys)
filter, keyvalues = filter_tags_generic(keyvalues, nokeys)
if filter == 1 then
return filter, keyvalues
end
if ((keyvalues["type"] ~= "route") and (keyvalues["type"] ~= "multipolygon") and (keyvalues["type"] ~= "boundary")) then
filter = 1
return filter, keyvalues
end
return filter, keyvalues
end
function filter_tags_way (keyvalues, nokeys)
filter = 0
poly = 0
tagcount = 0
roads = 0
filter, keyvalues = filter_tags_generic(keyvalues, nokeys)
if filter == 1 then
return filter, keyvalues, poly, roads
end
for i,k in ipairs(polygon_keys) do
if keyvalues[k] then
poly=1
break
end
end
if ((keyvalues["area"] == "yes") or (keyvalues["area"] == "1") or (keyvalues["area"] == "true")) then
poly = 1;
elseif ((keyvalues["area"] == "no") or (keyvalues["area"] == "0") or (keyvalues["area"] == "false")) then
poly = 0;
end
keyvalues, roads = add_z_order(keyvalues)
return filter, keyvalues, poly, roads
end
function filter_tags_relation_member (keyvalues, keyvaluemembers, roles, membercount)
filter = 0
boundary = 0
polygon = 0
roads = 0
membersuperseeded = {}
for i = 1, membercount do
membersuperseeded[i] = 0
end
type = keyvalues["type"]
keyvalues["type"] = nil
if (type == "boundary") then
boundary = 1
end
if ((type == "multipolygon") and keyvalues["boundary"]) then
boundary = 1
elseif (type == "multipolygon") then
polygon = 1
polytagcount = 0;
for i,k in ipairs(polygon_keys) do
if keyvalues[k] then
polytagcount = polytagcount + 1
end
end
if (polytagcount == 0) then
for i = 1,membercount do
if (roles[i] == "outer") then
for k,v in pairs(keyvaluemembers[i]) do
keyvalues[k] = v
end
end
end
end
for i = 1,membercount do
superseeded = 1
for k,v in pairs(keyvaluemembers[i]) do
if ((keyvalues[k] == nil) or (keyvalues[k] ~= v)) then
for j,k2 in ipairs(generic_keys) do
if (k == k2) then
superseeded = 0;
break
end
end
end
end
membersuperseeded[i] = superseeded
end
end
keyvalues, roads = add_z_order(keyvalues)
return filter, keyvalues, membersuperseeded, boundary, polygon, roads
end