Skip to content

Commit

Permalink
rework admin boundaries and admin labels on lower zooms, render count…
Browse files Browse the repository at this point in the history
…ry subdivisions only for the biggest countries on z4
  • Loading branch information
nebulon42 committed Nov 18, 2015
1 parent f855191 commit 4da1443
Show file tree
Hide file tree
Showing 5 changed files with 285 additions and 34 deletions.
82 changes: 65 additions & 17 deletions admin.mss
Original file line number Diff line number Diff line change
Expand Up @@ -6,48 +6,88 @@ For each zoomlevel, all borders come from a single attachment, to handle
overlapping borders correctly.
*/

#admin-low-zoom[zoom < 11],
#admin-very-low-zoom[zoom >= 4][zoom < 5],
#admin-low-zoom[zoom >= 5][zoom < 11],
#admin-mid-zoom[zoom >= 11][zoom < 13],
#admin-high-zoom[zoom >= 13] {
[admin_level = '2'],
[admin_level = '3'] {
[admin_level = '2'] {
[zoom >= 4] {
background/line-join: bevel;
background/line-color: white;
background/line-width: 0.6;
background/line-width: 1.2;
line-join: bevel;
line-color: @admin-boundaries;
line-width: 0.6;
line-width: 1.2;
}
[zoom >= 5] {
background/line-width: 1.5;
line-width: 1.5;
}
[zoom >= 6] {
background/line-width: 1.8;
line-width: 1.8;
}
[zoom >= 7] {
background/line-width: 2;
line-width: 2;
}
[zoom >= 10] {
[admin_level = '2'] {
background/line-width: 6;
line-width: 6;
}
[admin_level = '3'] {
background/line-width: 5;
line-width: 5;
line-dasharray: 4,2;
line-clip: false;
}
background/line-width: 6;
line-width: 6;
}
}
[admin_level = '4'] {
[admin_level = '3'] {
[zoom >= 4] {
background/line-join: bevel;
background/line-color: white;
background/line-width: 0.6;
line-join: bevel;
line-color: @admin-boundaries;
line-width: 0.6;
}
[zoom >= 7] {
background/line-width: 1.2;
line-width: 1.2;
}
[zoom >= 10] {
background/line-width: 4;
line-width: 4;
line-dasharray: 4,2;
line-clip: false;
}
}
[admin_level = '4'] {
[zoom >= 4] {
background/line-join: bevel;
background/line-color: white;
background/line-width: 0.4;
line-join: bevel;
line-color: @admin-boundaries;
line-width: 0.4;
line-dasharray: 4,3;
line-clip: false;
}
[zoom >= 5] {
background/line-width: 0.6;
line-width: 0.6;
}
[zoom >= 6] {
background/line-width: 0.8;
line-width: 0.8;
}
[zoom >= 7] {
background/line-width: 1;
line-width: 1;
}
[zoom >= 11] {
[zoom >= 9] {
background/line-width: 1.8;
line-width: 1.8;
}
[zoom >= 10] {
background/line-width: 2.5;
line-width: 2.5;
}
[zoom >= 12] {
background/line-width: 3;
line-width: 3;
}
Expand All @@ -70,16 +110,20 @@ overlapping borders correctly.
#admin-mid-zoom[zoom >= 11][zoom < 13],
#admin-high-zoom[zoom >= 13] {
[admin_level = '5'][zoom >= 11] {
background/line-join: bevel;
background/line-color: white;
background/line-width: 2;
line-join: bevel;
line-color: @admin-boundaries;
line-width: 2;
line-dasharray: 6,3,2,3,2,3;
line-clip: false;
}
[admin_level = '6'][zoom >= 11] {
background/line-join: bevel;
background/line-color: white;
background/line-width: 2;
line-join: bevel;
line-color: @admin-boundaries;
line-width: 2;
line-dasharray: 6,3,2,3;
Expand All @@ -88,8 +132,10 @@ overlapping borders correctly.
[admin_level = '7'],
[admin_level = '8'] {
[zoom >= 12] {
background/line-join: bevel;
background/line-color: white;
background/line-width: 1.5;
line-join: bevel;
line-color: @admin-boundaries;
line-width: 1.5;
line-dasharray: 5,2;
Expand All @@ -104,8 +150,10 @@ overlapping borders correctly.
[admin_level = '9'],
[admin_level = '10'] {
[zoom >= 13] {
background/line-join: bevel;
background/line-color: white;
background/line-width: 2;
line-join: bevel;
line-color: @admin-boundaries;
line-width: 2;
line-dasharray: 2,3;
Expand Down
41 changes: 31 additions & 10 deletions placenames.mss
Original file line number Diff line number Diff line change
@@ -1,18 +1,38 @@
@placenames: #222;
@placenames-light: #777777;
@country-labels: darken(@admin-boundaries, 15%);
@state-labels: desaturate(darken(@admin-boundaries, 5%), 20%);

.country {
[admin_level = '2'][zoom >= 2][way_pixels > 3000][way_pixels < 196000] {
[admin_level = '2'][zoom >= 3][way_pixels > 1000][way_pixels < 360000] {
text-name: "[name]";
text-size: 9;
text-fill: #9d6c9d;

[zoom >= 3] {
text-size: 10;
}
[zoom >= 4] {
text-size: 11;
}
[zoom >= 5] {
text-size: 12;
}
[zoom >= 7] {
text-size: 13;
}
[zoom >= 10] {
text-size: 14;
}

text-fill: @country-labels;
text-face-name: @book-fonts;
text-halo-fill: rgba(255,255,255,0.6);
text-halo-radius: 1.5;
text-wrap-width: 50;
text-wrap-width: 35;
text-placement: interior;
[zoom >= 4] {
text-size: 10;
}
text-character-spacing: 0.5;
text-min-distance: 3;
text-line-spacing: 1;
}
}

Expand All @@ -22,26 +42,27 @@
[zoom >= 5][way_pixels > 3000][way_pixels < 196000] {
text-name: "[ref]";
text-size: 9;
text-fill: #9d6c9d;
text-fill: @state-labels;
text-face-name: @oblique-fonts;
text-halo-fill: rgba(255,255,255,0.6);
text-halo-radius: 1.5;
text-wrap-width: 0;
text-placement: interior;
text-min-distance: 3;
[zoom >= 5] {
text-name: "[name]";
text-wrap-width: 50;
text-wrap-width: 30;
}
[zoom >= 7] {
text-size: 11;
text-wrap-width: 70;
text-wrap-width: 50;
}
}
}
}

#placenames-medium::high-importance {
[category = 1][zoom < 14] {
[zoom >= 3][score >= 5000000],
[zoom >= 4][score >= 3000000],
[zoom >= 5][score >= 400000] {
text-name: "[name]";
Expand Down
92 changes: 87 additions & 5 deletions project.mml
Original file line number Diff line number Diff line change
Expand Up @@ -1048,6 +1048,33 @@
},
"advanced": {}
},
{
"name": "admin-very-low-zoom",
"srs-name": "900913",
"geometry": "linestring",
"class": "",
"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",
"Datasource": {
"extent": "-20037508,-20037508,20037508,20037508",
"table": "(SELECT\n way,\n admin_level\n FROM planet_osm_roads l\n WHERE boundary = 'administrative'\n AND (admin_level IN ('0', '1', '2')\n OR (admin_level IN ('3', '4')\n AND EXISTS\n (SELECT 1\n FROM planet_osm_polygon p\n WHERE boundary = 'administrative'\n AND admin_level = '2'\n AND way_area > 9e+12\n AND ST_Within(ST_Centroid(l.way), p.way)\n )\n )\n )\n AND osm_id < 0\n ORDER BY admin_level DESC\n ) AS admin_very_low_zoom",
"geometry_field": "way",
"type": "postgis",
"key_field": "",
"dbname": "gis"
},
"extent": [
-180,
-85.05112877980659,
180,
85.05112877980659
],
"id": "admin-very-low-zoom",
"properties": {
"maxzoom": 4,
"minzoom": 4
},
"advanced": {}
},
{
"name": "admin-low-zoom",
"srs-name": "900913",
Expand All @@ -1056,7 +1083,7 @@
"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",
"Datasource": {
"extent": "-20037508,-20037508,20037508,20037508",
"table": "(SELECT\n way,\n admin_level\n FROM planet_osm_roads\n WHERE boundary = 'administrative'\n AND admin_level IN ('0', '1', '2', '3', '4')\n ORDER BY admin_level DESC\n) AS admin_low_zoom",
"table": "(SELECT\n way,\n admin_level\n FROM planet_osm_roads\n WHERE boundary = 'administrative'\n AND admin_level IN ('0', '1', '2', '3', '4')\n AND osm_id < 0\n ORDER BY admin_level DESC\n) AS admin_low_zoom",
"geometry_field": "way",
"type": "postgis",
"key_field": "",
Expand All @@ -1070,7 +1097,8 @@
],
"id": "admin-low-zoom",
"properties": {
"maxzoom": 10
"maxzoom": 10,
"minzoom": 5
},
"advanced": {}
},
Expand All @@ -1083,7 +1111,7 @@
"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",
"Datasource": {
"extent": "-20037508,-20037508,20037508,20037508",
"table": "(SELECT\n way,\n admin_level\n FROM planet_osm_roads\n WHERE boundary = 'administrative'\n AND admin_level IN ('0', '1', '2', '3', '4', '5', '6', '7', '8')\n ORDER BY admin_level DESC\n) AS admin_mid_zoom",
"table": "(SELECT\n way,\n admin_level\n FROM planet_osm_roads\n WHERE boundary = 'administrative'\n AND admin_level IN ('0', '1', '2', '3', '4', '5', '6', '7', '8')\n AND osm_id < 0\n ORDER BY admin_level DESC\n) AS admin_mid_zoom",
"geometry_field": "way",
"type": "postgis",
"key_field": "",
Expand All @@ -1110,7 +1138,7 @@
"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",
"Datasource": {
"extent": "-20037508,-20037508,20037508,20037508",
"table": "(SELECT\n way,\n admin_level\n FROM planet_osm_roads\n WHERE boundary = 'administrative'\n AND admin_level IN ('0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '10')\n ORDER BY admin_level::integer DESC -- With 10 as a valid value, we need to do a numeric ordering, not a text ordering\n) AS admin_high_zoom",
"table": "(SELECT\n way,\n admin_level\n FROM planet_osm_roads\n WHERE boundary = 'administrative'\n AND admin_level IN ('0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '10')\n AND osm_id < 0\n ORDER BY admin_level::integer DESC -- With 10 as a valid value, we need to do a numeric ordering, not a text ordering\n) AS admin_high_zoom",
"geometry_field": "way",
"type": "postgis",
"key_field": "",
Expand Down Expand Up @@ -1257,6 +1285,60 @@
},
"advanced": {}
},
{
"name": "placenames-large-very-low-zoom",
"srs-name": "900913",
"geometry": "point",
"class": "country state",
"id": "placenames-large-very-low-zoom",
"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",
"Datasource": {
"extent": "-20037508,-20037508,20037508,20037508",
"table": "(SELECT\n way,\n way_area/NULLIF(!pixel_width!::real*!pixel_height!::real,0) AS way_pixels,\n name,\n ref,\n admin_level\n FROM planet_osm_polygon\n WHERE boundary = 'administrative'\n AND admin_level = '2'\n AND name IS NOT NULL\n ORDER BY admin_level ASC, way_area DESC\n) AS placenames_large_very_low_zoom",
"geometry_field": "way",
"type": "postgis",
"key_field": "",
"dbname": "gis"
},
"extent": [
-180,
-85.05112877980659,
180,
85.05112877980659
],
"properties": {
"maxzoom": 3,
"minzoom": 2
},
"advanced": {}
},
{
"name": "placenames-large-low-zoom",
"srs-name": "900913",
"geometry": "point",
"class": "country state",
"id": "placenames-large-low-zoom",
"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",
"Datasource": {
"extent": "-20037508,-20037508,20037508,20037508",
"table": "(SELECT\n way,\n way_area/NULLIF(!pixel_width!::real*!pixel_height!::real,0) AS way_pixels,\n name,\n ref,\n admin_level\n FROM planet_osm_polygon o\n WHERE boundary = 'administrative'\n AND (admin_level IN ('0', '1', '2')\n OR (admin_level IN ('3', '4')\n AND EXISTS\n (SELECT 1\n FROM planet_osm_polygon i\n WHERE boundary = 'administrative'\n AND admin_level = '2'\n AND way_area > 9e+12\n AND ST_Within(ST_Centroid(o.way), i.way)\n )\n )\n )\n ORDER BY admin_level ASC, way_area DESC\n ) AS placenames_large_low_zoom",
"geometry_field": "way",
"type": "postgis",
"key_field": "",
"dbname": "gis"
},
"extent": [
-180,
-85.05112877980659,
180,
85.05112877980659
],
"properties": {
"maxzoom": 4,
"minzoom": 4
},
"advanced": {}
},
{
"name": "placenames-large",
"srs-name": "900913",
Expand All @@ -1279,7 +1361,7 @@
85.05112877980659
],
"properties": {
"minzoom": 2
"minzoom": 5
},
"advanced": {}
},
Expand Down
Loading

0 comments on commit 4da1443

Please sign in to comment.