Skip to content

Commit

Permalink
Split concurrent refs into a multi-line shield
Browse files Browse the repository at this point in the history
This new SQL takes the refs for a way, splits them on ;, and rejoins
them with newlines. When doing this it also calculates the number of lines
and the length of the longest line.

Fixes #670 as best as possible pre-Mapnik 3.
Also fixes #701
  • Loading branch information
pnorman committed Jul 21, 2014
1 parent e98bb12 commit cd7da91
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 46 deletions.
4 changes: 2 additions & 2 deletions project.mml
Original file line number Diff line number Diff line change
Expand Up @@ -1390,7 +1390,7 @@
],
"Datasource": {
"type": "postgis",
"table": " (select way,highway,ref,char_length(ref) as length\n from planet_osm_roads\n where highway in ('motorway','trunk','primary','secondary')\n and ref is not null\n and char_length(ref) between 1 and 11\n ) as roads_text_ref_low_zoom",
"table": "(SELECT way, highway, height, width, refs FROM\n (SELECT \n way, highway, \n array_length(refs,1) AS height, \n (SELECT MAX(char_length(ref)) FROM unnest(refs) AS u(ref)) AS width, \n array_to_string(refs,E'\\n') AS refs\n FROM (\n SELECT \n way, \n highway, \n string_to_array(ref,';') AS refs\n FROM planet_osm_roads\n WHERE highway IN ('motorway','trunk','primary','secondary')\n AND ref IS NOT NULL\n ) AS p) AS q\n WHERE height <= 4 AND width <= 11) AS roads_text_ref_low_zoom",
"extent": "-20037508,-20037508,20037508,20037508",
"key_field": "",
"geometry_field": "way",
Expand Down Expand Up @@ -1436,7 +1436,7 @@
],
"Datasource": {
"type": "postgis",
"table": " (select way,coalesce(highway,aeroway) as highway,ref,char_length(ref) as length,\n case when bridge in ('yes','true','1') then 'yes'::text else 'no'::text end as bridge\n from planet_osm_line\n where (highway is not null or aeroway is not null)\n and ref is not null\n and char_length(ref) between 1 and 11\n ) as roads_text_ref",
"table": "(SELECT way, highway, height, width, refs FROM\n (SELECT \n way, highway, \n array_length(refs,1) AS height, \n (SELECT MAX(char_length(ref)) FROM unnest(refs) AS u(ref)) AS width, \n array_to_string(refs,E'\\n') AS refs\n FROM (\n SELECT \n way, \n COALESCE(highway, aeroway) AS highway, \n string_to_array(ref,';') AS refs\n FROM planet_osm_line\n WHERE (highway IN ('motorway','trunk','primary','secondary','tertiary','unclassified','residential') OR aeroway IN ('runway','taxiway'))\n AND ref IS NOT NULL\n ) AS p) AS q\n WHERE height <= 4 AND width <= 11) AS roads_text_ref",
"extent": "-20037508,-20037508,20037508,20037508",
"key_field": "",
"geometry_field": "way",
Expand Down
84 changes: 40 additions & 44 deletions roads.mss
Original file line number Diff line number Diff line change
Expand Up @@ -2124,50 +2124,48 @@
}

#roads-text-ref-low-zoom {
[highway = 'motorway'][length < 12] {
[zoom >= 10][zoom < 13] {
shield-name: "[ref]";
shield-size: 10;
shield-fill: #fff;
shield-placement: line;
shield-file: url("symbols/shields/motorway_[length]x1.svg");
shield-spacing: 750;
shield-min-distance: 30;
shield-face-name: @bold-fonts;
shield-clip: false;
}
[highway = 'motorway'][zoom >= 10][zoom < 13] {
shield-name: "[refs]";
shield-size: 10;
shield-fill: #fff;
shield-placement: line;
shield-file: url("symbols/shields/motorway_[width]x[height].svg");
shield-spacing: 750;
shield-min-distance: 30;
shield-face-name: @bold-fonts;
shield-clip: false;
}

[highway = 'trunk'][zoom >= 11][zoom < 13] {
shield-name: "[ref]";
shield-name: "[refs]";
shield-size: 10;
shield-fill: #fff;
shield-placement: line;
shield-file: url("symbols/shields/trunk_[length]x1.svg");
shield-file: url("symbols/shields/trunk_[width]x[height].svg");
shield-spacing: 750;
shield-min-distance: 30;
shield-face-name: @bold-fonts;
shield-clip: false;
}

[highway = 'primary'][zoom >= 11][zoom < 13] {
shield-name: "[ref]";
shield-name: "[refs]";
shield-size: 10;
shield-fill: #fff;
shield-placement: line;
shield-file: url("symbols/shields/primary_[length]x1.svg");
shield-file: url("symbols/shields/primary_[width]x[height].svg");
shield-spacing: 750;
shield-min-distance: 30;
shield-face-name: @bold-fonts;
shield-clip: false;
}

[highway = 'secondary'][zoom >= 12][zoom < 13] {
shield-name: "[ref]";
shield-name: "[refs]";
shield-size: 10;
shield-fill: #fff;
shield-placement: line;
shield-file: url("symbols/shields/secondary_[length]x1.svg");
shield-file: url("symbols/shields/secondary_[width]x[height].svg");
shield-spacing: 750;
shield-min-distance: 30;
shield-face-name: @bold-fonts;
Expand All @@ -2176,62 +2174,60 @@
}

#roads-text-ref {
[highway = 'motorway'][length < 12] {
[zoom >= 13] {
shield-name: "[ref]";
shield-size: 10;
shield-fill: #fff;
shield-placement: line;
shield-file: url("symbols/shields/motorway_[length]x1.svg");
shield-spacing: 750;
shield-min-distance: 30;
shield-face-name: @bold-fonts;
shield-clip: false;
}
[highway = 'motorway'][zoom >= 13] {
shield-name: "[refs]";
shield-size: 10;
shield-fill: #fff;
shield-placement: line;
shield-file: url("symbols/shields/motorway_[width]x[height].svg");
shield-spacing: 750;
shield-min-distance: 30;
shield-face-name: @bold-fonts;
shield-clip: false;
}

[highway = 'trunk'][zoom >= 13] {
shield-name: "[ref]";
shield-name: "[refs]";
shield-size: 10;
shield-fill: #fff;
shield-placement: line;
shield-file: url("symbols/shields/trunk_[length]x1.svg");
shield-file: url("symbols/shields/trunk_[width]x[height].svg");
shield-spacing: 750;
shield-min-distance: 30;
shield-face-name: @bold-fonts;
shield-clip: false;
}

[highway = 'primary'][zoom >= 13] {
shield-name: "[ref]";
shield-name: "[refs]";
shield-size: 10;
shield-fill: #fff;
shield-placement: line;
shield-file: url("symbols/shields/primary_[length]x1.svg");
shield-file: url("symbols/shields/primary_[width]x[height].svg");
shield-spacing: 750;
shield-min-distance: 30;
shield-face-name: @bold-fonts;
shield-clip: false;
}

[highway = 'secondary'][bridge = 'no'][zoom >= 13] {
shield-name: "[ref]";
[highway = 'secondary'][zoom >= 13] {
shield-name: "[refs]";
shield-size: 10;
shield-fill: #fff;
shield-placement: line;
shield-file: url("symbols/shields/secondary_[length]x1.svg");
shield-file: url("symbols/shields/secondary_[width]x[height].svg");
shield-spacing: 750;
shield-min-distance: 30;
shield-face-name: @bold-fonts;
shield-clip: false;
}

[highway = 'tertiary'][bridge = 'no'][zoom >= 13] {
shield-name: "[ref]";
[highway = 'tertiary'][zoom >= 13] {
shield-name: "[refs]";
shield-size: 10;
shield-fill: #fff;
shield-placement: line;
shield-file: url("symbols/shields/tertiary_[length]x1.svg");
shield-file: url("symbols/shields/tertiary_[width]x[height].svg");
shield-spacing: 750;
shield-min-distance: 30;
shield-face-name: @bold-fonts;
Expand All @@ -2240,8 +2236,8 @@

[highway = 'unclassified'],
[highway = 'residential'] {
[zoom >= 15][bridge = 'no'] {
text-name: "[ref]";
[zoom >= 15] {
text-name: "[refs]";
text-size: 10;
text-fill: #000;
text-face-name: @bold-fonts;
Expand All @@ -2254,8 +2250,8 @@

[highway = 'runway'],
[highway = 'taxiway'] {
[zoom >= 15][bridge = 'no'] {
text-name: "[ref]";
[zoom >= 15] {
text-name: "[refs]";
text-size: 10;
text-fill: #333;
text-spacing: 750;
Expand Down

0 comments on commit cd7da91

Please sign in to comment.