project.mml

changeset 0
b0eb3af2f9ee
child 2
8d4148a8ded4
equal deleted inserted replaced
-1:000000000000 0:b0eb3af2f9ee
1 scale: 1
2 metatile: 2
3 name:
4 description: A general-purpose OpenStreetMap mapnik style, in CartoCSS
5 bounds: &world
6 - -180
7 - -85.05112877980659
8 - 180
9 - 85.05112877980659
10 center:
11 - 0
12 - 0
13 - 4
14 format: png
15 interactivity: false
16 minzoom: 0
17 maxzoom: 22
18 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"
19
20 # Various parts to be included later on
21 _parts:
22 # Extents are used for tilemill, and don't actually make it to the generated XML
23 extents: &extents
24 extent: *world
25 srs-name: "900913"
26 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"
27 osm2pgsql: &osm2pgsql
28 type: "postgis"
29 dbname: "gis"
30 key_field: ""
31 geometry_field: "way"
32 extent: "-20037508,-20037508,20037508,20037508"
33
34 Stylesheet:
35 - style/style.mss
36 - style/roads.mss
37 - style/buildings.mss
38 - style/places.mss
39 - style/shapefiles.mss
40 - style/amenity.mss
41 - style/roadref.mss
42 Layer:
43 - id: landcover
44 geometry: polygon
45 <<: *extents
46 Datasource:
47 <<: *osm2pgsql
48 table: |-
49 (SELECT
50 way,
51 (CASE WHEN
52 "landuse" IN ('grass', 'meadow', 'recreation_ground')
53 OR ("leisure" IN ('park', 'playground', 'arena', 'stadium', 'sports_centre') AND landuse IS NULL)
54 OR "natural" = 'scrub'
55 THEN 'grass'
56 ELSE CASE WHEN ("landuse" IN ('commercial', 'retail') OR "amenity" IN ('bus_station', 'ferry_terminal'))
57 THEN 'commercial'
58 ELSE CASE WHEN ("natural" = 'wood' OR "landuse" = 'forest')
59 THEN 'forest'
60 ELSE CASE WHEN ("natural" = 'water' OR "landuse" IN ('reservoir'))
61 THEN 'water'
62 ELSE CASE WHEN ("landuse" IN ('religious', 'cemetery') OR "amenity" = 'grave_yard')
63 THEN 'religious'
64 ELSE CASE WHEN ("landuse" = 'railway')
65 THEN 'industrial'
66 ELSE "landuse"
67 END
68 END
69 END
70 END
71 END
72 END) AS feature,
73 way_area/NULLIF(POW(!scale_denominator!*0.001*0.28,2),0) AS way_pixels,
74 way_area
75 FROM planet_osm_polygon
76 WHERE (landuse IN ('forest', 'farmland', 'residential', 'commercial', 'retail', 'industrial', 'meadow', 'grass', 'vineyard', 'orchard', 'religious', 'railway', 'construction', 'cemetery')
77 OR "natural" IN ('wood', 'wetland', 'mud', 'sand', 'scree', 'shingle', 'bare_rock', 'heath', 'grassland', 'scrub', 'water'))
78 OR "leisure" IN ('park', 'playground', 'arena', 'stadium', 'sports_centre')
79 OR "amenity" IN ('bus_station', 'ferry_terminal', 'grave_yard')
80 AND way_area > 0.01*!pixel_width!::real*!pixel_height!::real
81 AND building IS NULL
82 ORDER BY way_area DESC, feature
83 ) AS landcover
84 properties:
85 cache-features: true
86 minzoom: 5
87 - id: inland-water
88 geometry: polygon
89 <<: *extents
90 Datasource:
91 <<: *osm2pgsql
92 table: |-
93 (SELECT
94 way
95 FROM planet_osm_polygon
96 WHERE ("natural" = 'water' OR landuse IN ('reservoir', 'basin') OR waterway = 'riverbank')
97 ) AS landcover
98 properties:
99 cache-features: true
100 minzoom: 5
101 - id: ocean-lz
102 geometry: polygon
103 <<: *extents
104 Datasource:
105 <<: *osm2pgsql
106 table: |-
107 (SELECT
108 way
109 FROM simplified_water_polygons
110 ) AS ocean_lz
111 properties:
112 maxzoom: 9
113 - id: civic-services
114 geometry: polygon
115 <<: *extents
116 Datasource:
117 <<: *osm2pgsql
118 table: |-
119 (SELECT
120 way
121 FROM planet_osm_polygon
122 WHERE ("amenity" IN ('hospital', 'community_centre', 'fire_station', 'school', 'university', 'kindergarten', 'childcare', 'social_facility') OR landuse IN ('civic_services', 'civic_admin'))
123 ) AS civic_services
124 properties:
125 cache-features: true
126 minzoom: 5
127 - id: aerodrome
128 geometry: polygon
129 Datasource:
130 <<: *osm2pgsql
131 table: |-
132 (SELECT
133 way
134 FROM planet_osm_polygon
135 WHERE aeroway = 'aerodrome'
136 ) AS aerodrome
137 properties:
138 minzoom: 10
139 - id: runway
140 geometry: line
141 Datasource:
142 <<: *osm2pgsql
143 table: |-
144 (SELECT
145 way,
146 aeroway,
147 ref
148 FROM planet_osm_line
149 WHERE aeroway IN ('runway', 'taxiway')
150 ) AS aerodrome
151 properties:
152 minzoom: 10
153 - id: ocean
154 geometry: polygon
155 <<: *extents
156 Datasource:
157 <<: *osm2pgsql
158 table: |-
159 (SELECT
160 way
161 FROM water_polygons
162 ) AS ocean
163 properties:
164 minzoom: 10
165 - id: coastline
166 geometry: line
167 <<: *extents
168 Datasource:
169 <<: *osm2pgsql
170 table: |-
171 (SELECT way FROM planet_osm_line WHERE "natural" = 'coastline') AS coastlines
172 properties:
173 minzoom: 12
174 - id: buildings
175 geometry: polygon
176 <<: *extents
177 Datasource:
178 <<: *osm2pgsql
179 table: |-
180 (SELECT
181 way,
182 building
183 FROM planet_osm_polygon
184 WHERE building IS NOT NULL
185 ) AS landcover
186 properties:
187 cache-features: true
188 minzoom: 14
189 - id: road-casing-low-zoom
190 geometry: line
191 Datasource:
192 <<: *osm2pgsql
193 table: &road_low_zoom_sql |-
194 (SELECT
195 way,
196 highway
197 FROM planet_osm_roads
198 WHERE "highway" IN ('primary', 'trunk')
199 AND (tags->"access" IS NULL OR tags->"access" NOT IN ('private', 'no'))
200 ORDER BY
201 CASE
202 WHEN highway = 'trunk' THEN 37
203 WHEN highway = 'primary' THEN 36
204 END ASC NULLS LAST
205 ) AS road
206 properties:
207 minzoom: 4
208 maxzoom: 9
209 - id: road-low-zoom
210 geometry: line
211 Datasource:
212 <<: *osm2pgsql
213 table: *road_low_zoom_sql
214 properties:
215 minzoom: 4
216 maxzoom: 9
217 - id: road-casing-layer-n1
218 geometry: line
219 Datasource:
220 <<: *osm2pgsql
221 table: &road_sql |-
222 (SELECT
223 way,
224 (CASE WHEN "highway" IN ('motorway', 'trunk', 'primary', 'secondary', 'tertiary')
225 THEN 'road_major'
226 ELSE CASE WHEN "highway" IN ('motorway_link', 'trunk_link', 'primary_link', 'secondary_link', 'tertiary_link', 'residential', 'unclassified', 'living_street')
227 THEN 'road_minor'
228 ELSE CASE WHEN "highway" IN ('path', 'footway', 'cycleway', 'track', 'steps', 'pedestrian', 'platform')
229 THEN 'road_path'
230 ELSE 'road_' || "highway"
231 END
232 END
233 END) AS feature,
234 name,
235 minority_name,
236 highway,
237 COALESCE(layer::integer, 0) AS layer
238 FROM planet_osm_line
239 WHERE "highway" IS NOT NULL
240 AND (tags->"access" IS NULL OR tags->"access" NOT IN ('private', 'no'))
241 ORDER BY
242 CASE
243 WHEN highway = 'motorway' THEN 38
244 WHEN highway = 'trunk' THEN 37
245 WHEN highway = 'primary' THEN 36
246 WHEN highway = 'secondary' THEN 35
247 WHEN highway = 'tertiary' THEN 34
248
249 WHEN highway = 'motorway_link' THEN 28
250 WHEN highway = 'trunk_link' THEN 27
251 WHEN highway = 'primary_link' THEN 26
252 WHEN highway = 'secondary_link' THEN 25
253 WHEN highway = 'tertiary_link' THEN 24
254
255 WHEN highway = 'residential' THEN 10
256 WHEN highway = 'unclassified' THEN 10
257 WHEN highway = 'path' THEN 8
258 WHEN highway = 'footway' THEN 8
259 WHEN highway = 'cycleway' THEN 8
260 WHEN highway = 'service' THEN 5
261
262 WHEN highway = 'runway' THEN 6
263 WHEN highway = 'taxiway' THEN 5
264 END ASC NULLS LAST
265 ) AS road
266 properties:
267 minzoom: 10
268 - id: road-layer-n1
269 geometry: line
270 Datasource:
271 <<: *osm2pgsql
272 table: *road_sql
273 properties:
274 minzoom: 10
275 - id: rail-layer-n1
276 geometry: linestring
277 Datasource:
278 <<: *osm2pgsql
279 table: &rail_sql |-
280 (SELECT
281 way,
282 name,
283 minority_name,
284 service,
285 COALESCE(layer::integer, 0) AS layer,
286 tags->'electrified' AS electrified,
287 tags->'usage' AS usage
288 FROM planet_osm_line
289 WHERE "railway" = 'rail'
290 ORDER BY
291 CASE
292 WHEN service IS NULL THEN 20
293 WHEN service IS NOT NULL THEN 30
294 END DESC NULLS LAST
295 ) AS rail
296 - id: road-casing
297 geometry: line
298 Datasource:
299 <<: *osm2pgsql
300 table: *road_sql
301 properties:
302 minzoom: 12
303 - id: road
304 geometry: line
305 Datasource:
306 <<: *osm2pgsql
307 table: *road_sql
308 properties:
309 minzoom: 12
310 - id: rail
311 geometry: linestring
312 Datasource:
313 <<: *osm2pgsql
314 table: *rail_sql
315 - id: bridge-area
316 geometry: polygon
317 Datasource:
318 <<: *osm2pgsql
319 table: &bridge_area_sql |-
320 (SELECT
321 way,
322 name,
323 bilingual_name,
324 '0' AS natural
325 FROM planet_osm_polygon
326 WHERE "man_made" = 'bridge'
327 ) AS bridge_area
328 properties:
329 minzoom: 12
330 - id: road-casing-layer-1
331 geometry: line
332 Datasource:
333 <<: *osm2pgsql
334 table: *road_sql
335 properties:
336 minzoom: 12
337 - id: road-layer-1
338 geometry: line
339 Datasource:
340 <<: *osm2pgsql
341 table: *road_sql
342 properties:
343 minzoom: 12
344 - id: rail-layer-1
345 geometry: linestring
346 Datasource:
347 <<: *osm2pgsql
348 table: *rail_sql
349 - id: place-major
350 geometry: point
351 Datasource:
352 <<: *osm2pgsql
353 table: |-
354 (SELECT
355 way,
356 name,
357 bilingual_name,
358 place
359 FROM planet_osm_point
360 WHERE "place" IN ('city', 'town')
361 ) AS place_major
362 properties:
363 minzoom: 6
364 maxzoom: 15
365 - id: train-stations
366 geometry: point
367 Datasource:
368 <<: *osm2pgsql
369 table: |-
370 (SELECT
371 way,
372 name,
373 bilingual_name,
374 railway,
375 tags->'railway:ref' AS ref
376 FROM planet_osm_point
377 WHERE "railway" IN ('station', 'halt')
378 ) AS train_stations
379 - id: place-medium
380 geometry: point
381 Datasource:
382 <<: *osm2pgsql
383 table: |-
384 (SELECT
385 way,
386 name,
387 bilingual_name,
388 place
389 FROM planet_osm_point
390 WHERE "place" IN ('suburb', 'borough', 'village')
391 ) AS place_medium
392 properties:
393 minzoom: 12
394 maxzoom: 17
395 - id: stations
396 geometry: point
397 Datasource:
398 <<: *osm2pgsql
399 table: |-
400 (SELECT
401 way,
402 name,
403 bilingual_name,
404 COALESCE(
405 'amenity_' || CASE WHEN amenity IN ('bus_station') THEN amenity END
406 ) AS feature
407 FROM
408 (
409 SELECT
410 ST_PointOnSurface(way) AS way,
411 name,
412 bilingual_name,
413 amenity
414 FROM planet_osm_polygon
415 WHERE way && !bbox!
416 AND way_area < 768000*POW(!scale_denominator!*0.001*0.28,2)
417 UNION ALL
418 SELECT
419 way,
420 bilingual_name,
421 name,
422 amenity
423 FROM planet_osm_point
424 WHERE way && !bbox!
425 ) AS station_subquery
426 WHERE (
427 "amenity" IN ('bus_station')
428 )
429 ) AS stations
430 properties:
431 minzoom: 13
432 - id: place-natural
433 geometry: polygon
434 Datasource:
435 <<: *osm2pgsql
436 table: |-
437 (SELECT
438 way,
439 name,
440 bilingual_name,
441 place,
442 way_area/NULLIF(POW(!scale_denominator!*0.001*0.28,2),0) AS way_pixels,
443 way_area
444 FROM planet_osm_polygon
445 WHERE (
446 "place" IN ('island', 'peninsula', 'isthmus', 'islet')
447 OR "natural" IN ('peak', 'hill', 'fell')
448 )
449 ) AS place_natural
450 properties:
451 minzoom: 8
452 - id: place-minor
453 geometry: point
454 Datasource:
455 <<: *osm2pgsql
456 table: |-
457 (SELECT
458 way,
459 name,
460 bilingual_name,
461 (CASE WHEN ("place" = 'locality' OR "natural" IN ('peak', 'hill', 'fell')) THEN 1 ELSE 0 END) AS natural
462 FROM planet_osm_point
463 WHERE (
464 "place" IN ('neighbourhood', 'quarter', 'farm', 'hamlet', 'locality')
465 OR "natural" IN ('peak', 'hill', 'fell')
466 )
467 ) AS place_medium
468 properties:
469 minzoom: 15
470 - id: train-sites
471 geometry: point
472 Datasource:
473 <<: *osm2pgsql
474 table: |-
475 (SELECT
476 way,
477 name,
478 bilingual_name,
479 railway,
480 tags->'railway:ref' AS ref
481 FROM planet_osm_point
482 WHERE "railway" IN ('site', 'yard', 'crossover', 'junction', 'technical_station', 'service_station')
483 ) AS train_stations
484 - id: poi-name
485 geometry: polygon
486 Datasource:
487 <<: *osm2pgsql
488 table: |-
489 (SELECT
490 way,
491 name,
492 bilingual_name,
493 0 as natural
494 FROM
495 (
496 SELECT
497 ST_PointOnSurface(way) AS way,
498 name,
499 bilingual_name,
500 man_made,
501 building,
502 leisure,
503 amenity,
504 historic
505 FROM planet_osm_polygon
506 WHERE way && !bbox!
507 AND way_area < 768000*POW(!scale_denominator!*0.001*0.28,2)
508 UNION ALL
509 SELECT
510 way,
511 name,
512 bilingual_name,
513 building,
514 man_made,
515 leisure,
516 amenity,
517 historic
518 FROM planet_osm_point
519 WHERE way && !bbox!
520 ) AS poi_name_subquery
521 WHERE (
522 "man_made" IN ('bridge')
523 OR "amenity" IN ('hospital', 'university', 'exhibition_centre')
524 OR "leisure" IN ('stadium')
525 OR "historic" IN ('castle')
526 )
527 ) AS poi_name
528 properties:
529 minzoom: 15
530 - id: poi-name-medium
531 geometry: polygon
532 Datasource:
533 <<: *osm2pgsql
534 table: |-
535 (SELECT
536 way,
537 name,
538 bilingual_name,
539 shop,
540 0 as natural
541 FROM
542 (
543 SELECT
544 ST_PointOnSurface(way) AS way,
545 name,
546 bilingual_name,
547 amenity,
548 shop
549 FROM planet_osm_polygon
550 WHERE way && !bbox!
551 AND way_area < 768000*POW(!scale_denominator!*0.001*0.28,2)
552 UNION ALL
553 SELECT
554 way,
555 name,
556 bilingual_name,
557 shop,
558 amenity
559 FROM planet_osm_point
560 WHERE way && !bbox!
561 ) AS poi_name_subquery
562 WHERE (
563 "amenity" IN ('school', 'marketplace', 'fire_station')
564 OR "shop" = 'mall'
565 )
566 ) AS poi_name_medium
567 properties:
568 minzoom: 16
569 - id: aerodrome-name
570 geometry: point
571 Datasource:
572 <<: *osm2pgsql
573 table: |-
574 (SELECT
575 way,
576 aeroway,
577 name,
578 bilingual_name,
579 ref
580 FROM
581 (
582 SELECT
583 ST_PointOnSurface(way) AS way,
584 aeroway,
585 name,
586 bilingual_name,
587 COALESCE(tags->'iata', tags->'icao', ref) as ref
588 FROM planet_osm_polygon
589 WHERE way && !bbox!
590 AND way_area < 768000*POW(!scale_denominator!*0.001*0.28,2)
591 UNION ALL
592 SELECT
593 way,
594 aeroway,
595 name,
596 bilingual_name,
597 COALESCE(tags->'iata', tags->'icao', ref) as ref
598 FROM planet_osm_point
599 WHERE way && !bbox!
600 ) AS station_subquery
601 WHERE "aeroway" = 'aerodrome'
602 ) AS stations
603 properties:
604 minzoom: 9
605
606 - id: poi-name-minor
607 geometry: polygon
608 Datasource:
609 <<: *osm2pgsql
610 table: |-
611 (SELECT
612 way,
613 name,
614 bilingual_name,
615 0 as natural
616 FROM
617 (
618 SELECT
619 ST_PointOnSurface(way) AS way,
620 name,
621 bilingual_name,
622 highway,
623 area,
624 amenity
625 FROM planet_osm_polygon
626 WHERE way && !bbox!
627 AND way_area < 768000*POW(!scale_denominator!*0.001*0.28,2)
628 UNION ALL
629 SELECT
630 way,
631 name,
632 bilingual_name,
633 highway,
634 NULL as area,
635 amenity
636 FROM planet_osm_point
637 WHERE way && !bbox!
638 ) AS poi_name_subquery
639 WHERE (
640 "amenity" IN ('kindergarten', 'social_facility')
641 OR ("highway" IN ('footway', 'pedestrian') AND area = 'yes')
642 )
643 ) AS poi_name_medium
644 properties:
645 minzoom: 17
646 - id: train-milestones
647 geometry: point
648 Datasource:
649 <<: *osm2pgsql
650 table: |-
651 (SELECT
652 way,
653 tags->'railway:position' AS position,
654 railway
655 FROM planet_osm_point
656 WHERE "railway" = 'milestone'
657 ) AS train_milestones
658 - id: road-text
659 geometry: line
660 Datasource:
661 <<: *osm2pgsql
662 table: *road_sql
663 properties:
664 minzoom: 14
665 - id: road-text-minority
666 geometry: line
667 Datasource:
668 <<: *osm2pgsql
669 table: *road_sql
670 properties:
671 minzoom: 14
672 - id: roads-text-ref
673 geometry: linestring
674 <<: *extents
675 Datasource:
676 <<: *osm2pgsql
677 table: &road-ref-sql |-
678 (SELECT
679 way,
680 highway,
681 refs,
682 ref_1,
683 ref_2,
684 ref_3,
685 ref_4,
686 ref_5,
687 ref_6,
688 ref_class_1,
689 ref_class_2,
690 ref_class_3,
691 ref_class_4,
692 ref_class_5,
693 ref_class_6,
694 ref_length_1,
695 ref_length_2,
696 ref_length_3,
697 ref_length_4,
698 ref_length_5,
699 ref_length_6
700 FROM (
701 SELECT
702 osm_id,
703 way,
704 highway,
705 array_to_string(refs, E'\n') AS refs,
706 refs[1] as ref_1,
707 refs[2] as ref_2,
708 refs[3] as ref_3,
709 refs[4] as ref_4,
710 refs[5] as ref_5,
711 refs[6] as ref_6,
712 ref_classes[1] as ref_class_1,
713 ref_classes[2] as ref_class_2,
714 ref_classes[3] as ref_class_3,
715 ref_classes[4] as ref_class_4,
716 ref_classes[5] as ref_class_5,
717 ref_classes[6] as ref_class_6,
718 ref_widths[1] as ref_length_1,
719 ref_widths[2] as ref_length_2,
720 ref_widths[3] as ref_length_3,
721 ref_widths[4] as ref_length_4,
722 ref_widths[5] as ref_length_5,
723 ref_widths[6] as ref_length_6
724 FROM (
725 SELECT
726 osm_id,
727 way,
728 highway,
729 string_to_array(ref, ';') AS refs,
730 string_to_array(ref_class, ';') AS ref_classes,
731 string_to_array(ref_width, ';') AS ref_widths
732 FROM planet_osm_line
733 WHERE (highway IN ('motorway', 'trunk', 'primary', 'secondary', 'tertiary'))
734 AND ref IS NOT NULL
735 ) AS p) AS q
736 ORDER BY
737 CASE
738 WHEN highway = 'motorway' THEN 38
739 WHEN highway = 'trunk' THEN 37
740 WHEN highway = 'primary' THEN 36
741 WHEN highway = 'secondary' THEN 35
742 WHEN highway = 'tertiary' THEN 34
743 WHEN highway = 'taxiway' THEN 5
744 END DESC NULLS LAST,
745 refs,
746 osm_id
747 ) AS roads_text_ref
748 properties:
749 minzoom: 8
750 - id: roads-text-ref2
751 geometry: linestring
752 <<: *extents
753 Datasource:
754 <<: *osm2pgsql
755 table: *road-ref-sql
756 properties:
757 minzoom: 10
758 - id: roads-text-ref3
759 geometry: linestring
760 <<: *extents
761 Datasource:
762 <<: *osm2pgsql
763 table: *road-ref-sql
764 properties:
765 minzoom: 10
766 - id: roads-text-ref4
767 geometry: linestring
768 <<: *extents
769 Datasource:
770 <<: *osm2pgsql
771 table: *road-ref-sql
772 properties:
773 minzoom: 10
774 - id: roads-text-ref5
775 geometry: linestring
776 <<: *extents
777 Datasource:
778 <<: *osm2pgsql
779 table: *road-ref-sql
780 properties:
781 minzoom: 10
782 - id: roads-text-ref6
783 geometry: linestring
784 <<: *extents
785 Datasource:
786 <<: *osm2pgsql
787 table: *road-ref-sql
788 properties:
789 minzoom: 10
790 - id: railway-platform-ref
791 geometry: linestring
792 <<: *extents
793 Datasource:
794 <<: *osm2pgsql
795 table: |-
796 (SELECT
797 way,
798 COALESCE(tags->'local_ref', ref) AS ref
799 FROM planet_osm_line
800 WHERE "railway" = 'platform_edge'
801 ORDER BY ref
802 ) AS railway_platform_edge_ref
803 properties:
804 minzoom: 17

mercurial