forked from gravitystorm/openstreetmap-carto
-
Notifications
You must be signed in to change notification settings - Fork 0
/
project.mml
2263 lines (2261 loc) · 89.1 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
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
scale: 1
metatile: 2
name: OpenStreetMap Carto
description: A general-purpose OpenStreetMap mapnik style, in CartoCSS
bounds: &world
- -180
- -85.05112877980659
- 180
- 85.05112877980659
center:
- 0
- 0
- 4
format: png
interactivity: false
minzoom: 0
maxzoom: 22
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 don't 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"
osm2pgsql: &osm2pgsql
type: "postgis"
dbname: "gis"
key_field: ""
geometry_field: "way"
extent: "-20037508,-20037508,20037508,20037508"
Stylesheet:
- style/style.mss
- style/fonts.mss
- style/shapefiles.mss
- style/landcover.mss
- style/water.mss
- style/water-features.mss
- style/road-colors-generated.mss
- style/roads.mss
- style/power.mss
- style/placenames.mss
- style/buildings.mss
- style/stations.mss
- style/amenity-points.mss
- style/ferry-routes.mss
- style/aerialways.mss
- style/admin.mss
- style/addressing.mss
Layer:
- id: landcover-low-zoom
geometry: polygon
<<: *extents
Datasource:
<<: *osm2pgsql
table: |-
(SELECT
way, way_pixels,
COALESCE(wetland, landuse, "natural") AS feature
FROM (SELECT
way,
('landuse_' || (CASE WHEN landuse IN ('forest', 'farmland', 'residential', 'commercial', 'retail', 'industrial',
'meadow', 'grass', 'village_green', 'vineyard', 'orchard') THEN landuse END)) AS landuse,
('natural_' || (CASE WHEN "natural" IN ('wood', 'sand', 'scree', 'shingle', 'bare_rock', 'heath', 'grassland', 'scrub') THEN "natural" END)) AS "natural",
('wetland_' || (CASE WHEN "natural" IN ('wetland', 'mud') THEN (CASE WHEN "natural" IN ('mud') THEN "natural" ELSE tags->'wetland' END) END)) AS wetland,
way_area/NULLIF(POW(!scale_denominator!*0.001*0.28,2),0) AS way_pixels,
way_area
FROM planet_osm_polygon
WHERE (landuse IN ('forest', 'farmland', 'residential', 'commercial', 'retail', 'industrial', 'meadow', 'grass', 'village_green', 'vineyard', 'orchard')
OR "natural" IN ('wood', 'wetland', 'mud', 'sand', 'scree', 'shingle', 'bare_rock', 'heath', 'grassland', 'scrub'))
AND way_area > 0.01*!pixel_width!::real*!pixel_height!::real
AND building IS NULL
) AS features
ORDER BY way_area DESC, feature
) AS landcover_low_zoom
properties:
cache-features: true
minzoom: 5
maxzoom: 9
- id: landcover
geometry: polygon
<<: *extents
Datasource:
<<: *osm2pgsql
table: |-
(SELECT
way, name, religion, way_pixels, is_building,
COALESCE(aeroway, amenity, wetland, power, landuse, leisure, man_made, "natural", shop, tourism, highway, railway) AS feature
FROM (SELECT
way, COALESCE(name, '') AS name,
('aeroway_' || (CASE WHEN aeroway IN ('apron', 'aerodrome') THEN aeroway END)) AS aeroway,
('amenity_' || (CASE WHEN amenity IN ('bicycle_parking', 'motorcycle_parking', 'university', 'college', 'school', 'taxi',
'hospital', 'kindergarten', 'grave_yard', 'prison', 'place_of_worship', 'clinic', 'ferry_terminal',
'marketplace', 'community_centre', 'social_facility', 'arts_centre', 'parking_space', 'bus_station',
'fire_station', 'police')
OR amenity IN ('parking') AND (tags->'parking' NOT IN ('underground') OR (tags->'parking') IS NULL) THEN amenity END)) AS amenity,
('landuse_' || (CASE WHEN landuse IN ('quarry', 'vineyard', 'orchard', 'cemetery', 'residential', 'garages', 'meadow', 'grass',
'allotments', 'forest', 'farmyard', 'farmland', 'greenhouse_horticulture',
'recreation_ground', 'village_green', 'retail', 'industrial', 'railway', 'commercial',
'brownfield', 'landfill', 'salt_pond', 'construction', 'plant_nursery', 'religious') THEN landuse END)) AS landuse,
('shop_' || (CASE WHEN shop IN ('mall') AND (tags->'location' NOT IN ('underground') OR (tags->'location') IS NULL) THEN shop END)) AS shop,
('leisure_' || (CASE WHEN leisure IN ('swimming_pool', 'playground', 'park', 'recreation_ground', 'garden',
'golf_course', 'miniature_golf', 'sports_centre', 'stadium', 'pitch', 'ice_rink',
'track', 'dog_park', 'fitness_station', 'water_park') THEN leisure END)) AS leisure,
('man_made_' || (CASE WHEN man_made IN ('works', 'wastewater_plant', 'water_works') THEN man_made END)) AS man_made,
('natural_' || (CASE WHEN "natural" IN ('beach', 'shoal', 'heath', 'grassland', 'wood', 'sand', 'scree', 'shingle', 'bare_rock', 'scrub') THEN "natural" END)) AS "natural",
('wetland_' || (CASE WHEN "natural" IN ('wetland', 'mud') THEN (CASE WHEN "natural" = 'mud' THEN "natural" ELSE tags->'wetland' END) END)) AS wetland,
('power_' || (CASE WHEN power IN ('plant', 'substation', 'generator') THEN power END)) AS power,
('tourism_' || (CASE WHEN tourism IN ('camp_site', 'caravan_site', 'picnic_site') THEN tourism END)) AS tourism,
('highway_' || (CASE WHEN highway IN ('services', 'rest_area') THEN highway END)) AS highway,
('railway_' || (CASE WHEN railway = 'station' THEN railway END)) AS railway,
CASE WHEN religion IN ('christian', 'jewish', 'muslim') THEN religion ELSE 'INT-generic'::text END AS religion,
way_area/NULLIF(POW(!scale_denominator!*0.001*0.28,2),0) AS way_pixels,
CASE WHEN building = 'no' OR building IS NULL THEN 'no' ELSE 'yes' END AS is_building,
way_area
FROM planet_osm_polygon
WHERE (landuse IS NOT NULL
OR leisure IS NOT NULL
OR aeroway IN ('apron', 'aerodrome')
OR amenity IN ('parking', 'bicycle_parking', 'motorcycle_parking', 'taxi', 'university', 'college', 'school', 'hospital', 'kindergarten',
'grave_yard', 'place_of_worship', 'prison', 'clinic', 'ferry_terminal', 'marketplace', 'community_centre', 'social_facility',
'arts_centre', 'parking_space', 'bus_station', 'fire_station', 'police')
OR man_made IN ('works', 'wastewater_plant','water_works')
OR "natural" IN ('beach', 'shoal', 'heath', 'mud', 'wetland', 'grassland', 'wood', 'sand', 'scree', 'shingle', 'bare_rock', 'scrub')
OR power IN ('plant', 'substation', 'generator')
OR shop IN ('mall')
OR tourism IN ('camp_site', 'caravan_site', 'picnic_site')
OR highway IN ('services', 'rest_area')
OR railway = 'station')
AND way_area > 1*!pixel_width!::real*!pixel_height!::real
) AS landcover
ORDER BY way_area DESC, feature
) AS features
properties:
cache-features: true
minzoom: 10
- id: landcover-line
geometry: linestring
<<: *extents
Datasource:
<<: *osm2pgsql
table: |-
(SELECT
way
FROM planet_osm_line
WHERE man_made = 'cutline'
) AS landcover_line
properties:
minzoom: 14
- id: icesheet-poly
geometry: polygon
<<: *extents
Datasource:
<<: *osm2pgsql
table: |-
(SELECT
way
FROM icesheet_polygons
) AS icesheet_polygons
properties:
minzoom: 5
- id: water-lines-casing
geometry: linestring
<<: *extents
Datasource:
<<: *osm2pgsql
table: |-
(SELECT
way,
waterway,
CASE WHEN tags->'intermittent' IN ('yes')
OR tags->'seasonal' IN ('yes', 'spring', 'summer', 'autumn', 'winter', 'wet_season', 'dry_season')
THEN 'yes' ELSE 'no' END AS int_intermittent,
CASE WHEN tunnel IN ('yes', 'culvert')
OR waterway='canal' AND tunnel = 'flooded'
THEN 'yes' ELSE 'no' END AS int_tunnel
FROM planet_osm_line
WHERE waterway IN ('stream', 'drain', 'ditch')
) AS water_lines_casing
properties:
minzoom: 13
- id: water-lines-low-zoom
geometry: linestring
<<: *extents
Datasource:
<<: *osm2pgsql
table: |-
(SELECT
way,
waterway,
CASE WHEN tags->'intermittent' IN ('yes')
OR tags->'seasonal' IN ('yes', 'spring', 'summer', 'autumn', 'winter', 'wet_season', 'dry_season')
THEN 'yes' ELSE 'no' END AS int_intermittent
FROM planet_osm_line
WHERE waterway = 'river'
) AS water_lines_low_zoom
properties:
minzoom: 8
maxzoom: 11
- id: water-lines
geometry: linestring
<<: *extents
Datasource:
<<: *osm2pgsql
table: |-
(SELECT
way,
waterway,
name,
CASE WHEN tags->'intermittent' IN ('yes')
OR tags->'seasonal' IN ('yes', 'spring', 'summer', 'autumn', 'winter', 'wet_season', 'dry_season')
THEN 'yes' ELSE 'no' END AS int_intermittent,
CASE WHEN tunnel IN ('yes', 'culvert')
OR waterway = 'canal' AND tunnel = 'flooded'
THEN 'yes' ELSE 'no' END AS int_tunnel,
'no' AS bridge
FROM planet_osm_line
WHERE waterway IN ('river', 'canal', 'stream', 'drain', 'ditch')
AND (bridge IS NULL OR bridge NOT IN ('yes', 'aqueduct'))
ORDER BY COALESCE(layer,0)
) AS water_lines
properties:
minzoom: 12
- id: water-areas
geometry: polygon
<<: *extents
Datasource:
<<: *osm2pgsql
table: |-
(SELECT
way,
"natural",
waterway,
landuse,
way_area/NULLIF(POW(!scale_denominator!*0.001*0.28,2),0) AS way_pixels,
CASE WHEN tags->'intermittent' IN ('yes')
OR tags->'seasonal' IN ('yes', 'spring', 'summer', 'autumn', 'winter', 'wet_season', 'dry_season')
OR tags->'basin' IN ('detention', 'infiltration')
THEN 'yes' ELSE 'no' END AS int_intermittent
FROM planet_osm_polygon
WHERE
(waterway IN ('dock', 'riverbank')
OR landuse IN ('reservoir', 'basin')
OR "natural" IN ('water', 'glacier'))
AND building IS NULL
AND way_area > 1*!pixel_width!::real*!pixel_height!::real
ORDER BY COALESCE(layer,0), way_area DESC
) AS water_areas
properties:
cache-features: true
minzoom: 0
- id: ocean-lz
geometry: polygon
<<: *extents
Datasource:
<<: *osm2pgsql
table: |-
(SELECT
way
FROM simplified_water_polygons
) AS ocean_lz
properties:
maxzoom: 9
- id: ocean
geometry: polygon
<<: *extents
Datasource:
<<: *osm2pgsql
table: |-
(SELECT
way
FROM water_polygons
) AS ocean
properties:
minzoom: 10
- id: landcover-area-symbols
geometry: polygon
<<: *extents
Datasource:
<<: *osm2pgsql
table: |-
(SELECT
way, surface,
COALESCE(CASE WHEN landuse = 'forest' THEN 'wood' END, "natural") AS "natural",
CASE WHEN "natural" = 'mud'
THEN "natural"
ELSE CASE WHEN ("natural" = 'wetland' AND NOT tags ? 'wetland')
THEN 'wetland'
ELSE CASE WHEN ("natural" = 'wetland')
THEN tags->'wetland'
END
END
END AS int_wetland,
landuse,
tags->'leaf_type' AS leaf_type,
way_area/NULLIF(POW(!scale_denominator!*0.001*0.28,2),0) AS way_pixels
FROM planet_osm_polygon
WHERE ("natural" IN ('mud', 'wetland', 'wood', 'beach', 'shoal', 'reef', 'scrub') OR landuse IN ('forest', 'salt_pond'))
AND building IS NULL
AND way_area > 1*!pixel_width!::real*!pixel_height!::real
ORDER BY COALESCE(layer,0), way_area DESC
) AS landcover_area_symbols
properties:
cache-features: true
minzoom: 9
- id: icesheet-outlines
geometry: linestring
<<: *extents
Datasource:
<<: *osm2pgsql
table: |-
(SELECT
way,
ice_edge
FROM icesheet_outlines
) AS icesheet_outlines
properties:
minzoom: 5
- id: marinas-area
geometry: polygon
<<: *extents
Datasource:
<<: *osm2pgsql
table: |-
(SELECT
way
FROM planet_osm_polygon
WHERE leisure = 'marina'
) AS marinas_area
properties:
minzoom: 14
- id: water-barriers-line
geometry: linestring
<<: *extents
Datasource:
<<: *osm2pgsql
table: |-
(SELECT
way,
waterway
FROM planet_osm_line
WHERE waterway IN ('dam', 'weir', 'lock_gate')
) AS water_barriers_line
properties:
minzoom: 13
- id: water-barriers-poly
geometry: polygon
<<: *extents
Datasource:
<<: *osm2pgsql
table: |-
(SELECT
way,
waterway
FROM planet_osm_polygon
WHERE waterway IN ('dam', 'weir', 'lock_gate')
) AS water_barriers_poly
properties:
minzoom: 13
- id: piers-poly
geometry: polygon
<<: *extents
Datasource:
<<: *osm2pgsql
table: |-
(SELECT
way, man_made
FROM planet_osm_polygon
WHERE man_made IN ('pier', 'breakwater', 'groyne')
) AS piers_poly
properties:
minzoom: 12
- id: piers-line
geometry: linestring
<<: *extents
Datasource:
<<: *osm2pgsql
table: |-
(SELECT
way, man_made
FROM planet_osm_line
WHERE man_made IN ('pier', 'breakwater', 'groyne')
) AS piers_line
properties:
minzoom: 12
- id: water-barriers-point
geometry: point
<<: *extents
Datasource:
<<: *osm2pgsql
table: |-
(SELECT
way, waterway
FROM planet_osm_point
WHERE waterway IN ('dam', 'weir', 'lock_gate')
) AS water_barriers_points
properties:
minzoom: 17
- id: bridge
geometry: polygon
<<: *extents
Datasource:
<<: *osm2pgsql
table: |-
(SELECT
way,
man_made
FROM planet_osm_polygon
WHERE man_made = 'bridge'
) AS bridge
properties:
minzoom: 12
- id: buildings
geometry: polygon
<<: *extents
Datasource:
<<: *osm2pgsql
table: |-
(SELECT
way,
building,
amenity,
aeroway,
aerialway,
tags->'public_transport' as public_transport
FROM planet_osm_polygon
WHERE building IS NOT NULL
AND building != 'no'
AND way_area > 1*!pixel_width!::real*!pixel_height!::real
ORDER BY COALESCE(layer,0), way_area DESC
) AS buildings
properties:
minzoom: 14
- id: tunnels
geometry: linestring
<<: *extents
Datasource:
<<: *osm2pgsql
# This query is quite large, having to deal with both roads, railways. To
# allow for ways that are both railways and roads, a UNION ALL is present.
table: |-
(SELECT
way,
(CASE WHEN feature IN ('highway_motorway_link', 'highway_trunk_link', 'highway_primary_link', 'highway_secondary_link', 'highway_tertiary_link') THEN substr(feature, 0, length(feature)-4) ELSE feature END) AS feature,
horse,
foot,
bicycle,
tracktype,
int_surface,
access,
construction,
service,
link,
layernotnull
FROM ( -- subselect that contains both roads and rail
SELECT
way,
'highway_' || highway AS feature, --only motorway to tertiary links are accepted later on
horse,
foot,
bicycle,
tracktype,
CASE WHEN surface IN ('unpaved', 'compacted', 'dirt', 'earth', 'fine_gravel', 'grass', 'grass_paver', 'gravel', 'ground',
'mud', 'pebblestone', 'salt', 'sand', 'woodchips', 'clay', 'ice', 'snow') THEN 'unpaved'
WHEN surface IN ('paved', 'asphalt', 'cobblestone', 'cobblestone:flattened', 'sett', 'concrete', 'concrete:lanes',
'concrete:plates', 'paving_stones', 'metal', 'wood', 'unhewn_cobblestone') THEN 'paved'
END AS int_surface,
CASE WHEN access IN ('destination') THEN 'destination'::text
WHEN access IN ('no', 'private') THEN 'no'::text
END AS access,
construction,
CASE
WHEN service IN ('parking_aisle', 'drive-through', 'driveway') THEN 'INT-minor'::text
ELSE 'INT-normal'::text
END AS service,
CASE
WHEN highway IN ('motorway_link', 'trunk_link', 'primary_link', 'secondary_link', 'tertiary_link') THEN 'yes'
ELSE 'no'
END AS link,
COALESCE(layer,0) AS layernotnull,
z_order
FROM planet_osm_line
WHERE (tunnel = 'yes' OR tunnel = 'building_passage' OR covered = 'yes')
AND highway IS NOT NULL -- end of road select
UNION ALL
SELECT
way,
'railway_' || (CASE WHEN railway = 'preserved' AND service IN ('spur', 'siding', 'yard') THEN 'INT-preserved-ssy'::text
WHEN (railway = 'rail' AND service IN ('spur', 'siding', 'yard')) THEN 'INT-spur-siding-yard'
WHEN (railway = 'tram' AND service IN ('spur', 'siding', 'yard')) THEN 'tram-service'
ELSE railway END) AS feature,
horse,
foot,
bicycle,
tracktype,
'null',
CASE
WHEN access IN ('destination') THEN 'destination'::text
WHEN access IN ('no', 'private') THEN 'no'::text
END AS access,
construction,
CASE WHEN service IN ('parking_aisle', 'drive-through', 'driveway') THEN 'INT-minor'::text ELSE 'INT-normal'::text END AS service,
'no' AS link,
COALESCE(layer,0) AS layernotnull,
z_order
FROM planet_osm_line
WHERE (tunnel = 'yes' OR tunnel = 'building_passage' OR covered = 'yes')
AND (railway NOT IN ('platform') AND railway IS NOT NULL) -- end of rail select
) AS features
ORDER BY
layernotnull,
z_order,
CASE WHEN substring(feature for 8) = 'railway_' THEN 2 ELSE 1 END,
CASE WHEN feature IN ('railway_INT-preserved-ssy', 'railway_INT-spur-siding-yard', 'railway_tram-service') THEN 0 ELSE 1 END,
CASE WHEN access IN ('no', 'private') THEN 0 WHEN access IN ('destination') THEN 1 ELSE 2 END,
CASE WHEN int_surface IN ('unpaved') THEN 0 ELSE 2 END
) AS tunnels
properties:
cache-features: true
group-by: layernotnull
minzoom: 10
- id: landuse-overlay
geometry: polygon
<<: *extents
Datasource:
<<: *osm2pgsql
table: |-
(SELECT
way,
landuse,
military,
way_area/NULLIF(POW(!scale_denominator!*0.001*0.28,2),0) AS way_pixels
FROM planet_osm_polygon
WHERE (landuse = 'military'
OR military = 'danger_area')
AND building IS NULL
) AS landuse_overlay
properties:
minzoom: 8
- id: tourism-boundary
geometry: polygon
<<: *extents
Datasource:
<<: *osm2pgsql
table: |-
(SELECT
way,
way_area/NULLIF(POW(!scale_denominator!*0.001*0.28,2),0) AS way_pixels,
tourism
FROM planet_osm_polygon
WHERE tourism = 'theme_park'
OR tourism = 'zoo'
) AS tourism_boundary
properties:
minzoom: 10
- id: barriers
geometry: linestring
<<: *extents
Datasource:
<<: *osm2pgsql
table: |-
(SELECT
way, COALESCE(historic, barrier) AS feature
FROM
(SELECT way,
('barrier_' || (CASE WHEN barrier IN ('chain', 'city_wall', 'ditch', 'fence', 'guard_rail',
'handrail', 'hedge', 'retaining_wall', 'wall') THEN barrier END)) AS barrier,
('historic_' || (CASE WHEN historic = 'citywalls' THEN historic END)) AS historic
FROM
(SELECT
way,
historic,
barrier,
waterway
FROM planet_osm_polygon
WHERE way && !bbox!
UNION ALL
SELECT
way,
historic,
barrier,
waterway
FROM planet_osm_line
WHERE way && !bbox!
) _
WHERE barrier IN ('chain', 'city_wall', 'ditch', 'fence', 'guard_rail',
'handrail', 'hedge', 'retaining_wall', 'wall')
OR historic = 'citywalls'
AND (waterway IS NULL OR waterway NOT IN ('river', 'canal', 'stream', 'drain', 'ditch'))
) AS features
) AS line_barriers
properties:
minzoom: 15
- id: cliffs
geometry: linestring
<<: *extents
Datasource:
<<: *osm2pgsql
table: |-
(SELECT
way, "natural", man_made
FROM planet_osm_line
WHERE "natural" IN ('arete', 'cliff', 'ridge') OR man_made = 'embankment'
) AS cliffs
properties:
cache-features: true
minzoom: 13
- id: ferry-routes
geometry: linestring
<<: *extents
Datasource:
<<: *osm2pgsql
table: |-
(SELECT
way
FROM planet_osm_line
WHERE route = 'ferry'
AND osm_id > 0
) AS ferry_routes
properties:
minzoom: 8
- id: turning-circle-casing
geometry: point
<<: *extents
Datasource:
<<: *osm2pgsql
table: &turning-circle_sql |-
(SELECT DISTINCT ON (p.way)
p.way AS way, l.highway AS int_tc_type,
CASE WHEN l.service IN ('parking_aisle', 'drive-through', 'driveway')
THEN 'INT-minor'::text
ELSE 'INT-normal'::text
END AS int_tc_service
FROM planet_osm_point p
JOIN planet_osm_line l
ON ST_DWithin(p.way, l.way, 0.1) -- Assumes Mercator
JOIN (VALUES
('tertiary', 1),
('unclassified', 2),
('residential', 3),
('living_street', 4),
('service', 5),
('track', 6)
) AS v (highway, prio)
ON v.highway=l.highway
WHERE p.highway = 'turning_circle'
OR p.highway = 'turning_loop'
ORDER BY p.way, v.prio
) AS turning_circle_sql
properties:
minzoom: 15
- id: highway-area-casing
geometry: polygon
<<: *extents
Datasource:
<<: *osm2pgsql
table: |-
(SELECT
way,
COALESCE((
'highway_' || (CASE WHEN highway IN ('pedestrian', 'footway', 'service', 'platform') THEN highway END)),
('railway_' || (CASE WHEN (railway IN ('platform')
AND (tags->'location' NOT IN ('underground') OR (tags->'location') IS NULL)
AND (tunnel NOT IN ('yes', 'building_passage') OR tunnel IS NULL)
AND (covered NOT IN ('yes') OR covered IS NULL))
THEN railway END))
) AS feature
FROM planet_osm_polygon
WHERE highway IN ('pedestrian', 'footway', 'service', 'platform')
OR (railway IN ('platform')
AND (tags->'location' NOT IN ('underground') OR (tags->'location') IS NULL)
AND (tunnel NOT IN ('yes', 'building_passage') OR tunnel IS NULL)
AND (covered NOT IN ('yes') OR covered IS NULL))
ORDER BY COALESCE(layer,0), way_area DESC
) AS highway_area_casing
properties:
minzoom: 14
- id: roads-casing
geometry: linestring
<<: *extents
Datasource:
<<: *osm2pgsql
# This is one of the most complex layers, so it bears explaining in some detail
# It is necessary to
# - Have roads and railways in the same layer to get ordering right
# - Return two linestrings for ways which are both a road and railway
table: &roads_sql |-
(SELECT
way,
(CASE WHEN feature IN ('highway_motorway_link', 'highway_trunk_link', 'highway_primary_link', 'highway_secondary_link', 'highway_tertiary_link') THEN substr(feature, 0, length(feature)-4) ELSE feature END) AS feature,
horse,
foot,
bicycle,
tracktype,
int_surface,
access,
construction,
service,
link,
layernotnull
FROM ( -- subselect that contains both roads and rail/aero
SELECT
way,
('highway_' || highway) AS feature, --only motorway to tertiary links are accepted later on
horse,
foot,
bicycle,
tracktype,
CASE WHEN surface IN ('unpaved', 'compacted', 'dirt', 'earth', 'fine_gravel', 'grass', 'grass_paver', 'gravel', 'ground',
'mud', 'pebblestone', 'salt', 'sand', 'woodchips', 'clay', 'ice', 'snow') THEN 'unpaved'
WHEN surface IN ('paved', 'asphalt', 'cobblestone', 'cobblestone:flattened', 'sett', 'concrete', 'concrete:lanes',
'concrete:plates', 'paving_stones', 'metal', 'wood', 'unhewn_cobblestone') THEN 'paved'
END AS int_surface,
CASE WHEN access IN ('destination') THEN 'destination'::text
WHEN access IN ('no', 'private') THEN 'no'::text
END AS access,
construction,
CASE
WHEN service IN ('parking_aisle', 'drive-through', 'driveway') OR leisure IN ('slipway') THEN 'INT-minor'::text
ELSE 'INT-normal'::text
END AS service,
CASE
WHEN highway IN ('motorway_link', 'trunk_link', 'primary_link', 'secondary_link', 'tertiary_link') THEN 'yes'
ELSE 'no'
END AS link,
COALESCE(layer,0) AS layernotnull,
osm_id,
z_order
FROM planet_osm_line
WHERE (tunnel IS NULL OR NOT tunnel IN ('yes', 'building_passage'))
AND (covered IS NULL OR NOT covered = 'yes')
AND (bridge IS NULL OR NOT bridge IN ('yes', 'boardwalk', 'cantilever', 'covered', 'low_water_crossing', 'movable', 'trestle', 'viaduct'))
AND highway IS NOT NULL -- end of road select
UNION ALL
SELECT
way,
('railway_' || (CASE WHEN railway = 'preserved' AND service IN ('spur', 'siding', 'yard') THEN 'INT-preserved-ssy'::text
WHEN (railway = 'rail' AND service IN ('spur', 'siding', 'yard')) THEN 'INT-spur-siding-yard'
WHEN (railway = 'tram' AND service IN ('spur', 'siding', 'yard')) THEN 'tram-service'
ELSE railway END)) AS feature,
horse,
foot,
bicycle,
tracktype,
'null',
CASE
WHEN access IN ('destination') THEN 'destination'::text
WHEN access IN ('no', 'private') THEN 'no'::text
END AS access,
construction,
CASE WHEN service IN ('parking_aisle', 'drive-through', 'driveway') OR leisure IN ('slipway') THEN 'INT-minor'::text ELSE 'INT-normal'::text END AS service,
'no' AS link,
COALESCE(layer,0) AS layernotnull,
osm_id,
z_order
FROM planet_osm_line
WHERE (tunnel IS NULL OR NOT tunnel IN ('yes', 'building_passage'))
AND (covered IS NULL OR NOT covered = 'yes')
AND (bridge IS NULL OR NOT bridge IN ('yes', 'boardwalk', 'cantilever', 'covered', 'low_water_crossing', 'movable', 'trestle', 'viaduct'))
AND railway IS NOT NULL -- end of rail select
) AS features
ORDER BY
layernotnull,
z_order,
CASE WHEN substring(feature for 8) = 'railway_' THEN 2 ELSE 1 END,
CASE WHEN feature IN ('railway_INT-preserved-ssy', 'railway_INT-spur-siding-yard', 'railway_tram-service') THEN 0 ELSE 1 END,
CASE WHEN access IN ('no', 'private') THEN 0 WHEN access IN ('destination') THEN 1 ELSE 2 END,
CASE WHEN int_surface IN ('unpaved') THEN 0 ELSE 2 END,
osm_id
) AS roads_sql
properties:
cache-features: true
minzoom: 10
- id: highway-area-fill
# FIXME: No geometry?
<<: *extents
Datasource:
<<: *osm2pgsql
table: |-
(SELECT
way,
COALESCE(
('highway_' || (CASE WHEN highway IN ('pedestrian', 'footway', 'service', 'living_street',
'platform', 'services') THEN highway END)),
('railway_' || (CASE WHEN (railway IN ('platform')
AND (tags->'location' NOT IN ('underground') OR (tags->'location') IS NULL)
AND (tunnel NOT IN ('yes', 'building_passage') OR tunnel IS NULL)
AND (covered NOT IN ('yes') OR covered IS NULL))
THEN railway END)),
(('aeroway_' || CASE WHEN aeroway IN ('runway', 'taxiway', 'helipad') THEN aeroway END))
) AS feature
FROM planet_osm_polygon
WHERE highway IN ('pedestrian', 'footway', 'service', 'living_street', 'platform', 'services')
OR (railway IN ('platform')
AND (tags->'location' NOT IN ('underground') OR (tags->'location') IS NULL)
AND (tunnel NOT IN ('yes', 'building_passage') OR tunnel IS NULL)
AND (covered NOT IN ('yes') OR covered IS NULL))
OR aeroway IN ('runway', 'taxiway', 'helipad')
ORDER BY COALESCE(layer,0), way_area desc
) AS highway_area_fill
properties:
minzoom: 14
- id: roads-fill
geometry: linestring
<<: *extents
Datasource:
<<: *osm2pgsql
table: *roads_sql
properties:
cache-features: true
minzoom: 10
- id: turning-circle-fill
geometry: point
<<: *extents
Datasource:
<<: *osm2pgsql
table: *turning-circle_sql
properties:
minzoom: 15
- id: aerialways
geometry: linestring
<<: *extents
Datasource:
<<: *osm2pgsql
table: |-
(SELECT
way,
aerialway,
man_made,
tags->'substance' AS substance
FROM planet_osm_line
WHERE aerialway IS NOT NULL
OR (man_made = 'pipeline'
AND tags-> 'location' IN ('overground', 'overhead', 'surface', 'outdoor')
OR bridge IN ('yes', 'aqueduct', 'cantilever', 'covered', 'trestle', 'viaduct'))
OR (man_made = 'goods_conveyor'
AND (tags->'location' NOT IN ('underground') OR (tags->'location') IS NULL)
AND (tunnel NOT IN ('yes') OR tunnel IS NULL))
ORDER BY
CASE
WHEN man_made IN ('goods_conveyor', 'pipeline') THEN 1
WHEN tags-> 'location' = 'overhead' THEN 2
WHEN bridge IS NOT NULL THEN 3
WHEN aerialway IS NOT NULL THEN 4
END
) AS aerialways
properties:
minzoom: 12
- id: roads-low-zoom
geometry: linestring
<<: *extents
Datasource:
<<: *osm2pgsql
table: |-
(SELECT
way,
COALESCE(
('highway_' || (CASE WHEN highway IN ('motorway_link', 'trunk_link', 'primary_link', 'secondary_link', 'tertiary_link')
THEN substr(highway, 0, length(highway)-4) ELSE highway end)),
('railway_' || (CASE WHEN (railway = 'rail' AND service IN ('spur', 'siding', 'yard')) THEN 'INT-spur-siding-yard'
WHEN railway IN ('rail', 'tram', 'light_rail', 'funicular', 'narrow_gauge') THEN railway END))
) AS feature,
CASE WHEN tunnel = 'yes' OR tunnel = 'building_passage' OR covered = 'yes' THEN 'yes' ELSE 'no' END AS int_tunnel,
CASE WHEN highway IN ('motorway_link', 'trunk_link', 'primary_link', 'secondary_link', 'tertiary_link') THEN 'yes' ELSE 'no' END AS link,
CASE WHEN surface IN ('unpaved', 'compacted', 'dirt', 'earth', 'fine_gravel', 'grass', 'grass_paver', 'gravel', 'ground',
'mud', 'pebblestone', 'salt', 'sand', 'woodchips', 'clay', 'ice', 'snow') THEN 'unpaved'
WHEN surface IN ('paved', 'asphalt', 'cobblestone', 'cobblestone:flattened', 'sett', 'concrete', 'concrete:lanes',
'concrete:plates', 'paving_stones', 'metal', 'wood', 'unhewn_cobblestone') THEN 'paved'
END AS int_surface
FROM planet_osm_roads
WHERE highway IS NOT NULL
OR (railway IS NOT NULL AND railway != 'preserved'
AND (service IS NULL OR service NOT IN ('spur', 'siding', 'yard')))
ORDER BY
z_order
) AS roads_low_zoom
properties:
cache-features: true
minzoom: 6
maxzoom: 9
- id: waterway-bridges
geometry: linestring
<<: *extents
Datasource:
<<: *osm2pgsql
table: |-
(SELECT
way,
waterway,
CASE WHEN tags->'intermittent' IN ('yes')
OR tags->'seasonal' IN ('yes', 'spring', 'summer', 'autumn', 'winter', 'wet_season', 'dry_season')
THEN 'yes' ELSE 'no' END AS int_intermittent,
CASE WHEN tunnel IN ('yes', 'culvert')
OR waterway = 'canal' AND tunnel = 'flooded'
THEN 'yes' ELSE 'no' END AS int_tunnel,
'yes' AS bridge
FROM planet_osm_line
WHERE waterway IN ('river', 'canal', 'stream', 'drain', 'ditch')
AND bridge IN ('yes', 'aqueduct')
ORDER BY COALESCE(layer,0)
) AS waterway_bridges
properties:
minzoom: 12
- id: bridges
geometry: linestring
<<: *extents
Datasource:
<<: *osm2pgsql
table: |-
(SELECT
way,
(CASE WHEN feature IN ('highway_motorway_link', 'highway_trunk_link', 'highway_primary_link', 'highway_secondary_link', 'highway_tertiary_link') THEN substr(feature, 0, length(feature)-4) ELSE feature END) AS feature,
horse,
foot,
bicycle,
tracktype,
int_surface,
access,
construction,
service,
link,
layernotnull
FROM ( -- subselect that contains both roads and rail/aero
SELECT
way,
'highway_' || highway AS feature, --only motorway to tertiary links are accepted later on
horse,
foot,
bicycle,
tracktype,
CASE WHEN surface IN ('unpaved', 'compacted', 'dirt', 'earth', 'fine_gravel', 'grass', 'grass_paver', 'gravel', 'ground',
'mud', 'pebblestone', 'salt', 'sand', 'woodchips', 'clay', 'ice', 'snow') THEN 'unpaved'
WHEN surface IN ('paved', 'asphalt', 'cobblestone', 'cobblestone:flattened', 'sett', 'concrete', 'concrete:lanes',
'concrete:plates', 'paving_stones', 'metal', 'wood', 'unhewn_cobblestone') THEN 'paved'
END AS int_surface,
CASE WHEN access IN ('destination') THEN 'destination'::text
WHEN access IN ('no', 'private') THEN 'no'::text
END AS access,
construction,
CASE
WHEN service IN ('parking_aisle', 'drive-through', 'driveway') THEN 'INT-minor'::text
ELSE 'INT-normal'::text
END AS service,
CASE
WHEN highway IN ('motorway_link', 'trunk_link', 'primary_link', 'secondary_link', 'tertiary_link') THEN 'yes'
ELSE 'no'
END AS link,
COALESCE(layer,0) AS layernotnull,
z_order
FROM planet_osm_line
WHERE bridge IN ('yes', 'boardwalk', 'cantilever', 'covered', 'low_water_crossing', 'movable', 'trestle', 'viaduct')
AND highway IS NOT NULL -- end of road select
UNION ALL
SELECT
way,
'railway_' || (CASE WHEN railway = 'preserved' AND service IN ('spur', 'siding', 'yard') THEN 'INT-preserved-ssy'::text
WHEN (railway = 'rail' AND service IN ('spur', 'siding', 'yard')) THEN 'INT-spur-siding-yard'
WHEN (railway = 'tram' AND service IN ('spur', 'siding', 'yard')) THEN 'tram-service'
ELSE railway END) AS feature,
horse,
foot,
bicycle,
tracktype,
'null',
CASE
WHEN access IN ('destination') THEN 'destination'::text
WHEN access IN ('no', 'private') THEN 'no'::text
END AS access,
construction,
CASE WHEN service IN ('parking_aisle', 'drive-through', 'driveway') THEN 'INT-minor'::text ELSE 'INT-normal'::text END AS service,
'no' AS link,
COALESCE(layer,0) AS layernotnull,
z_order
FROM planet_osm_line
WHERE bridge IN ('yes', 'boardwalk', 'cantilever', 'covered', 'low_water_crossing', 'movable', 'trestle', 'viaduct')
AND railway IS NOT NULL -- end of rail select
) AS features
ORDER BY
layernotnull,
z_order,
CASE WHEN substring(feature for 8) = 'railway_' THEN 2 ELSE 1 END,
CASE WHEN feature IN ('railway_INT-preserved-ssy', 'railway_INT-spur-siding-yard', 'railway_tram-service') THEN 0 ELSE 1 END,
CASE WHEN access IN ('no', 'private') THEN 0 WHEN access IN ('destination') THEN 1 ELSE 2 END,
CASE WHEN int_surface IN ('unpaved') THEN 0 ELSE 2 END
) AS bridges
properties:
cache-features: true
group-by: layernotnull
minzoom: 10
- id: guideways
geometry: linestring
<<: *extents
Datasource:
<<: *osm2pgsql
table: |-
(SELECT
way
FROM planet_osm_line