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 5325126a..5ef4566c 100644 --- a/electrification.mss +++ b/electrification.mss @@ -147,10 +147,15 @@ [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] { + ["state"="proposed_future"][zoom < 9], + ["state"="construction_future"][zoom < 9] { line-color: black; } @@ -160,11 +165,11 @@ } #electrification_future { - ["state"="construction"] { + ["state"="construction_future"] { line-dasharray: @construction-dashes; } - ["state"="proposed"] { + ["state"="proposed_future"] { line-dasharray: @proposed-dashes; } } diff --git a/sql/functions.sql b/sql/functions.sql index 352e01a1..b74d8dbc 100644 --- a/sql/functions.sql +++ b/sql/functions.sql @@ -362,17 +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; - 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'; + 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'; @@ -390,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; @@ -406,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;