-
Notifications
You must be signed in to change notification settings - Fork 0
/
style.lua
244 lines (200 loc) · 7.79 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
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
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','designation','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 ) 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
-- ----------------------------------------------------------------------------
-- Designation processing
--
-- The "standard" stylesheet contains rules for different sorts of tracks
-- (tracktype), but doesn't contain rules for English/Welsh rights of way
-- designations.
--
-- The changes here do the following:
-- 1) Render any non-designated footway, bridleway or track as "path"
-- (grey dashes in the "standard" style)
-- 2) Render anything designated as "public_footpath" as a "footway" (dotted
-- salmon)
-- 3) Render anything designated as "public_bridleway" as a "footway" (dotted
-- green)
-- 4) Render anything designated as "restricted_byway" as a "grade4 track"
-- (dashed and dotted brown).
-- 5) Render anything designated as "byway_open_to_all_traffic" as a
-- "grade3 track" (dashed brown)
-- 6) Render anything designated as "unclassified_county_road" or a
-- misspelling as a "grade2 track" (long dashed brown)
--
-- These changes do mean that the the resulting database isn't any use for
-- anything other than rendering, but they do allow designations to be
-- displayed without any stylesheet changes. Also, some information is
-- lost in the process (e.g. track or steps vs path).
-- ----------------------------------------------------------------------------
keyvalues["tracktype"] = nil
if ((keyvalues["highway"] == "footway") or
(keyvalues["highway"] == "bridleway") or
(keyvalues["highway"] == "track")) then
keyvalues["highway"] = "path"
end
if ((keyvalues["highway"] == "unclassified") and
(keyvalues["surface"] == "unpaved" )) then
keyvalues["highway"] = "track"
keyvalues["tracktype"] = "grade1"
end
if ((keyvalues["designation"] == "unclassified_county_road") or
(keyvalues["designation"] == "unclassified_country_road") or
(keyvalues["designation"] == "unclassified_highway")) then
keyvalues["highway"] = "track"
keyvalues["tracktype"] = "grade2"
end
if (keyvalues["designation"] == "byway_open_to_all_traffic") then
keyvalues["highway"] = "track"
keyvalues["tracktype"] = "grade3"
end
if (keyvalues["designation"] == "restricted_byway") then
keyvalues["highway"] = "track"
keyvalues["tracktype"] = "grade4"
end
if (keyvalues["designation"] == "public_bridleway") then
keyvalues["highway"] = "bridleway"
end
if (keyvalues["designation"] == "public_footpath") then
keyvalues["highway"] = "footway"
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