Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Render dashed lines for all railways under construction in the electrification layer #69

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions electrification.mml
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down
13 changes: 9 additions & 4 deletions electrification.mss
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand All @@ -160,11 +165,11 @@
}

#electrification_future {
["state"="construction"] {
["state"="construction_future"] {
line-dasharray: @construction-dashes;
}

["state"="proposed"] {
["state"="proposed_future"] {
line-dasharray: @proposed-dashes;
}
}
Expand Down
29 changes: 19 additions & 10 deletions sql/functions.sql
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -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;
Expand All @@ -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;
Expand Down