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 1 commit
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
31 changes: 12 additions & 19 deletions electrification.mss
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -149,37 +147,32 @@
[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"] {
line-color: #70584D;
}

#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;
Expand Down Expand Up @@ -221,7 +214,7 @@
line-color: #97FF2F;
}

[frequency!=null][frequency!=0][voltage>=15000][voltage<25000] {
[frequency=null][frequency!=0][voltage>=15000][voltage<25000] {
JonathanBittner marked this conversation as resolved.
Show resolved Hide resolved
line-color: #F1F100;
}

Expand All @@ -233,7 +226,7 @@
line-color: #00CB66;
}

[frequency!=null][frequency!=0][voltage>25000] {
[frequency=null][frequency!=0][voltage>=25000] {
JonathanBittner marked this conversation as resolved.
Show resolved Hide resolved
line-color: #FF9F19;
}

Expand Down
35 changes: 19 additions & 16 deletions sql/functions.sql
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -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;
Expand All @@ -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;
Expand Down