forked from cxberlin/gravel-cartocss-style
-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
project.mml
480 lines (477 loc) · 24.6 KB
/
project.mml
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
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
name: CXBGravel
description: 'cxberlin.com Gravel Overlay'
attribution: Data © OpenStreetMap (and) contributors, ODbL
bounds: &world
- -180
- -85.05112877980659
- 180
- 85.05112877980659
center:
- 0
- 0
- 4
format: png
interactivity: false
minzoom: 0
maxzoom: 20
srs: "+proj=merc +a=6378137 +b=6378137 +lat_ts=0.0 +lon_0=0.0 +x_0=0.0 +y_0=0.0 +k=1.0 +units=m +nadgrids=@null +wktext +no_defs +over"
# Various parts to be included later on
_parts:
# Extents are used for tilemill, and dont actually make it to the generated XML
extents: &extents
extent: *world
srs-name: "900913"
srs: "+proj=merc +a=6378137 +b=6378137 +lat_ts=0.0 +lon_0=0.0 +x_0=0.0 +y_0=0.0 +k=1.0 +units=m +nadgrids=@null +wktext +no_defs +over"
extents84: &extents84
extent: *world
srs-name: "WGS84"
srs: "+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs"
osm2pgsql: &osm2pgsql
type: "postgis"
dbname: "osm"
key_field: ""
geometry_field: "way"
extent: "-20037508,-20037508,20037508,20037508"
Stylesheet:
- palette.mss
- road-colors.mss
- fonts.mss
- base.mss
- aerialways.mss
- roads.mss
- amenities.mss
- labels.mss
- placenames.mss
- addressing.mss
- ferry-routes.mss
- power.mss
- admin.mss
- gpx.mss
- legend.mss
Layer:
- id: roads_high
<<: *extents
Datasource:
<<: *osm2pgsql
table: |-
(
SELECT
way,
COALESCE(
CASE
WHEN highway='raceway' THEN 'track' -- render raceways as tracks
WHEN highway='cycleway' THEN 'track' -- render cycleways as tracks
WHEN highway='road' THEN 'residential' -- render "road" as residential
WHEN highway='footway' AND (bicycle='yes' OR bicycle='designated') THEN 'path'
WHEN highway='bridleway' AND (bicycle='yes' OR bicycle='designated' OR bicycle IS NULL) THEN 'path'
WHEN highway!='bus_guideway' THEN highway
ELSE NULL
END,
CASE
WHEN railway IN ('light_rail', 'subway', 'narrow_gauge', 'rail', 'tram') THEN 'railway'
ELSE NULL
END
) AS type,
access,
CASE
WHEN tags->'maxspeed'~E'^\\d+$' THEN (tags->'maxspeed')::integer
WHEN tags->'maxspeed'~E'^\\d+ mph$' THEN REPLACE(tags->'maxspeed', ' mph', '')::integer * 1.609344
WHEN tags->'maxspeed'~E'^\\d+ knots$' THEN REPLACE(tags->'maxspeed', ' knots', '')::integer * 1.852
WHEN tags->'maxspeed'='walk' THEN 5
ELSE NULL
END AS maxspeed_kmh,
CASE
WHEN (
tags->'psv' != 'no' OR tags->'motorcar' != 'no' OR tags->'bus' != 'no'
OR tags->'motor_vehicle' != 'no'
OR tags->'vehicle' != 'no'
) THEN 'yes'
WHEN tags->'psv' IS NULL AND tags->'motorcar' IS NULL AND tags->'bus' IS NULL AND tags->'motor_vehicle' IS NULL AND tags->'vehicle' IS NULL AND (access != 'no' OR access IS NULL) THEN 'yes'
ELSE 'no'
END AS motor_vehicle,
CASE
WHEN tags->'cyclestreet' IN ('yes') THEN 'yes'
WHEN tags->'bicycle_road' IN ('yes') THEN 'yes'
ELSE 'no'
END AS cyclestreet,
CASE
WHEN oneway IN ('yes', '-1') THEN oneway
ELSE 'no'
END AS oneway,
CASE
WHEN tags->'cycleway:left' IN ('track', 'opposite_track') THEN 'track'
WHEN tags->'cycleway:left' IN ('lane', 'opposite_lane') THEN 'lane'
WHEN tags->'cycleway:left' IN ('share_busway', 'opposite_share_busway', 'shoulder', 'shared_lane') THEN 'busway'
WHEN tags->'cycleway:both' IN ('track', 'opposite_track') THEN 'track'
WHEN tags->'cycleway:both' IN ('lane', 'opposite_lane') THEN 'lane'
WHEN tags->'cycleway:both' IN ('share_busway', 'opposite_share_busway', 'shoulder', 'shared_lane') THEN 'busway'
WHEN tags->'cycleway' IN ('track', 'opposite_track') THEN 'track'
WHEN tags->'cycleway' IN ('lane', 'opposite_lane') THEN 'lane'
WHEN tags->'cycleway' IN ('share_busway', 'opposite_share_busway', 'shoulder', 'shared_lane') THEN 'busway'
ELSE NULL
END AS cycleway_left_render,
CASE
WHEN tags->'cycleway:right' IN ('track', 'opposite_track') THEN 'track'
WHEN tags->'cycleway:right' IN ('lane', 'opposite_lane') THEN 'lane'
WHEN tags->'cycleway:right' IN ('share_busway', 'opposite_share_busway', 'shoulder', 'shared_lane') THEN 'busway'
WHEN tags->'cycleway:both' IN ('track', 'opposite_track') THEN 'track'
WHEN tags->'cycleway:both' IN ('lane', 'opposite_lane') THEN 'lane'
WHEN tags->'cycleway:both' IN ('share_busway', 'opposite_share_busway', 'shoulder', 'shared_lane') THEN 'busway'
WHEN tags->'cycleway' IN ('track', 'opposite_track') THEN 'track'
WHEN tags->'cycleway' IN ('lane', 'opposite_lane') THEN 'lane'
WHEN tags->'cycleway' IN ('share_busway', 'opposite_share_busway', 'shoulder', 'shared_lane') THEN 'busway'
ELSE NULL
END AS cycleway_right_render,
CASE
WHEN tags->'cycleway:left:oneway' IS NOT NULL THEN tags->'cycleway:left:oneway'
WHEN tags->'cycleway:left' IN ('opposite_lane', 'opposite_track', 'opposite_share_busway') THEN '-1'
WHEN tags->'cycleway' IN ('opposite_lane', 'opposite_track', 'opposite_share_busway') THEN '-1'
ELSE NULL
END AS cycleway_left_oneway,
CASE
WHEN tags->'cycleway:right:oneway' IS NOT NULL THEN tags->'cycleway:right:oneway'
WHEN tags->'cycleway:right' IN ('opposite_lane', 'opposite_track', 'opposite_share_busway') THEN '-1'
WHEN tags->'cycleway' IN ('opposite_lane', 'opposite_track', 'opposite_share_busway') THEN '-1'
ELSE NULL
END AS cycleway_right_oneway,
CASE
WHEN (bicycle = 'no' AND highway IN ('track', 'path')) THEN '' -- rare to see public tracks or paths that don't allow bike access
WHEN bicycle IN ('no', 'private') THEN ''
WHEN bicycle IS NOT NULL THEN bicycle
WHEN tags->'motorroad' IN ('yes') THEN 'no'
WHEN highway NOT IN ('motorway', 'motorway_link') AND tags->'vehicle' IN ('no', 'private') THEN 'no'
WHEN highway NOT IN ('motorway', 'motorway_link') AND tags->'vehicle' IS NOT NULL THEN tags->'vehicle'
WHEN highway NOT IN ('motorway', 'motorway_link') AND access IN ('no', 'private') THEN 'no'
WHEN highway NOT IN ('motorway', 'motorway_link') AND access IS NOT NULL THEN access
ELSE NULL
END AS can_bicycle,
CASE
WHEN tags->'segregated' IN ('yes') THEN 'yes'
ELSE 'no'
END AS segregated,
CASE
WHEN tags->'oneway:bicycle' IN ('yes', '-1') THEN tags->'oneway:bicycle'
ELSE 'no'
END AS oneway_bicycle,
COALESCE(
tags->'ramp:bicycle',
tags->'ramp:stroller',
tags->'ramp:wheelchair',
tags->'ramp:luggage'
) AS has_ramp,
CASE
-- From best tag to less precise quality surface tag (smoothness > track > surface).
WHEN tags->'smoothness' IS NULL AND tracktype IS NULL AND surface IS NULL
THEN 'unknown'
WHEN tags->'smoothness' IN ('horrible', 'very_horrible', 'impassable')
THEN 'mtb'
WHEN tags->'smoothness' IN ('bad', 'very_bad')
THEN 'cyclocross'
WHEN tracktype IN ('grade4', 'grade5')
THEN 'mtb'
WHEN tracktype IN ('grade3')
THEN 'cyclocross'
WHEN tracktype IN ('grade2')
THEN 'gravel'
WHEN surface IN ('bad', 'pebblestone', 'dirt', 'earth', 'grass', 'grass_paver', 'gravel_turf', 'ground', 'mud', 'sand')
THEN 'mtb'
WHEN surface IN ('concrete:lanes', 'concrete:plates', 'sett', 'unhewn_cobblestone', 'cobblestone', 'wood', 'woodchips', 'unpaved')
THEN 'cyclocross'
WHEN surface IN ('fine_gravel', 'compacted', 'gravel')
THEN 'gravel'
ELSE NULL
END AS surface_type,
CASE
WHEN tags->'mtb:scale'~E'^\\d+[+-]?$' THEN REPLACE(REPLACE(tags->'mtb:scale', '+', ''), '-', '')::integer
ELSE NULL
END AS mtb_scale,
CASE
WHEN tags->'mtb:scale:imba'~E'^\\d+$' THEN (tags->'mtb:scale:imba')::integer
ELSE NULL
END AS mtb_scale_imba,
CASE
WHEN highway='cycleway' OR (highway IN ('path', 'footway', 'pedestrian', 'bridleway') AND bicycle IN ('yes', 'designated')) THEN CASE WHEN layer~E'^\\d+$' THEN 100*layer::integer+39 ELSE 39 END
WHEN highway IN ('path', 'footway', 'pedestrian', 'bridleway') THEN CASE WHEN layer~E'^\\d+$' THEN 100*layer::integer+38 ELSE 38 END
ELSE z_order
END AS z_order
FROM planet_osm_line
WHERE (highway IS NOT NULL OR railway IN ('light_rail', 'subway', 'narrow_gauge', 'rail', 'tram'))
AND (tunnel IS NULL OR tunnel = 'no')
AND (bridge IS NULL OR bridge = 'no')
AND (covered IS NULL OR covered = 'no')
AND (tags->'indoor' IS NULL OR tags->'indoor' = 'no')
-- CXB conditions
AND (tags->'smoothness' IS NULL OR tags-> 'smoothness' IN ('excellent', 'good', 'intermediate', 'bad', 'very_bad'))
AND (
-- these surfaces are all suitable for grvl, regardless of smoothness
(surface IN ('finegravel', 'fine_gravel', 'gravel', 'pebblestone', 'compacted', 'concrete:lanes'))
OR
-- these too
(tracktype IN ('grade2'))
OR
-- dirt/unpaved roads or tracktype=grade3 can go either way and are only considered if smoothness explicitly tells us it's reasonable
-- (note that tracktype=grade2 with smoothness=null are still considered through other conditions)
((surface IN ('dirt', 'unpaved') or tracktype = 'grade3') AND tags->'smoothness' IN ('excellent', 'good', 'intermediate'))
)
AND (surface IS NULL OR surface <> 'sand')
ORDER BY z_order
) AS data
geometry: linestring
properties:
cache-features: true
minzoom: 11
- id: amenities-poly
<<: *extents
Datasource:
<<: *osm2pgsql
# Update the layer with the text below as well when editing this query.
table: |-
(
SELECT
access,
bicycle,
tags->'mtb' AS mtb,
covered,
tags->'shelter' AS shelter,
way,
name,
COALESCE( -- order is important here
'tourism_' || CASE WHEN tourism IN ('alpine_hut', 'camp_site', 'caravan_site', 'wilderness_hut', 'picnic_site') THEN tourism ELSE NULL END,
'amenity_' || CASE WHEN amenity IN ('bicycle_repair_station', 'compressed_air', 'drinking_water', 'fountain', 'hospital', 'pharmacy', 'public_bath', 'shelter', 'shower', 'toilets', 'water_point', 'fuel') THEN amenity ELSE NULL END,
'shop_' || CASE WHEN tags->'service:bicycle:retail'='yes' OR tags->'service:bicycle:repair'='yes' OR tags->'service:bicycle:rental'='yes' OR tags->'service:bicycle:pump'='yes' OR tags->'service:bicycle:diy'='yes' THEN 'bicycle' ELSE CASE WHEN shop IN ('bicycle', 'bakery', 'beverage', 'convenience', 'convenience;gas', 'greengrocer', 'supermarket', 'pastry', 'sports') THEN shop ELSE NULL END END,
'emergency_' || CASE WHEN tags->'emergency' IS NOT NULL then tags->'emergency' ELSE NULL END,
'healthcare_' || CASE WHEN tags->'healthcare' IN ('clinic', 'hospital') THEN tags->'healthcare' ELSE NULL END,
'leisure_' || CASE WHEN leisure='picnic_table' THEN leisure ELSE NULL END,
'man_made_' || CASE WHEN man_made IN ('mast', 'tower', 'water_tower', 'lighthouse', 'windmill', 'cross', 'obelisk', 'communications_tower', 'telescope', 'chimney', 'crane', 'storage_tank', 'silo', 'water_tap', 'monitoring_station') THEN man_made ELSE NULL END,
'natural_' || CASE WHEN "natural" IN ('peak', 'volcano', 'saddle', 'spring', 'cave_entrance') THEN "natural" ELSE NULL END,
'waterway_' || CASE WHEN waterway IN ('waterfall') THEN waterway ELSE NULL END,
'historic_' || CASE WHEN historic IN ('memorial', 'monument', 'archaeological_site', 'wayside_cross', 'fort', 'wayside_shrine', 'castle', 'manor', 'city_gate') THEN historic ELSE NULL END,
'military_'|| CASE WHEN military IN ('bunker') THEN military ELSE NULL END,
'highway_'|| CASE WHEN highway IN ('bus_stop', 'elevator', 'traffic_signals') THEN highway ELSE NULL END,
'power_' || power,
'landuse_' || CASE WHEN landuse IN ('cemetery') THEN landuse ELSE NULL END
) AS feature,
CASE
WHEN tags->'capacity'~E'^\\d+$' THEN (tags->'capacity')::integer
ELSE NULL
END AS capacity,
religion,
tags->'denomination' AS denomination,
tags->'compressed_air' AS compressed_air,
tags->'car_wash' as car_wash,
tags->'drinking_water' AS drinking_water,
tags->'location' AS location,
tags->'memorial' AS memorial,
tags->'castle_type' AS castle_type,
tags->'information' AS information,
tags->'artwork_type' as artwork_type,
tags->'icao' as icao,
tags->'iata' as iata,
"generator:source",
tags->'supervised' as supervised,
tags->'bicycle_parking' as bicycle_parking,
tags->'vending' as vending,
tags->'automated' as automated,
CASE
WHEN "natural" IN ('peak', 'volcano', 'saddle') THEN NULL
WHEN "waterway" IN ('waterfall') THEN
CASE
WHEN tags->'height' ~ '^\d{1,3}(\.\d+)?( m)?$' THEN (SUBSTRING(tags->'height', '^(\d{1,3}(\.\d+)?)( m)?$'))::NUMERIC
ELSE NULL
END
WHEN tags->'capacity'~E'^\\d+$' THEN (tags->'capacity')::integer
ELSE NULL
END AS score,
NULL AS elevation,
CASE
WHEN (man_made IN ('mast', 'tower', 'chimney', 'crane') AND (tags->'location' NOT IN ('roof', 'rooftop') OR (tags->'location') IS NULL)) OR waterway IN ('waterfall') THEN
CASE
WHEN tags->'height' ~ '^\d{1,3}(\.\d+)?( m)?$' THEN (SUBSTRING(tags->'height', '^(\d{1,3}(\.\d+)?)( m)?$'))::NUMERIC
ELSE NULL
END
ELSE NULL
END AS height,
way_area/NULLIF(!pixel_width!::real*!pixel_height!::real,0) AS way_pixels
FROM planet_osm_polygon
WHERE
tourism IN ('alpine_hut', 'camp_site', 'caravan_site', 'wilderness_hut', 'picnic_site')
OR amenity IN ('bicycle_repair_station', 'compressed_air', 'drinking_water', 'fountain', 'public_bath', 'shelter', 'shower', 'toilets', 'water_point', 'fuel')
OR tags->'compressed_air'='yes'
OR tags->'car_wash'='yes'
OR (amenity='motorcycle_parking' AND (bicycle='yes' OR bicycle='designated'))
OR (amenity='charging_station' AND (bicycle='yes' OR bicycle='designated'))
OR (amenity='vending_machine' AND tags->'vending'='bicycle_tube')
--OR tags->'healthcare' IN ('clinic', 'hospital')
OR shop IN ('bicycle', 'bakery', 'convenience;gas', 'supermarket')
OR leisure='picnic_table'
--OR (
-- man_made IN ('mast', 'tower', 'water_tower', 'lighthouse', 'windmill', 'cross', 'obelisk', 'communications_tower', 'telescope', 'chimney', 'crane', 'storage_tank', 'silo')
-- AND (tags->'location' NOT IN ('roof', 'rooftop') OR (tags->'location') IS NULL)
--)
OR man_made IN ('water_tap')
OR man_made IN ('monitoring_station') AND tags->'monitoring:bicycle'='yes'
--OR "natural" IN ('peak', 'volcano', 'saddle', 'spring', 'cave_entrance')
--OR waterway IN ('waterfall')
--OR historic IN ('memorial', 'monument', 'archaeological_site', 'wayside_cross', 'fort', 'wayside_shrine', 'castle', 'manor', 'city_gate')
--OR military IN ('bunker')
--OR tags->'emergency'='phone'
--OR highway IN ('elevator', 'traffic_signals')
OR (highway='bus_stop' AND (tags->'shelter'='yes' OR covered='yes'))
--OR (power = 'generator' AND "generator:source"='wind')
OR (landuse = 'cemetery')
ORDER BY
CASE
-- Emergency first
WHEN tags->'healthcare' IS NOT NULL OR tags->'emergency'='phone' OR amenity IN ('hospital', 'pharmacy') THEN 0
-- Other emergency-related amenities
WHEN amenity IN ('bicycle_repair_station', 'compressed_air', 'drinking_water', 'police', 'toilets',
'water_point', 'charging_station') THEN 10
WHEN tags->'compressed_air'='yes' THEN 11
-- Bike amenities
WHEN shop IN ('bicycle', 'sports') THEN 30
WHEN amenity IN ('bicycle_rental') Then 31
WHEN amenity IN ('bicycle_parking', 'motorcycle_parking') THEN 32
-- Supermarkets and bakeries
WHEN shop IN ('supermarket') THEN 40
WHEN shop IN ('bakery') THEN 45
-- Convenience
WHEN shop='convenience' OR shop='convenience;gas' THEN 50
-- Food
WHEN shop IS NOT NULL OR amenity IN ('bar', 'biergarten', 'cafe', 'fast_food', 'food_court', 'pub', 'restaurant') THEN 60
-- Everything else
ELSE NULL
END ASC NULLS LAST,
feature,
score DESC NULLS LAST
) AS data
geometry: polygon
properties:
minzoom: 13
- id: amenities-points
<<: *extents
Datasource:
<<: *osm2pgsql
# Update the layer with the text below as well when editing this query.
table: |-
(
SELECT
access,
bicycle,
tags->'mtb' AS mtb,
covered,
tags->'shelter' AS shelter,
way,
name,
COALESCE( -- order is important here
'tourism_' || CASE WHEN tourism IN ('alpine_hut', 'camp_site', 'caravan_site', 'wilderness_hut', 'picnic_site') THEN tourism ELSE NULL END,
'amenity_' || CASE WHEN amenity IN ('bicycle_repair_station', 'compressed_air', 'drinking_water', 'fountain', 'hospital', 'pharmacy', 'public_bath', 'shelter', 'shower', 'toilets', 'water_point', 'fuel') THEN amenity ELSE NULL END,
'shop_' || CASE WHEN tags->'service:bicycle:retail'='yes' OR tags->'service:bicycle:repair'='yes' OR tags->'service:bicycle:rental'='yes' OR tags->'service:bicycle:pump'='yes' OR tags->'service:bicycle:diy'='yes' THEN 'bicycle' ELSE CASE WHEN shop IN ('bicycle', 'bakery', 'beverage', 'convenience', 'convenience;gas', 'greengrocer', 'supermarket', 'pastry', 'sports') THEN shop ELSE NULL END END,
'emergency_' || CASE WHEN tags->'emergency' IS NOT NULL then tags->'emergency' ELSE NULL END,
'healthcare_' || CASE WHEN tags->'healthcare' IN ('clinic', 'hospital') THEN tags->'healthcare' ELSE NULL END,
'leisure_' || CASE WHEN leisure='picnic_table' THEN leisure ELSE NULL END,
'man_made_' || CASE WHEN man_made IN ('mast', 'tower', 'water_tower', 'lighthouse', 'windmill', 'cross', 'obelisk', 'communications_tower', 'telescope', 'chimney', 'crane', 'storage_tank', 'silo', 'water_tap', 'monitoring_station') THEN man_made ELSE NULL END,
'natural_' || CASE WHEN "natural" IN ('peak', 'volcano', 'saddle', 'spring', 'cave_entrance') THEN "natural" ELSE NULL END,
'waterway_' || CASE WHEN waterway IN ('waterfall') THEN waterway ELSE NULL END,
'historic_' || CASE WHEN historic IN ('memorial', 'monument', 'archaeological_site', 'wayside_cross', 'fort', 'wayside_shrine', 'castle', 'manor', 'city_gate') THEN historic ELSE NULL END,
'military_'|| CASE WHEN military IN ('bunker') THEN military ELSE NULL END,
'highway_'|| CASE WHEN highway IN ('bus_stop', 'elevator', 'traffic_signals') THEN highway ELSE NULL END,
'power_' || power
) AS feature,
CASE
WHEN tags->'capacity'~E'^\\d+$' THEN (tags->'capacity')::integer
ELSE NULL
END AS capacity,
religion,
tags->'denomination' AS denomination,
tags->'compressed_air' AS compressed_air,
tags->'car_wash' as car_wash,
tags->'drinking_water' AS drinking_water,
tags->'location' AS location,
tags->'memorial' AS memorial,
tags->'castle_type' AS castle_type,
tags->'information' AS information,
tags->'artwork_type' as artwork_type,
tags->'icao' as icao,
tags->'iata' as iata,
"generator:source",
tags->'supervised' as supervised,
tags->'bicycle_parking' as bicycle_parking,
tags->'vending' as vending,
tags->'automated' as automated,
CASE
WHEN "natural" IN ('peak', 'volcano', 'saddle') THEN
CASE
WHEN ele ~ '^-?\d{1,4}(\.\d+)?$' THEN ele::NUMERIC
ELSE NULL
END
WHEN "waterway" IN ('waterfall') THEN
CASE
WHEN tags->'height' ~ '^\d{1,3}(\.\d+)?( m)?$' THEN (SUBSTRING(tags->'height', '^(\d{1,3}(\.\d+)?)( m)?$'))::NUMERIC
ELSE NULL
END
WHEN tags->'capacity'~E'^\\d+$' THEN (tags->'capacity')::integer
ELSE NULL
END AS score,
CASE
WHEN "natural" IN ('peak', 'volcano', 'saddle')
OR tourism = 'alpine_hut' OR (tourism = 'information' AND tags->'information' = 'guidepost')
OR amenity = 'shelter'
THEN
CASE
WHEN ele ~ '^-?\d{1,4}(\.\d+)?$' THEN ele::NUMERIC
ELSE NULL
END
ELSE NULL
END AS elevation,
CASE
WHEN (man_made IN ('mast', 'tower', 'chimney', 'crane') AND (tags->'location' NOT IN ('roof', 'rooftop') OR (tags->'location') IS NULL)) OR waterway IN ('waterfall') THEN
CASE
WHEN tags->'height' ~ '^\d{1,3}(\.\d+)?( m)?$' THEN (SUBSTRING(tags->'height', '^(\d{1,3}(\.\d+)?)( m)?$'))::NUMERIC
ELSE NULL
END
ELSE NULL
END AS height,
NULL AS way_pixels
FROM planet_osm_point
WHERE
tourism IN ('alpine_hut', 'camp_site', 'caravan_site', 'wilderness_hut', 'picnic_site')
OR amenity IN ('bicycle_repair_station', 'compressed_air', 'drinking_water', 'fountain', 'public_bath', 'shelter', 'shower', 'toilets', 'water_point', 'fuel')
OR tags->'compressed_air'='yes'
OR tags->'car_wash'='yes'
OR (amenity='motorcycle_parking' AND (bicycle='yes' OR bicycle='designated'))
OR (amenity='charging_station' AND (bicycle='yes' OR bicycle='designated'))
OR (amenity='vending_machine' AND tags->'vending'='bicycle_tube')
OR shop IN ('bicycle', 'bakery', 'convenience;gas', 'supermarket')
OR leisure='picnic_table'
OR man_made IN ('water_tap')
OR (highway='bus_stop' AND (tags->'shelter'='yes' OR covered='yes'))
OR tags->'ford' IS NOT NULL
ORDER BY
CASE
-- Emergency first
WHEN tags->'healthcare' IS NOT NULL OR tags->'emergency'='phone' OR amenity IN ('hospital', 'pharmacy') THEN 0
-- Other emergency-related amenities
WHEN amenity IN ('bicycle_repair_station', 'compressed_air', 'drinking_water', 'police', 'toilets',
'water_point', 'charging_station') THEN 10
WHEN tags->'compressed_air'='yes' THEN 11
-- Bike amenities
WHEN shop IN ('bicycle', 'sports') THEN 30
WHEN amenity IN ('bicycle_rental') Then 31
WHEN amenity IN ('bicycle_parking', 'motorcycle_parking') THEN 32
-- Supermarkets and Bakeries
WHEN shop IN ('supermarket') THEN 40
WHEN shop IN ('bakery') THEN 45
-- Convenience
WHEN shop='convenience' OR shop='convenience;gas' THEN 50
-- Food
WHEN shop IS NOT NULL OR amenity IN ('bar', 'biergarten', 'cafe', 'fast_food', 'food_court', 'pub', 'restaurant') THEN 60
-- Everything else
ELSE NULL
END ASC NULLS LAST,
feature,
score DESC NULLS LAST
) AS data
geometry: point
properties:
cache-features: true
minzoom: 13