From cd7da91de4cbbb29c26178dda3eed479b4cb084a Mon Sep 17 00:00:00 2001 From: Paul Norman Date: Sun, 20 Jul 2014 19:39:36 -0700 Subject: [PATCH] Split concurrent refs into a multi-line shield 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 --- project.mml | 4 +-- roads.mss | 84 +++++++++++++++++++++++++---------------------------- 2 files changed, 42 insertions(+), 46 deletions(-) diff --git a/project.mml b/project.mml index fd9b47963f..c8fe0ad6be 100755 --- a/project.mml +++ b/project.mml @@ -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", @@ -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", diff --git a/roads.mss b/roads.mss index e21411f057..b7dae20c7c 100644 --- a/roads.mss +++ b/roads.mss @@ -2124,26 +2124,24 @@ } #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; @@ -2151,11 +2149,11 @@ } [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; @@ -2163,11 +2161,11 @@ } [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; @@ -2176,26 +2174,24 @@ } #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; @@ -2203,35 +2199,35 @@ } [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; @@ -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; @@ -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;