From 82de166bd587513d65bffd26ab0d8a09bef8dae1 Mon Sep 17 00:00:00 2001 From: Jonathan Bittner Date: Mon, 28 Feb 2022 13:42:46 -0500 Subject: [PATCH 1/3] updates for electrification errors on issue 47 --- electrification.mss | 12 +++++++++--- sql/functions.sql | 21 +++++++++++++++------ 2 files changed, 24 insertions(+), 9 deletions(-) diff --git a/electrification.mss b/electrification.mss index 5325126a..d8011310 100644 --- a/electrification.mss +++ b/electrification.mss @@ -153,6 +153,11 @@ ["state"="construction"][zoom < 9] { line-color: black; } + + ["state"=null]["railway"="construction"] + { + line-color: darkgrey; + } ["state"="deelectrified"], ["state"="abandoned"] { @@ -160,7 +165,8 @@ } #electrification_future { - ["state"="construction"] { + ["state"="construction"], + ["railway"="construction"] { line-dasharray: @construction-dashes; } @@ -209,7 +215,7 @@ line-color: #97FF2F; } - [frequency=null][frequency!=0][voltage>=15000][voltage<25000] { + [frequency!=null][frequency!=0][voltage>=15000][voltage<25000] { line-color: #F1F100; } @@ -221,7 +227,7 @@ line-color: #00CB66; } - [frequency=null][frequency!=0][voltage>=25000] { + [frequency!=null][frequency!=0][voltage>25000] { line-color: #FF9F19; } diff --git a/sql/functions.sql b/sql/functions.sql index 352e01a1..0bb68557 100644 --- a/sql/functions.sql +++ b/sql/functions.sql @@ -362,18 +362,27 @@ DECLARE valid_values TEXT[] := ARRAY['contact_line', 'yes', 'rail', 'ground-level_power_supply', '4th_rail', 'contact_line;rail', 'rail;contact_line']; BEGIN state := NULL; - IF electrified = ANY(valid_values) THEN - return 'present'; - END IF; - IF electrified = 'no' THEN - state := 'no'; - END IF; IF NOT ignore_future_states AND construction_electrified = ANY(valid_values) THEN RETURN 'construction'; + END IF; + IF NOT ignore_future_states AND railway = 'construction' AND construction_electrified = 'no' THEN + return 'no'; + ELSIF NOT ignore_future_states AND railway = 'construction' THEN + return NULL; END IF; + + IF NOT ignore_future_states AND proposed_electrified = ANY(valid_values) THEN RETURN 'proposed'; + END IF; + IF electrified = ANY(valid_values) THEN + return 'present'; END IF; + IF electrified = 'no' THEN + state := 'no'; + END IF; + + IF state = 'no' AND deelectrified = ANY(valid_values) THEN RETURN 'deelectrified'; END IF; From 6475aa58a466b3db614aa5ee332a0f0613920368 Mon Sep 17 00:00:00 2001 From: Jonathan Bittner Date: Wed, 2 Mar 2022 16:37:30 -0500 Subject: [PATCH 2/3] Fixed issue 47: electrification layer renders railway=construction as normal line These changes cause all lines under construction to be displayed with dashes in the electrification layer, regardless of electrification state. --- electrification.mss | 16 +++++++++++----- sql/functions.sql | 25 +++++++++++-------------- 2 files changed, 22 insertions(+), 19 deletions(-) diff --git a/electrification.mss b/electrification.mss index d8011310..d2a561e2 100644 --- a/electrification.mss +++ b/electrification.mss @@ -22,6 +22,8 @@ @color_25kv_50: #FF0000; @color_25kv_60: #C00000; +@construct_elec_unknown: darkgrey; + /** * Railway tracks with electrification under construction or proposed electrification * are rendered with a second symbolizer called proposed_construction. @@ -151,13 +153,9 @@ ["state"="no"], ["state"="proposed"][zoom < 9], ["state"="construction"][zoom < 9] { - line-color: black; + line-color: @color_no; } - ["state"=null]["railway"="construction"] - { - line-color: darkgrey; - } ["state"="deelectrified"], ["state"="abandoned"] { @@ -174,6 +172,14 @@ line-dasharray: @proposed-dashes; } } + /* When this layer runs, if the line is under construction + * and doesn't have an explicit electrified=no/construction:electrified=no + * render a light grey/dark grey mix until a voltage color overrides */ + #electrification_future { + ["railway"="construction"]["state"!="no"] { + line-color: @construct_elec_unknown; + } + } [frequency=0]["voltage"<750] { line-color: #FF79B8; diff --git a/sql/functions.sql b/sql/functions.sql index 0bb68557..6dee8864 100644 --- a/sql/functions.sql +++ b/sql/functions.sql @@ -362,27 +362,24 @@ DECLARE valid_values TEXT[] := ARRAY['contact_line', 'yes', 'rail', 'ground-level_power_supply', '4th_rail', 'contact_line;rail', 'rail;contact_line']; BEGIN state := NULL; - IF NOT ignore_future_states AND construction_electrified = ANY(valid_values) THEN - RETURN 'construction'; - END IF; - IF NOT ignore_future_states AND railway = 'construction' AND construction_electrified = 'no' THEN - return 'no'; - ELSIF NOT ignore_future_states AND railway = 'construction' THEN - return NULL; +-- For the first layer if this is construction, let the second pass do the work + IF ignore_future_states AND railway = 'construction' THEN + RETURN NULL; END IF; - - - IF NOT ignore_future_states AND proposed_electrified = ANY(valid_values) THEN - RETURN 'proposed'; - END IF; IF electrified = ANY(valid_values) THEN return 'present'; END IF; IF electrified = 'no' THEN state := 'no'; END IF; - - + IF NOT ignore_future_states AND construction_electrified = ANY(valid_values) THEN + RETURN 'construction'; + ELSIF NOT ignore_future_states AND railway = 'construction' AND construction_electrified = 'no' THEN + return 'no'; + END IF; + IF NOT ignore_future_states AND proposed_electrified = ANY(valid_values) THEN + RETURN 'proposed'; + END IF; IF state = 'no' AND deelectrified = ANY(valid_values) THEN RETURN 'deelectrified'; END IF; From 2ab7cc20baae57c1b173da8c2de6548c59e45df6 Mon Sep 17 00:00:00 2001 From: Jonathan Bittner Date: Mon, 7 Mar 2022 12:47:46 -0500 Subject: [PATCH 3/3] Updated electrification layer for handling lines under construction. Lines under construction now properly render in the electrification layer with dashing. Corrects issue #47. --- electrification.mml | 4 ++-- electrification.mss | 31 ++++++++++++------------------- sql/functions.sql | 35 +++++++++++++++++++---------------- 3 files changed, 33 insertions(+), 37 deletions(-) diff --git a/electrification.mml b/electrification.mml index 92015eab..641000d8 100644 --- a/electrification.mml +++ b/electrification.mml @@ -217,7 +217,7 @@ Layer: tags->'preserved:railway' AS preserved_railway, tags->'preserved:service' AS preserved_service, tags->'preserved:usage' AS preserved_usage, railway_electrification_state(railway, electrified, deelectrified, abandoned_electrified, construction_electrified, proposed_electrified, FALSE) AS electrification_state, - railway_electrification_state(railway, electrified, deelectrified, abandoned_electrified, NULL, NULL, TRUE) AS electrification_state_without_future, + railway_electrification_state(railway, electrified, deelectrified, abandoned_electrified, construction_electrified, NULL, TRUE) AS electrification_state_without_future, frequency AS frequency, voltage AS voltage, construction_frequency AS construction_frequency, @@ -281,7 +281,7 @@ Layer: proposed_voltage AS proposed_voltage, layer FROM openrailwaymap_osm_line - WHERE railway IN ('rail', 'tram', 'light_rail', 'subway', 'narrow_gauge', 'construction', 'preserved') + WHERE railway IN ('rail', 'tram', 'light_rail', 'subway', 'narrow_gauge') ) AS r ORDER BY layer, diff --git a/electrification.mss b/electrification.mss index d2a561e2..5ef4566c 100644 --- a/electrification.mss +++ b/electrification.mss @@ -22,8 +22,6 @@ @color_25kv_50: #FF0000; @color_25kv_60: #C00000; -@construct_elec_unknown: darkgrey; - /** * Railway tracks with electrification under construction or proposed electrification * are rendered with a second symbolizer called proposed_construction. @@ -149,13 +147,17 @@ [zoom>=13]["railway"="light_rail"]["service"!=null], [zoom>=11]["railway"="tram"]["service"=null], [zoom>=13]["railway"="tram"]["service"!=null] { + + #railway_line_fill["railway"="construction"] { + line-dasharray: @construction-dashes; + } + ["state"="no"], - ["state"="proposed"][zoom < 9], - ["state"="construction"][zoom < 9] { - line-color: @color_no; + ["state"="proposed_future"][zoom < 9], + ["state"="construction_future"][zoom < 9] { + line-color: black; } - ["state"="deelectrified"], ["state"="abandoned"] { @@ -163,23 +165,14 @@ } #electrification_future { - ["state"="construction"], - ["railway"="construction"] { + ["state"="construction_future"] { line-dasharray: @construction-dashes; } - ["state"="proposed"] { + ["state"="proposed_future"] { line-dasharray: @proposed-dashes; } } - /* When this layer runs, if the line is under construction - * and doesn't have an explicit electrified=no/construction:electrified=no - * render a light grey/dark grey mix until a voltage color overrides */ - #electrification_future { - ["railway"="construction"]["state"!="no"] { - line-color: @construct_elec_unknown; - } - } [frequency=0]["voltage"<750] { line-color: #FF79B8; @@ -221,7 +214,7 @@ line-color: #97FF2F; } - [frequency!=null][frequency!=0][voltage>=15000][voltage<25000] { + [frequency=null][frequency!=0][voltage>=15000][voltage<25000] { line-color: #F1F100; } @@ -233,7 +226,7 @@ line-color: #00CB66; } - [frequency!=null][frequency!=0][voltage>25000] { + [frequency=null][frequency!=0][voltage>=25000] { line-color: #FF9F19; } diff --git a/sql/functions.sql b/sql/functions.sql index 6dee8864..b74d8dbc 100644 --- a/sql/functions.sql +++ b/sql/functions.sql @@ -362,23 +362,26 @@ DECLARE valid_values TEXT[] := ARRAY['contact_line', 'yes', 'rail', 'ground-level_power_supply', '4th_rail', 'contact_line;rail', 'rail;contact_line']; BEGIN state := NULL; --- For the first layer if this is construction, let the second pass do the work - IF ignore_future_states AND railway = 'construction' THEN - RETURN NULL; - END IF; - IF electrified = ANY(valid_values) THEN - return 'present'; + + IF railway = 'construction' AND construction_electrified = 'no' THEN + return 'no'; + ELSIF railway = 'construction' AND construction_electrified = ANY(valid_values) THEN + return 'construction_now'; + ELSIF railway = 'construction' AND electrified = ANY(valid_values) THEN + --this is really to correct a mistag, but there are too many mistags to leave this out + return 'construction_now'; END IF; IF electrified = 'no' THEN state := 'no'; END IF; + IF electrified = ANY(valid_values) THEN + return 'present'; + END IF; IF NOT ignore_future_states AND construction_electrified = ANY(valid_values) THEN - RETURN 'construction'; - ELSIF NOT ignore_future_states AND railway = 'construction' AND construction_electrified = 'no' THEN - return 'no'; + RETURN 'construction_future'; END IF; IF NOT ignore_future_states AND proposed_electrified = ANY(valid_values) THEN - RETURN 'proposed'; + RETURN 'proposed_future'; END IF; IF state = 'no' AND deelectrified = ANY(valid_values) THEN RETURN 'deelectrified'; @@ -396,10 +399,10 @@ BEGIN IF state = 'present' THEN RETURN railway_to_int(voltage); END IF; - IF state = 'construction' THEN - RETURN railway_to_int(construction_voltage); + IF state = 'construction_future' OR state = 'construction_now' THEN + RETURN railway_to_int(COALESCE(construction_voltage,voltage)); END IF; - IF state = 'proposed' THEN + IF state = 'proposed_future' THEN RETURN railway_to_int(proposed_voltage); END IF; RETURN NULL; @@ -412,10 +415,10 @@ BEGIN IF state = 'present' THEN RETURN railway_to_float(frequency); END IF; - IF state = 'construction' THEN - RETURN railway_to_float(construction_frequency); + IF state = 'construction_future' OR state = 'construction_now' THEN + RETURN railway_to_float(COALESCE(construction_frequency,frequency)); END IF; - IF state = 'proposed' THEN + IF state = 'proposed_future' THEN RETURN railway_to_float(proposed_frequency); END IF; RETURN NULL;