From 637e3d65712f34fffef16668730b475cc4bac2da Mon Sep 17 00:00:00 2001 From: Michael Reichert Date: Tue, 19 Nov 2019 22:24:04 +0100 Subject: [PATCH 01/19] current working state of electrification style --- electrification.mml | 275 ++++++++++++++++++++++++++++++++++++++++ electrification.mss | 193 ++++++++++++++++++++++++++++ sql/osm_carto_views.sql | 7 + 3 files changed, 475 insertions(+) create mode 100644 electrification.mml create mode 100644 electrification.mss diff --git a/electrification.mml b/electrification.mml new file mode 100644 index 00000000..1a0c6769 --- /dev/null +++ b/electrification.mml @@ -0,0 +1,275 @@ +scale: 1 +metatile: 2 +name: OpenRailwayMap Electrification +description: A map style for railway electrification +bounds: &world + - -180 + - -85.05112877980659 + - 180 + - 85.05112877980659 +center: + - 0 + - 0 + - 4 +format: png +interactivity: false +minzoom: 0 +maxzoom: 22 +srs: "+proj=merc +a=6378137 +b=6378137 +lat_ts=0.0 +lon_0=0.0 +x_0=0.0 +y_0=0.0 +k=1.0 +units=m +nadgrids=@null +wktext +no_defs +over" + +# Various parts to be included later on +_parts: + # Extents are used for tilemill, and don't actually make it to the generated XML + extents: &extents + extent: *world + srs-name: "900913" + srs: "+proj=merc +a=6378137 +b=6378137 +lat_ts=0.0 +lon_0=0.0 +x_0=0.0 +y_0=0.0 +k=1.0 +units=m +nadgrids=@null +wktext +no_defs +over" + extents84: &extents84 + extent: *world + srs-name: "WGS84" + srs: "+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs" + osm2pgsql: &osm2pgsql + type: "postgis" + dbname: "gis" + key_field: "" + geometry_field: "way" + extent: "-20037508,-20037508,20037508,20037508" + +Stylesheet: + - fonts.mss + - electrification.mss + - common.mss + +Layer: + - id: railway_line_casing + geometry: line + <<: *extents + Datasource: + <<: *osm2pgsql + table: |- + (SELECT + way, railway, usage, service, + disused, construction, + disused_railway, + construction_railway, + CASE WHEN railway = 'rail' AND usage IN ('usage', 'military', 'test') AND service IS NULL THEN 400 + WHEN railway = 'rail' AND usage IS NULL AND service IS NULL THEN 400 + WHEN railway = 'rail' AND usage IS NULL AND service = 'siding' THEN 870 + WHEN railway = 'rail' AND usage IS NULL AND service = 'yard' THEN 860 + WHEN railway = 'rail' AND usage IS NULL AND service = 'spur' THEN 880 + WHEN railway = 'rail' AND usage IS NULL AND service = 'crossover' THEN 300 + WHEN railway = 'rail' AND usage = 'main' AND service IS NULL THEN 1100 + WHEN railway = 'rail' AND usage = 'branch' AND service IS NULL THEN 1000 + WHEN railway = 'rail' AND usage = 'industrial' AND service IS NULL THEN 850 + WHEN railway = 'rail' AND usage = 'industrial' AND service IN ('siding', 'spur', 'yard', 'crossover') THEN 850 + WHEN railway IN ('preserved', 'construction') THEN 400 + WHEN railway = 'disused' THEN 300 + ELSE 50 + END AS rank, + electrified, + frequency, + construction_electrified, + construction_frequency, + proposed_electrified, + proposed_frequency, + railway_no_to_null(deelectrified) + FROM + (SELECT + way, railway, usage, service, + tags->'disused' AS disused, construction, + tags->'disused:railway' AS disused_railway, + tags->'construction:railway' AS construction_railway, + electrified, + frequency, + construction_electrified, + construction_frequency, + proposed_electrified, + proposed_frequency, + deelectrified, + z_order + FROM openrailwaymap_osm_line + WHERE railway IN ('rail', 'tram', 'light_rail', 'subway', 'narrow_gauge', 'disused', 'construction') + ) AS r + ORDER by z_order, rank NULLS LAST + ) AS railway_line_casing + properties: + minzoom: 9 + - id: railway_line_low + geometry: line + <<: *extents + Datasource: + <<: *osm2pgsql + table: |- + (SELECT + way, railway, usage, + -- speeds are converted to kph in this layer because it is used for colouring + railway_dominant_speed(preferred_direction, maxspeed, maxspeed_forward, maxspeed_backward) AS maxspeed, + NULL AS service, + NULL AS disused, NULL AS construction, + NULL AS disused_railway, + NULL AS construction_railway, + NULL AS disused_usage, NULL AS disused_service, + NULL AS construction_usage, NULL AS construction_service, + NULL AS preserved_railway, NULL AS preserved_service, + NULL AS preserved_usage, + CASE WHEN railway = 'rail' AND usage = 'main' THEN 1100 + WHEN railway = 'rail' AND usage = 'branch' THEN 1000 + ELSE 50 + END AS rank, + electrified, + frequency, + construction_electrified, + construction_frequency, + proposed_electrified, + proposed_frequency, + railway_no_to_null(deelectrified), + FROM + (SELECT + way, railway, usage, + maxspeed, + maxspeed_forward, + maxspeed_backward, + preferred_direction, + electrified, + frequency, + construction_electrified, + construction_frequency, + proposed_electrified, + proposed_frequency, + deelectrified, + z_order + FROM openrailwaymap_osm_line + WHERE railway = 'rail' AND usage IN ('main', 'branch') AND service IS NULL + ) AS r + ORDER BY + z_order, + rank NULLS LAST, + maxspeed ASC NULLS FIRST + ) AS openrailwaymap_line_low + properties: + maxzoom: 7 + - id: railway_line_med + geometry: line + <<: *extents + Datasource: + <<: *osm2pgsql + table: |- + (SELECT + way, railway, usage, + -- speeds are converted to kph in this layer because it is used for colouring + railway_dominant_speed(preferred_direction, maxspeed, maxspeed_forward, maxspeed_backward) AS maxspeed, + NULL AS service, + NULL AS disused, NULL AS construction, + NULL AS disused_railway, + NULL AS construction_railway, + NULL AS disused_usage, NULL AS disused_service, + NULL AS construction_usage, NULL AS construction_service, + NULL AS preserved_railway, NULL AS preserved_service, + NULL AS preserved_usage, + CASE WHEN railway = 'rail' AND usage = 'main' THEN 1100 + WHEN railway = 'rail' AND usage = 'branch' THEN 1000 + ELSE 50 + END AS rank, + electrified, + frequency, + construction_electrified, + construction_frequency, + proposed_electrified, + proposed_frequency, + railway_no_to_null(deelectrified) + FROM + (SELECT + way, railway, usage, + maxspeed, + maxspeed_forward, + maxspeed_backward, + preferred_direction, + electrified, + frequency, + construction_electrified, + construction_frequency, + proposed_electrified, + proposed_frequency, + deelectrified, + z_order + FROM openrailwaymap_osm_line + WHERE railway = 'rail' AND usage = 'main' AND service IS NULL + ) AS r + ORDER BY + z_order, + rank NULLS LAST, + maxspeed ASC NULLS FIRST + ) AS railway_line_med + properties: + minzoom: 8 + maxzoom: 8 + - id: railway_line_fill + geometry: line + <<: *extents + Datasource: + <<: *osm2pgsql + table: |- + (SELECT + way, railway, usage, service, + -- speeds are converted to kph in this layer because it is used for colouring + railway_dominant_speed(preferred_direction, maxspeed, maxspeed_forward, maxspeed_backward) AS maxspeed, + disused, construction, + disused_railway, + construction_railway, + disused_usage, disused_service, + construction_usage, construction_service, + preserved_railway, preserved_service, + preserved_usage, + CASE WHEN railway = 'rail' AND usage IN ('usage', 'military', 'test') AND service IS NULL THEN 400 + WHEN railway = 'rail' AND usage IS NULL AND service IS NULL THEN 400 + WHEN railway = 'rail' AND usage IS NULL AND service = 'siding' THEN 870 + WHEN railway = 'rail' AND usage IS NULL AND service = 'yard' THEN 860 + WHEN railway = 'rail' AND usage IS NULL AND service = 'spur' THEN 880 + WHEN railway = 'rail' AND usage IS NULL AND service = 'crossover' THEN 300 + WHEN railway = 'rail' AND usage = 'main' AND service IS NULL THEN 1100 + WHEN railway = 'rail' AND usage = 'branch' AND service IS NULL THEN 1000 + WHEN railway = 'rail' AND usage = 'industrial' AND service IS NULL THEN 850 + WHEN railway = 'rail' AND usage = 'industrial' AND service IN ('siding', 'spur', 'yard', 'crossover') THEN 850 + WHEN railway IN ('preserved', 'construction') THEN 400 + WHEN railway = 'disused' THEN 300 + + ELSE 50 + END AS rank, + electrified, + frequency, + construction_electrified, + construction_frequency, + proposed_electrified, + proposed_frequency + FROM + (SELECT + way, railway, usage, service, + maxspeed, + maxspeed_forward, + maxspeed_backward, + preferred_direction, + tags->'disused' AS disused, construction, + tags->'disused:railway' AS disused_railway, + tags->'construction:railway' AS construction_railway, + tags->'disused:usage' AS disused_usage, tags->'disused:service' AS disused_service, + tags->'construction:usage' AS construction_usage, tags->'construction:service' AS construction_service, + tags->'preserved:railway' AS preserved_railway, tags->'preserved:service' AS preserved_service, + tags->'preserved:usage' AS preserved_usage, + electrified, + frequency, + construction_electrified, + construction_frequency, + proposed_electrified, + proposed_frequency, + deelectrified, + z_order + FROM openrailwaymap_osm_line + WHERE railway IN ('rail', 'tram', 'light_rail', 'subway', 'narrow_gauge', 'disused', 'construction', 'preserved') + ) AS r + ORDER BY + z_order, + rank NULLS LAST, + maxspeed ASC NULLS FIRST + ) AS railway_line_fill + properties: + minzoom: 9 diff --git a/electrification.mss b/electrification.mss new file mode 100644 index 00000000..ce0240f1 --- /dev/null +++ b/electrification.mss @@ -0,0 +1,193 @@ +@text-halo-color: white; +@text-halo-radius: 1; + +@color_no: black; +@color_delectrified: #70584D; +@color_lt750v_dc: #FF79B8; +@color_750v_dc: #F930FF; +@color_gt750v_lt1kv_dc: #D033FF; +@color_1kv_dc: #5C1CCB; +@color_gt1kv_lt1500v_dc: #007ACB; +@color_1500v_dc: #0098CB; +@color_gt1500v_lt3kv_dc: #00B7CB; +@color_3kv_dc: #0000FF; +@color_lt15kv_ac: #97FF2F; +@color_gte15kv_lt25kv_ac: #F1F100; +@color_15kv_1667hz: #00FF00; +@color_15kv_167hz: #00CB66; +@color_gt25kv_ac: #FF9F19; +@color_25kv_50: #FF0000; +@color_25kv_60: #C00000; + +#railway_line_fill[zoom>=9]::fill, +#railway_line_low[zoom<=7]::fill, +#railway_line_med[zoom>7][zoom<9]::fill { + ["railway"="rail"]["usage"="main"]["service"=null], + [zoom>=8]["railway"="rail"]["usage"="branch"]["service"=null], + [zoom=10]["railway"="rail"]["usage"="industrial"]["service"=null], + [zoom>=11]["railway"="rail"]["usage"="industrial"], + [zoom>=13]["railway"="rail"]["usage"=null]["service"=null], + [zoom>=11]["railway"="rail"]["usage"=null]["service"="siding"], + [zoom>=11]["railway"="rail"]["usage"=null]["service"="crossover"], + [zoom>=12]["railway"="rail"]["usage"=null]["service"="yard"], + [zoom>=11]["railway"="rail"]["usage"=null]["service"="spur"], + [zoom>=10]["railway"="narrow_gauge"]["service"=null], + [zoom>=11]["railway"="narrow_gauge"]["service"="spur"], + [zoom>=11]["railway"="narrow_gauge"]["service"="siding"], + [zoom>=11]["railway"="narrow_gauge"]["service"="crossover"], + [zoom>=12]["railway"="narrow_gauge"]["service"="yard"], + [zoom>=9]["railway"="disused"]["disused_railway"="rail"]["service"=null], + [zoom>=11]["railway"="disused"]["disused_railway"="subway"]["service"=null], + [zoom>=11]["railway"="disused"]["disused_railway"="light_rail"]["service"=null], + [zoom>=12]["railway"="disused"]["disused_railway"="tram"]["service"=null], + [zoom>=13]["railway"="disused"], + [zoom>=9]["railway"="construction"]["construction_railway"="rail"]["usage"="main"]["service"=null], + [zoom>=9]["railway"="construction"]["construction_railway"="rail"]["usage"="branch"]["service"=null], + [zoom>=10]["railway"="construction"]["construction_railway"="subway"]["service"=null], + [zoom>=10]["railway"="construction"]["construction_railway"="light_rail"]["service"=null], + [zoom>=11]["railway"="construction"]["construction_railway"="tram"]["service"=null], + [zoom>=13]["railway"="construction"], + [zoom>=10]["railway"="subway"]["service"=null], + [zoom>=13]["railway"="subway"], + [zoom>=10]["railway"="light_rail"]["service"=null], + [zoom>=13]["railway"="light_rail"], + [zoom>=11]["railway"="tram"]["service"=null], + [zoom>=13]["railway"="tram"] { + ["electrified"="no"], + ["proposed_electrified"="no"], + ["construction_electrified"="no"] { + line-color: black; + } + ["electrified"="no"]["deelectrified"!="null"][deelectrified!=no], + ["electrified"="no"]["abandoned:electrified"]["abandoned:electrified"!=no] { + line-color: #70584D; + } + + ["frequency"=0][voltage<750], + ["proposed_frequency"=0]["proposed_voltage"<750], + ["construction_frequency"=0]["construction_voltage"<750] { + line-color: #FF79B8; + } + + ["frequency"=0]["voltage"=750], + ["proposed_frequency"=0]["proposed_voltage"=750], + ["construction_frequency"=0]["construction_voltage"=750] { + line-color: #F930FF; + } + + ["frequency"=0][voltage>750][voltage<1000], + ["proposed_frequency"=0]["proposed_voltage">750]["proposed_voltage"<1000], + ["construction_frequency"=0]["construction_voltage">750]["construction_voltage"<1000] { + line-color: #D033FF; + } + + ["frequency"=0]["voltage"=1000], + ["proposed_frequency"=0]["proposed_voltage"=1000], + ["construction_frequency"=0]["construction_voltage"=1000] { + line-color: #5C1CCB; + } + + ["frequency"=0][voltage>1000][voltage<1500], + ["proposed_frequency"=0]["proposed_voltage">1000]["proposed_voltage"<1500], + ["construction_frequency"=0]["construction_voltage">1000]["construction_voltage"<1500] { + line-color: #007ACB; + } + + ["frequency"=0]["voltage"=1500], + ["proposed_frequency"=0]["proposed_voltage"=1500], + ["construction_frequency"=0]["construction_voltage"=1500] { + line-color: #0098CB; + } + + ["frequency"=0][voltage>1500][voltage<3000], + ["proposed_frequency"=0]["proposed_voltage">1500]["proposed_voltage"<3000], + ["construction_frequency"=0]["construction_voltage">1500]["construction_voltage"<3000] { + line-color: #00B7CB; + } + + ["frequency"=0]["voltage"=3000], + ["proposed_frequency"=0]["proposed_voltage"=3000], + ["construction_frequency"=0]["construction_voltage"=3000] { + line-color: #0000FF; + } + + ["frequency"=0][voltage>3000], + ["proposed_frequency"=0]["proposed_voltage">3000], + ["construction_frequency"=0]["construction_voltage">3000] { + line-color: #1969FF; + } + + [frequency][frequency!=0][voltage<15000], + ["proposed_frequency"!=0]["proposed_voltage"<15000], + ["construction_frequency"!=0]["construction_voltage"<15000] { + line-color: #97FF2F; + } + + [frequency][frequency!=0][voltage>=15000][voltage<25000], + ["proposed_frequency"!=0]["proposed_voltage">15000]["proposed_voltage"<25000], + ["construction_frequency"!=0]["construction_voltage">15000]["construction_voltage"<25000] { + line-color: #F1F100; + } + + [frequency="16.67"]["voltage"=15000], + ["proposed_frequency"="16.67"]["proposed_voltage"=15000], + ["construction_frequency"="16.67"]["construction_voltage"=15000] { + line-color: #00FF00; + } + + [frequency="16.7"]["voltage"=15000], + ["proposed_frequency"="16.7"]["proposed_voltage"=15000], + ["construction_frequency"="16.7"]["construction_voltage"=15000] { + line-color: #00CB66; + } + + [frequency][frequency!=0][voltage>=25000], + ["proposed_frequency"!=0]["proposed_voltage">25000], + ["construction_frequency"!=0]["construction_voltage">25000] { + line-color: #FF9F19; + } + + ["frequency"=50]["voltage"=25000], + ["proposed_frequency"=50]["proposed_voltage"=25000], + ["construction_frequency"=50]["construction_voltage"=25000] { + line-color: #FF0000; + } + + ["frequency"=60]["voltage"=25000], + ["proposed_frequency"=60]["proposed_voltage"=25000], + ["construction_frequency"=60]["construction_voltage"=25000] { + line-color: #C00000; + } + /* [disused!=null], + [construction!=null] { + comp-op: screen; + }*/ + } +} + +#railway_line_text[zoom>=14] { + [railway="rail"], + [railway="construction"][construction_railway="rail"], + [railway="disused"][disused_railway="rail"], + [zoom>=11][railway="narrow_gauge"], + [zoom>=11][railway="construction"][construction_railway="narrow_gauge"], + [zoom>=11][railway="disused"][disused_railway="narrow_gauge"], + [zoom>=12][railway="light_rail"], + [zoom>=12][railway="construction"][construction_railway="light_rail"], + [zoom>=12][railway="disused"][disused_railway="light_rail"], + [zoom>=12][railway="subway"], + [zoom>=12][railway="construction"][construction_railway="subway"], + [zoom>=12][railway="disused"][disused_railway="subway"], + [zoom>=13][railway="tram"], + [zoom>=13][railway="construction"][construction_railway="tram"], + [zoom>=13][railway="disused"][disused_railway="tram"] { + text-name: [label]; + text-face-name: @bold-fonts; + text-size: 11; + text-placement: line; + text-spacing: 100; + text-min-distance: 30; + text-halo-radius: @text-halo-radius; + text-halo-fill: @text-halo-color; + } +} diff --git a/sql/osm_carto_views.sql b/sql/osm_carto_views.sql index 6a57b15d..140e4331 100644 --- a/sql/osm_carto_views.sql +++ b/sql/osm_carto_views.sql @@ -13,6 +13,13 @@ CREATE OR REPLACE VIEW openrailwaymap_osm_line AS tags->'maxspeed:forward' AS maxspeed_forward, tags->'maxspeed:backward' AS maxspeed_backward, tags->'railway:preferred_direction' AS preferred_direction, + tags->'electrified' AS electrified, + tags->'frequency' AS frequency, + tags->'construction:electrified' AS construction_electrified, + tags->'construction:frequency' AS construction_frequency, + tags->'proposed:electrified' AS proposed_electrified, + tags->'proposed:frequency' AS proposed_frequency, + tags->'deelectrified' AS deelectrified, ref, name, layer, From c05ffbf3d48dd851294b7549e02c33575acc3f41 Mon Sep 17 00:00:00 2001 From: Michael Reichert Date: Wed, 22 Jan 2020 13:40:47 +0100 Subject: [PATCH 02/19] fix MSS --- electrification.mss | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/electrification.mss b/electrification.mss index ce0240f1..052e0b3a 100644 --- a/electrification.mss +++ b/electrification.mss @@ -57,13 +57,13 @@ ["proposed_electrified"="no"], ["construction_electrified"="no"] { line-color: black; - } - ["electrified"="no"]["deelectrified"!="null"][deelectrified!=no], - ["electrified"="no"]["abandoned:electrified"]["abandoned:electrified"!=no] { + } + ["electrified"="no"]["deelectrified"!=null]["deelectrified"!="no"], + ["electrified"="no"]["abandoned_electrified"!=null]["abandoned_electrified"!="no"] { line-color: #70584D; } - ["frequency"=0][voltage<750], + ["frequency"=0]["voltage"<750], ["proposed_frequency"=0]["proposed_voltage"<750], ["construction_frequency"=0]["construction_voltage"<750] { line-color: #FF79B8; @@ -117,13 +117,13 @@ line-color: #1969FF; } - [frequency][frequency!=0][voltage<15000], + ["frequency"!=null]["frequency"!="0"][voltage<15000], ["proposed_frequency"!=0]["proposed_voltage"<15000], ["construction_frequency"!=0]["construction_voltage"<15000] { line-color: #97FF2F; } - [frequency][frequency!=0][voltage>=15000][voltage<25000], + ["frequency"=null][frequency!=0][voltage>=15000][voltage<25000], ["proposed_frequency"!=0]["proposed_voltage">15000]["proposed_voltage"<25000], ["construction_frequency"!=0]["construction_voltage">15000]["construction_voltage"<25000] { line-color: #F1F100; @@ -141,7 +141,7 @@ line-color: #00CB66; } - [frequency][frequency!=0][voltage>=25000], + ["frequency"=null][frequency!=0][voltage>=25000], ["proposed_frequency"!=0]["proposed_voltage">25000], ["construction_frequency"!=0]["construction_voltage">25000] { line-color: #FF9F19; From e8bc1be3da78422546e0eae1ef3bdf26218e8fc8 Mon Sep 17 00:00:00 2001 From: Michael Reichert Date: Wed, 22 Jan 2020 13:41:00 +0100 Subject: [PATCH 03/19] Make SQL of electrification style work * Add missing fields in SQL queries and views * Add missing functions * Remove maxspeed stuff --- electrification.mml | 60 +++++++++++++++++++++++------------------ sql/functions.sql | 9 +++++++ sql/osm_carto_views.sql | 4 +++ 3 files changed, 47 insertions(+), 26 deletions(-) diff --git a/electrification.mml b/electrification.mml index 1a0c6769..a110db17 100644 --- a/electrification.mml +++ b/electrification.mml @@ -68,6 +68,7 @@ Layer: END AS rank, electrified, frequency, + voltage, construction_electrified, construction_frequency, proposed_electrified, @@ -81,6 +82,7 @@ Layer: tags->'construction:railway' AS construction_railway, electrified, frequency, + voltage, construction_electrified, construction_frequency, proposed_electrified, @@ -102,8 +104,6 @@ Layer: table: |- (SELECT way, railway, usage, - -- speeds are converted to kph in this layer because it is used for colouring - railway_dominant_speed(preferred_direction, maxspeed, maxspeed_forward, maxspeed_backward) AS maxspeed, NULL AS service, NULL AS disused, NULL AS construction, NULL AS disused_railway, @@ -118,24 +118,29 @@ Layer: END AS rank, electrified, frequency, + voltage, construction_electrified, construction_frequency, + construction_voltage, proposed_electrified, proposed_frequency, - railway_no_to_null(deelectrified), + proposed_voltage, + abandoned_electrified, + deelectrified, + railway_no_to_null(deelectrified) FROM (SELECT way, railway, usage, - maxspeed, - maxspeed_forward, - maxspeed_backward, - preferred_direction, electrified, frequency, + voltage, construction_electrified, construction_frequency, + construction_voltage, proposed_electrified, proposed_frequency, + proposed_voltage, + abandoned_electrified, deelectrified, z_order FROM openrailwaymap_osm_line @@ -143,8 +148,7 @@ Layer: ) AS r ORDER BY z_order, - rank NULLS LAST, - maxspeed ASC NULLS FIRST + rank NULLS LAST ) AS openrailwaymap_line_low properties: maxzoom: 7 @@ -156,8 +160,6 @@ Layer: table: |- (SELECT way, railway, usage, - -- speeds are converted to kph in this layer because it is used for colouring - railway_dominant_speed(preferred_direction, maxspeed, maxspeed_forward, maxspeed_backward) AS maxspeed, NULL AS service, NULL AS disused, NULL AS construction, NULL AS disused_railway, @@ -172,24 +174,29 @@ Layer: END AS rank, electrified, frequency, + voltage, construction_electrified, construction_frequency, + construction_voltage, proposed_electrified, proposed_frequency, + proposed_voltage, + abandoned_electrified, + deelectrified, railway_no_to_null(deelectrified) FROM (SELECT way, railway, usage, - maxspeed, - maxspeed_forward, - maxspeed_backward, - preferred_direction, electrified, frequency, + voltage, construction_electrified, construction_frequency, + construction_voltage, proposed_electrified, proposed_frequency, + proposed_voltage, + abandoned_electrified, deelectrified, z_order FROM openrailwaymap_osm_line @@ -197,8 +204,7 @@ Layer: ) AS r ORDER BY z_order, - rank NULLS LAST, - maxspeed ASC NULLS FIRST + rank NULLS LAST ) AS railway_line_med properties: minzoom: 8 @@ -211,8 +217,6 @@ Layer: table: |- (SELECT way, railway, usage, service, - -- speeds are converted to kph in this layer because it is used for colouring - railway_dominant_speed(preferred_direction, maxspeed, maxspeed_forward, maxspeed_backward) AS maxspeed, disused, construction, disused_railway, construction_railway, @@ -237,17 +241,18 @@ Layer: END AS rank, electrified, frequency, + voltage, construction_electrified, construction_frequency, + construction_voltage, proposed_electrified, - proposed_frequency + proposed_frequency, + proposed_voltage, + abandoned_electrified, + deelectrified FROM (SELECT way, railway, usage, service, - maxspeed, - maxspeed_forward, - maxspeed_backward, - preferred_direction, tags->'disused' AS disused, construction, tags->'disused:railway' AS disused_railway, tags->'construction:railway' AS construction_railway, @@ -257,10 +262,14 @@ Layer: tags->'preserved:usage' AS preserved_usage, electrified, frequency, + voltage, construction_electrified, construction_frequency, + construction_voltage, proposed_electrified, proposed_frequency, + proposed_voltage, + abandoned_electrified, deelectrified, z_order FROM openrailwaymap_osm_line @@ -268,8 +277,7 @@ Layer: ) AS r ORDER BY z_order, - rank NULLS LAST, - maxspeed ASC NULLS FIRST + rank NULLS LAST ) AS railway_line_fill properties: minzoom: 9 diff --git a/sql/functions.sql b/sql/functions.sql index b08bd1c0..c4ad1693 100644 --- a/sql/functions.sql +++ b/sql/functions.sql @@ -1,3 +1,12 @@ +CREATE OR REPLACE FUNCTION railway_no_to_null(value TEXT) RETURNS TEXT AS $$ +BEGIN + IF value = 'no' THEN + RETURN NULL; + END IF; + RETURN value; +END; +$$ LANGUAGE plpgsql; + CREATE OR REPLACE FUNCTION railway_get_first_pos(pos_value TEXT) RETURNS TEXT AS $$ DECLARE pos_part1 TEXT; diff --git a/sql/osm_carto_views.sql b/sql/osm_carto_views.sql index 140e4331..d9f70e35 100644 --- a/sql/osm_carto_views.sql +++ b/sql/osm_carto_views.sql @@ -15,11 +15,15 @@ CREATE OR REPLACE VIEW openrailwaymap_osm_line AS tags->'railway:preferred_direction' AS preferred_direction, tags->'electrified' AS electrified, tags->'frequency' AS frequency, + tags->'voltage' AS voltage, tags->'construction:electrified' AS construction_electrified, tags->'construction:frequency' AS construction_frequency, + tags->'construction:voltage' AS construction_voltage, tags->'proposed:electrified' AS proposed_electrified, tags->'proposed:frequency' AS proposed_frequency, + tags->'proposed:voltage' AS proposed_voltage, tags->'deelectrified' AS deelectrified, + tags->'abandoned:electrified' AS abandoned_electrified, ref, name, layer, From f1660465ee4a5f0f1a1d4be1bc393af145b5b5d4 Mon Sep 17 00:00:00 2001 From: Michael Reichert Date: Wed, 22 Jan 2020 16:16:37 +0100 Subject: [PATCH 04/19] treat voltage and frequency as numeric --- electrification.mml | 36 ++++++++++++++++++------------------ sql/functions.sql | 9 +++++++++ 2 files changed, 27 insertions(+), 18 deletions(-) diff --git a/electrification.mml b/electrification.mml index a110db17..aff92329 100644 --- a/electrification.mml +++ b/electrification.mml @@ -132,14 +132,14 @@ Layer: (SELECT way, railway, usage, electrified, - frequency, - voltage, + railway_to_float(frequency) AS frequency, + railway_to_float(voltage) AS voltage, construction_electrified, - construction_frequency, - construction_voltage, + railway_to_float(construction_frequency) AS construction_frequency, + railway_to_float(construction_voltage) AS construction_voltage, proposed_electrified, - proposed_frequency, - proposed_voltage, + railway_to_float(proposed_frequency) AS proposed_frequency, + railway_to_float(proposed_voltage) AS proposed_voltage, abandoned_electrified, deelectrified, z_order @@ -188,14 +188,14 @@ Layer: (SELECT way, railway, usage, electrified, - frequency, - voltage, + railway_to_float(frequency) AS frequency, + railway_to_float(voltage) AS voltage, construction_electrified, - construction_frequency, - construction_voltage, + railway_to_float(construction_frequency) AS construction_frequency, + railway_to_float(construction_voltage) AS construction_voltage, proposed_electrified, - proposed_frequency, - proposed_voltage, + railway_to_float(proposed_frequency) AS proposed_frequency, + railway_to_float(proposed_voltage) AS proposed_voltage, abandoned_electrified, deelectrified, z_order @@ -261,14 +261,14 @@ Layer: tags->'preserved:railway' AS preserved_railway, tags->'preserved:service' AS preserved_service, tags->'preserved:usage' AS preserved_usage, electrified, - frequency, - voltage, + railway_to_float(frequency) AS frequency, + railway_to_float(voltage) AS voltage, construction_electrified, - construction_frequency, - construction_voltage, + railway_to_float(construction_frequency) AS construction_frequency, + railway_to_float(construction_voltage) AS construction_voltage, proposed_electrified, - proposed_frequency, - proposed_voltage, + railway_to_float(proposed_frequency) AS proposed_frequency, + railway_to_float(proposed_voltage) AS proposed_voltage, abandoned_electrified, deelectrified, z_order diff --git a/sql/functions.sql b/sql/functions.sql index c4ad1693..67b1a833 100644 --- a/sql/functions.sql +++ b/sql/functions.sql @@ -7,6 +7,15 @@ BEGIN END; $$ LANGUAGE plpgsql; +CREATE OR REPLACE FUNCTION railway_to_float(value TEXT) RETURNS FLOAT AS $$ +BEGIN + IF value ~ '^[0-9.]+$' THEN + RETURN value::FLOAT; + END IF; + RETURN NULL; +END; +$$ LANGUAGE plpgsql; + CREATE OR REPLACE FUNCTION railway_get_first_pos(pos_value TEXT) RETURNS TEXT AS $$ DECLARE pos_part1 TEXT; From 2ee711c2e30904a5e09813b862b1d8268916e379 Mon Sep 17 00:00:00 2001 From: Michael Reichert Date: Wed, 22 Jan 2020 16:16:54 +0100 Subject: [PATCH 05/19] voltage and frequency are numeric fields, user correct comparisons --- electrification.mss | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/electrification.mss b/electrification.mss index 052e0b3a..0de22ecb 100644 --- a/electrification.mss +++ b/electrification.mss @@ -117,7 +117,7 @@ line-color: #1969FF; } - ["frequency"!=null]["frequency"!="0"][voltage<15000], + ["frequency"!=null]["frequency"!=0][voltage<15000], ["proposed_frequency"!=0]["proposed_voltage"<15000], ["construction_frequency"!=0]["construction_voltage"<15000] { line-color: #97FF2F; @@ -129,15 +129,15 @@ line-color: #F1F100; } - [frequency="16.67"]["voltage"=15000], - ["proposed_frequency"="16.67"]["proposed_voltage"=15000], - ["construction_frequency"="16.67"]["construction_voltage"=15000] { + [frequency=16.67]["voltage"=15000], + ["proposed_frequency"=16.67]["proposed_voltage"=15000], + ["construction_frequency"=16.67]["construction_voltage"=15000] { line-color: #00FF00; } - [frequency="16.7"]["voltage"=15000], - ["proposed_frequency"="16.7"]["proposed_voltage"=15000], - ["construction_frequency"="16.7"]["construction_voltage"=15000] { + [frequency=16.7]["voltage"=15000], + ["proposed_frequency"=16.7]["proposed_voltage"=15000], + ["construction_frequency"=16.7]["construction_voltage"=15000] { line-color: #00CB66; } From ef91683e78155b6f299e587bb3cb0c87964e7782 Mon Sep 17 00:00:00 2001 From: Michael Reichert Date: Wed, 22 Jan 2020 16:25:54 +0100 Subject: [PATCH 06/19] Improve performance of CartoCSS transpilation with Carto Before: 909 kB 57 seconds, afterwards 724 kB 15 seconds --- electrification.mss | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/electrification.mss b/electrification.mss index 0de22ecb..c0483c4e 100644 --- a/electrification.mss +++ b/electrification.mss @@ -25,8 +25,8 @@ ["railway"="rail"]["usage"="main"]["service"=null], [zoom>=8]["railway"="rail"]["usage"="branch"]["service"=null], [zoom=10]["railway"="rail"]["usage"="industrial"]["service"=null], - [zoom>=11]["railway"="rail"]["usage"="industrial"], [zoom>=13]["railway"="rail"]["usage"=null]["service"=null], + [zoom>=11]["railway"="rail"]["usage"="industrial"], [zoom>=11]["railway"="rail"]["usage"=null]["service"="siding"], [zoom>=11]["railway"="rail"]["usage"=null]["service"="crossover"], [zoom>=12]["railway"="rail"]["usage"=null]["service"="yard"], @@ -40,19 +40,20 @@ [zoom>=11]["railway"="disused"]["disused_railway"="subway"]["service"=null], [zoom>=11]["railway"="disused"]["disused_railway"="light_rail"]["service"=null], [zoom>=12]["railway"="disused"]["disused_railway"="tram"]["service"=null], - [zoom>=13]["railway"="disused"], + /* service!=null is required to get a smaller Mapnik XML style with the Carto compiler. */ + [zoom>=13]["railway"="disused"]["service"!=null], [zoom>=9]["railway"="construction"]["construction_railway"="rail"]["usage"="main"]["service"=null], [zoom>=9]["railway"="construction"]["construction_railway"="rail"]["usage"="branch"]["service"=null], [zoom>=10]["railway"="construction"]["construction_railway"="subway"]["service"=null], [zoom>=10]["railway"="construction"]["construction_railway"="light_rail"]["service"=null], [zoom>=11]["railway"="construction"]["construction_railway"="tram"]["service"=null], - [zoom>=13]["railway"="construction"], + [zoom>=13]["railway"="construction"]["service"!=null], [zoom>=10]["railway"="subway"]["service"=null], - [zoom>=13]["railway"="subway"], + [zoom>=13]["railway"="subway"]["service"!=null], [zoom>=10]["railway"="light_rail"]["service"=null], - [zoom>=13]["railway"="light_rail"], + [zoom>=13]["railway"="light_rail"]["service"!=null], [zoom>=11]["railway"="tram"]["service"=null], - [zoom>=13]["railway"="tram"] { + [zoom>=13]["railway"="tram"]["service"!=null] { ["electrified"="no"], ["proposed_electrified"="no"], ["construction_electrified"="no"] { From 85c6913d4f9f6d2630c0a476a9392b6ecda37c09 Mon Sep 17 00:00:00 2001 From: Michael Reichert Date: Mon, 17 Feb 2020 20:52:11 +0100 Subject: [PATCH 07/19] Add labels of railway tracks to electrification style --- electrification.mml | 105 ++++++++++++++++++++++++++++++++++++++++++++ electrification.mss | 3 +- sql/functions.sql | 59 +++++++++++++++++++++++++ 3 files changed, 166 insertions(+), 1 deletion(-) diff --git a/electrification.mml b/electrification.mml index aff92329..1f80a4da 100644 --- a/electrification.mml +++ b/electrification.mml @@ -281,3 +281,108 @@ Layer: ) AS railway_line_fill properties: minzoom: 9 + - id: railway_text_med + geometry: line + <<: *extents + Datasource: + <<: *osm2pgsql + table: |- + (SELECT + way, railway, usage, service, + tags->'disused' AS disused, + construction, + tags->'disused:railway' AS disused_railway, + tags->'construction:railway' AS construction_railway, + CASE WHEN railway = 'rail' AND usage IN ('usage', 'military', 'test') AND service IS NULL THEN 400 + WHEN railway = 'rail' AND usage IS NULL AND service IS NULL THEN 400 + WHEN railway = 'rail' AND usage IS NULL AND service = 'siding' THEN 870 + WHEN railway = 'rail' AND usage IS NULL AND service = 'yard' THEN 860 + WHEN railway = 'rail' AND usage IS NULL AND service = 'spur' THEN 880 + WHEN railway = 'rail' AND usage IS NULL AND service = 'crossover' THEN 300 + WHEN railway = 'rail' AND usage = 'main' AND service IS NULL THEN 1100 + WHEN railway = 'rail' AND usage = 'branch' AND service IS NULL THEN 1000 + WHEN railway = 'rail' AND usage = 'industrial' AND service IS NULL THEN 850 + WHEN railway = 'rail' AND usage = 'industrial' AND service IN ('siding', 'spur', 'yard', 'crossover') THEN 850 + WHEN railway IN ('preserved', 'construction') THEN 400 + WHEN railway = 'disused' THEN 300 + ELSE 50 + END AS rank, + z_order, + railway_electrification_label(electrified, deelectrified, construction_electrified, proposed_electrified, voltage, frequency, construction_voltage, construction_frequency, proposed_voltage, proposed_frequency) AS label, + electrified, + frequency, + voltage, + construction_electrified, + construction_frequency, + construction_voltage, + proposed_electrified, + proposed_frequency, + proposed_voltage, + abandoned_electrified, + deelectrified + FROM openrailwaymap_osm_line + WHERE + railway IN ('rail', 'disused', 'construction') + AND ( + electrified IS NOT NULL + OR deelectrified IS NOT NULL + OR construction_electrified IS NOT NULL + OR proposed_electrified IS NOT NULL + ) + ORDER by z_order, rank NULLS LAST + ) AS railway_text_high + properties: + minzoom: 8 + maxzoom: 10 + - id: railway_text_high + geometry: line + <<: *extents + Datasource: + <<: *osm2pgsql + table: |- + (SELECT + way, railway, usage, service, + tags->'disused' AS disused, + construction, + tags->'disused:railway' AS disused_railway, + tags->'construction:railway' AS construction_railway, + CASE WHEN railway = 'rail' AND usage IN ('usage', 'military', 'test') AND service IS NULL THEN 400 + WHEN railway = 'rail' AND usage IS NULL AND service IS NULL THEN 400 + WHEN railway = 'rail' AND usage IS NULL AND service = 'siding' THEN 870 + WHEN railway = 'rail' AND usage IS NULL AND service = 'yard' THEN 860 + WHEN railway = 'rail' AND usage IS NULL AND service = 'spur' THEN 880 + WHEN railway = 'rail' AND usage IS NULL AND service = 'crossover' THEN 300 + WHEN railway = 'rail' AND usage = 'main' AND service IS NULL THEN 1100 + WHEN railway = 'rail' AND usage = 'branch' AND service IS NULL THEN 1000 + WHEN railway = 'rail' AND usage = 'industrial' AND service IS NULL THEN 850 + WHEN railway = 'rail' AND usage = 'industrial' AND service IN ('siding', 'spur', 'yard', 'crossover') THEN 850 + WHEN railway IN ('preserved', 'construction') THEN 400 + WHEN railway = 'disused' THEN 300 + ELSE 50 + END AS rank, + z_order, + railway_electrification_label(electrified, deelectrified, construction_electrified, proposed_electrified, voltage, frequency, construction_voltage, construction_frequency, proposed_voltage, proposed_frequency) AS label, + electrified, + frequency, + voltage, + construction_electrified, + construction_frequency, + construction_voltage, + proposed_electrified, + proposed_frequency, + proposed_voltage, + abandoned_electrified, + deelectrified + FROM openrailwaymap_osm_line + WHERE + railway IN ('rail', 'tram', 'light_rail', 'subway', 'narrow_gauge', 'disused', 'construction') + AND ( + electrified IS NOT NULL + OR deelectrified IS NOT NULL + OR construction_electrified IS NOT NULL + OR proposed_electrified IS NOT NULL + ) + ORDER by z_order, rank NULLS LAST + ) AS railway_text_high + properties: + minzoom: 11 diff --git a/electrification.mss b/electrification.mss index c0483c4e..b8c0316d 100644 --- a/electrification.mss +++ b/electrification.mss @@ -166,7 +166,8 @@ } } -#railway_line_text[zoom>=14] { +#railway_text_med[zoom<=10], +#railway_text_high[zoom>=11] { [railway="rail"], [railway="construction"][construction_railway="rail"], [railway="disused"][disused_railway="rail"], diff --git a/sql/functions.sql b/sql/functions.sql index 67b1a833..2f5665e6 100644 --- a/sql/functions.sql +++ b/sql/functions.sql @@ -16,6 +16,15 @@ BEGIN END; $$ LANGUAGE plpgsql; +CREATE OR REPLACE FUNCTION railway_to_int(value TEXT) RETURNS INTEGER AS $$ +BEGIN + IF value ~ '^-?[0-9]+$' THEN + RETURN value::INTEGER; + END IF; + RETURN NULL; +END; +$$ LANGUAGE plpgsql; + CREATE OR REPLACE FUNCTION railway_get_first_pos(pos_value TEXT) RETURNS TEXT AS $$ DECLARE pos_part1 TEXT; @@ -343,3 +352,53 @@ BEGIN RETURN name; END; $$ LANGUAGE plpgsql; + +-- Get label for electrification +CREATE OR REPLACE FUNCTION railway_electrification_label(electrified TEXT, deelectrified TEXT, + construction_electrified TEXT, proposed_electrified TEXT, voltage TEXT, frequency TEXT, + construction_voltage TEXT, construction_frequency TEXT, proposed_voltage TEXT, + proposed_frequency TEXT) RETURNS TEXT AS $$ +DECLARE + volt TEXT; + freq TEXT; + volt_int INTEGER; + kilovolt NUMERIC(3, 1); + volt_text TEXT; + freq_text TEXT; +BEGIN + -- Select right values for voltage and frequency part of the label + IF railway_no_to_null(electrified) IS NOT NULL OR railway_no_to_null(deelectrified) IS NOT NULL THEN + volt := voltage; + freq := frequency; + ELSIF railway_no_to_null(construction_electrified) IS NOT NULL THEN + volt := construction_voltage; + freq := construction_frequency; + ELSIF railway_no_to_null(proposed_electrified) IS NOT NULL THEN + volt := proposed_voltage; + freq := proposed_frequency; + ELSE + RETURN NULL; + END IF; + -- Grounded sections + IF volt = '0' THEN + RETURN '0V'; + END IF; + -- Round voltage nicely + volt_int := railway_to_int(volt); + IF volt_int < 1000 THEN + volt_text := volt || 'V'; + ELSIF volt_int % 1000 = 0 THEN + volt_text := (volt_int/1000)::TEXT || 'kV'; + ELSE + volt_text := (volt_int::FLOAT / 1000::FLOAT)::NUMERIC(3, 1)::TEXT || 'kV'; + END IF; + -- Output voltage and frequency + IF freq = '0' OR freq IS NULL THEN + RETURN volt_text || ' ='; + END IF; + IF freq IS NOT NULL THEN + RETURN volt_text || ' ' || freq || 'Hz'; + END IF; + RETURN volt_text; +END; +$$ LANGUAGE plpgsql; From bc244f8d19351ec29ea129a2c13cb9704164d10f Mon Sep 17 00:00:00 2001 From: Michael Reichert Date: Wed, 19 Feb 2020 15:34:58 +0100 Subject: [PATCH 08/19] Add electrification signals --- electrification.mml | 22 +++++++ electrification_signals.mss | 127 ++++++++++++++++++++++++++++++++++++ 2 files changed, 149 insertions(+) create mode 100644 electrification_signals.mss diff --git a/electrification.mml b/electrification.mml index 1f80a4da..01ac678a 100644 --- a/electrification.mml +++ b/electrification.mml @@ -37,6 +37,7 @@ _parts: Stylesheet: - fonts.mss + - electrification_signals.mss - electrification.mss - common.mss @@ -281,6 +282,27 @@ Layer: ) AS railway_line_fill properties: minzoom: 9 + - id: electrification-signals + geometry: point + <<: *extents + Datasource: + <<: *osm2pgsql + table: |- + (SELECT + way, + railway, + tags->'railway:signal:electricity' AS signal_electricity, + tags->'railway:signal:electricity:form' AS electricity_form, + tags->'railway:signal:electricity:turn_direction' AS electricity_turn_direction, + tags->'railway:signal:electricity:type' AS electricity_type, + signal_direction + FROM openrailwaymap_osm_signals + WHERE + railway = 'signal' + AND tags ? 'railway:signal:electricity' + ) AS railway_signals + properties: + minzoom: 15 - id: railway_text_med geometry: line <<: *extents diff --git a/electrification_signals.mss b/electrification_signals.mss new file mode 100644 index 00000000..dbbe0039 --- /dev/null +++ b/electrification_signals.mss @@ -0,0 +1,127 @@ +@de-el-size: 18; +@de-el-size-with-arrow: @de-el-size * 1.286; + +#electrification-signals[zoom>=17] { + ["signal_direction"!=null] { + /*************************************/ + /* DE pantograph down advance El 3 */ + /* AT Ankündigung Stromabnehmer tief */ + /*************************************/ + ["electricity_type"="pantograph_down_advance"]["electricity_form"="sign"] { + ["signal_electricity"="DE-ESO:el3"], + ["signal_electricity"="AT-V2:andkündigung_stromabnehmer_tief"] { + marker-file: url("symbols/de/el3.svg"); + marker-width: @de-el-size; + marker-height: @de-el-size; + marker-allow-overlap: true; + } + } + + /************************************/ + /* DE power off advance sign El 1v */ + /* AT Ankündigung Hauptschalter aus */ + /************************************/ + ["electricity_type"="power_off_advance"]["electricity_form"="sign"] { + ["signal_electricity"="DE-ESO:el1v"], + ["signal_electricity"="AT-V2:ankündigung_hauptschalter_aus"] { + marker-file: url("symbols/de/el1v.svg"); + marker-width: @de-el-size; + marker-height: @de-el-size; + marker-allow-overlap: true; + } + } + + /*******************************************************/ + /* DE end of catenary sign El 6 */ + /* AT Halt für Fahrzeuge mit angehobenem Stromabnehmer */ + /*******************************************************/ + ["electricity_type"="end_of_catenary"]["electricity_form"="sign"] { + ["signal_electricity"="DE-ESO:el6"], + ["signal_electricity"="AT-V2:halt_fuer_fahrzeuge_mit_angehobenem_stromabnehmer"] { + marker-file: url("symbols/de/el6.svg"); + marker-width: @de-el-size; + marker-height: @de-el-size; + marker-allow-overlap: true; + + ["electricity_turn_direction"="right"] { + marker-file: url("symbols/de/el6-right.svg"); + marker-width: @de-el-size; + marker-height: @de-el-size-with-arrow; + } + + ["electricity_turn_direction"="left"] { + marker-file: url("symbols/de/el6-left.svg"); + marker-width: @de-el-size; + marker-height: @de-el-size-with-arrow; + } + } + } + + /**************************/ + /* DE power on sign El 2 */ + /* AT Hauptschalter ein */ + /**************************/ + ["electricity_type"="power_on"]["electricity_form"="sign"] { + ["signal_electricity"="DE-ESO:el2"], + ["signal_electricity"="AT-V2:hauptschalter_ein"] { + marker-file: url("symbols/de/el2.svg"); + marker-width: @de-el-size; + marker-height: @de-el-size; + marker-allow-overlap: true; + } + } + + /*************************/ + /* DE pantograph up El 5 */ + /* AT Stromabnehmer hoch */ + /*************************/ + ["electricity_type"="pantograph_up"]["electricity_form"="sign"] { + ["signal_electricity"="DE-ESO:el5"], + ["signal_electricity"="AT-V2:stromabnehmer_hoch"] { + marker-file: url("symbols/de/el5.svg"); + marker-width: @de-el-size; + marker-height: @de-el-size; + marker-allow-overlap: true; + } + } + + /**************************/ + /* DE power off sign El 1 */ + /* AT Hauptschalter aus */ + /**************************/ + ["electricity_type"="power_off"]["electricity_form"="sign"] { + ["signal_electricity"="DE-ESO:el1"], + ["signal_electricity"="AT-V2:hauptschalter_aus"] { + marker-file: url("symbols/de/el1.svg"); + marker-width: @de-el-size; + marker-height: @de-el-size; + marker-allow-overlap: true; + } + } + + /***************************/ + /* DE pantograph down El 4 */ + /* AT Stromabnehmer tief */ + /***************************/ + ["electricity_type"="pantograph_down"]["electricity_form"="sign"] { + ["signal_electricity"="DE-ESO:el4"], + ["signal_electricity"="AT-V2:stromabnehmer_tief"] { + marker-file: url("symbols/de/el4.svg"); + marker-width: @de-el-size; + marker-height: @de-el-size; + marker-allow-overlap: true; + } + } + } + + /*******************************************/ + /* DE tram power off shortly signal (St 7) */ + /*******************************************/ + ["signal_electricity"="DE-BOStrab:st7"]["electricity_type"="power_off_shortly"]["electricity_form"="sign"], + ["signal_electricity"="DE-AVG:st7"]["electricity_type"="power_off_shortly"]["electricity_form"="sign"] { + marker-file: url("symbols/de/bostrab/st7.svg"); + marker-width: 11; + marker-height: 12; + marker-allow-overlap: true; + } +} From 76c5ba05e55b679217089eb2dcbf8c1d6c94c11b Mon Sep 17 00:00:00 2001 From: Michael Reichert Date: Mon, 24 Feb 2020 16:57:19 +0100 Subject: [PATCH 09/19] Add dashing for proposed electrification and those under construction This requires preprocessing with SQL because otherwise we would end up with transpilation times of more than 4 minutes and 6.5 MB XML instead of 737 kB. --- electrification.mml | 21 ++------ electrification.mss | 116 ++++++++++++++++++-------------------------- sql/functions.sql | 61 +++++++++++++++++++++++ 3 files changed, 112 insertions(+), 86 deletions(-) diff --git a/electrification.mml b/electrification.mml index 01ac678a..66e0761f 100644 --- a/electrification.mml +++ b/electrification.mml @@ -173,32 +173,19 @@ Layer: WHEN railway = 'rail' AND usage = 'branch' THEN 1000 ELSE 50 END AS rank, - electrified, - frequency, - voltage, - construction_electrified, - construction_frequency, - construction_voltage, - proposed_electrified, - proposed_frequency, - proposed_voltage, - abandoned_electrified, - deelectrified, - railway_no_to_null(deelectrified) + electrification_state AS state, + railway_voltage_for_state(electrification_state, voltage, construction_voltage, proposed_voltage) AS voltage, + railway_frequency_for_state(electrification_state, frequency, construction_frequency, proposed_frequency) AS frequency FROM (SELECT way, railway, usage, - electrified, + railway_electrification_state(electrified, deelectrified, abandoned_electrified, construction_electrified, proposed_electrified) AS electrification_state, railway_to_float(frequency) AS frequency, railway_to_float(voltage) AS voltage, - construction_electrified, railway_to_float(construction_frequency) AS construction_frequency, railway_to_float(construction_voltage) AS construction_voltage, - proposed_electrified, railway_to_float(proposed_frequency) AS proposed_frequency, railway_to_float(proposed_voltage) AS proposed_voltage, - abandoned_electrified, - deelectrified, z_order FROM openrailwaymap_osm_line WHERE railway = 'rail' AND usage = 'main' AND service IS NULL diff --git a/electrification.mss b/electrification.mss index b8c0316d..84f5e00e 100644 --- a/electrification.mss +++ b/electrification.mss @@ -1,6 +1,9 @@ @text-halo-color: white; @text-halo-radius: 1; +@construction-dashes: 5,5; +@proposed-dashes: 2,8; + @color_no: black; @color_delectrified: #70584D; @color_lt750v_dc: #FF79B8; @@ -54,109 +57,84 @@ [zoom>=13]["railway"="light_rail"]["service"!=null], [zoom>=11]["railway"="tram"]["service"=null], [zoom>=13]["railway"="tram"]["service"!=null] { - ["electrified"="no"], - ["proposed_electrified"="no"], - ["construction_electrified"="no"] { + ["state"="no"] { line-color: black; } - ["electrified"="no"]["deelectrified"!=null]["deelectrified"!="no"], - ["electrified"="no"]["abandoned_electrified"!=null]["abandoned_electrified"!="no"] { + + ["state"="deelectrified"], + ["state"="abandoned"] { line-color: #70584D; } - - ["frequency"=0]["voltage"<750], - ["proposed_frequency"=0]["proposed_voltage"<750], - ["construction_frequency"=0]["construction_voltage"<750] { + + ["state"="construction"] { + line-dasharray: @construction-dashes; + } + + ["state"="proposed"] { + line-dasharray: @proposed-dashes; + } + + ["frequency"=0]["voltage"<750] { line-color: #FF79B8; } - - ["frequency"=0]["voltage"=750], - ["proposed_frequency"=0]["proposed_voltage"=750], - ["construction_frequency"=0]["construction_voltage"=750] { + + ["frequency"=0]["voltage"=750] { line-color: #F930FF; } - - ["frequency"=0][voltage>750][voltage<1000], - ["proposed_frequency"=0]["proposed_voltage">750]["proposed_voltage"<1000], - ["construction_frequency"=0]["construction_voltage">750]["construction_voltage"<1000] { + + ["frequency"=0][voltage>750][voltage<1000] { line-color: #D033FF; } - - ["frequency"=0]["voltage"=1000], - ["proposed_frequency"=0]["proposed_voltage"=1000], - ["construction_frequency"=0]["construction_voltage"=1000] { + + ["frequency"=0]["voltage"=1000] { line-color: #5C1CCB; } - - ["frequency"=0][voltage>1000][voltage<1500], - ["proposed_frequency"=0]["proposed_voltage">1000]["proposed_voltage"<1500], - ["construction_frequency"=0]["construction_voltage">1000]["construction_voltage"<1500] { + + ["frequency"=0][voltage>1000][voltage<1500] { line-color: #007ACB; } - - ["frequency"=0]["voltage"=1500], - ["proposed_frequency"=0]["proposed_voltage"=1500], - ["construction_frequency"=0]["construction_voltage"=1500] { + + ["frequency"=0]["voltage"=1500] { line-color: #0098CB; } - - ["frequency"=0][voltage>1500][voltage<3000], - ["proposed_frequency"=0]["proposed_voltage">1500]["proposed_voltage"<3000], - ["construction_frequency"=0]["construction_voltage">1500]["construction_voltage"<3000] { + + ["frequency"=0][voltage>1500][voltage<3000] { line-color: #00B7CB; } - - ["frequency"=0]["voltage"=3000], - ["proposed_frequency"=0]["proposed_voltage"=3000], - ["construction_frequency"=0]["construction_voltage"=3000] { + + ["frequency"=0]["voltage"=3000] { line-color: #0000FF; } - - ["frequency"=0][voltage>3000], - ["proposed_frequency"=0]["proposed_voltage">3000], - ["construction_frequency"=0]["construction_voltage">3000] { + + ["frequency"=0][voltage>3000] { line-color: #1969FF; } - - ["frequency"!=null]["frequency"!=0][voltage<15000], - ["proposed_frequency"!=0]["proposed_voltage"<15000], - ["construction_frequency"!=0]["construction_voltage"<15000] { + + ["frequency"!=null]["frequency"!=0][voltage<15000] { line-color: #97FF2F; } - - ["frequency"=null][frequency!=0][voltage>=15000][voltage<25000], - ["proposed_frequency"!=0]["proposed_voltage">15000]["proposed_voltage"<25000], - ["construction_frequency"!=0]["construction_voltage">15000]["construction_voltage"<25000] { + + ["frequency"=null][frequency!=0][voltage>=15000][voltage<25000] { line-color: #F1F100; } - - [frequency=16.67]["voltage"=15000], - ["proposed_frequency"=16.67]["proposed_voltage"=15000], - ["construction_frequency"=16.67]["construction_voltage"=15000] { + + [frequency=16.67]["voltage"=15000] { line-color: #00FF00; } - - [frequency=16.7]["voltage"=15000], - ["proposed_frequency"=16.7]["proposed_voltage"=15000], - ["construction_frequency"=16.7]["construction_voltage"=15000] { + + [frequency=16.7]["voltage"=15000] { line-color: #00CB66; } - - ["frequency"=null][frequency!=0][voltage>=25000], - ["proposed_frequency"!=0]["proposed_voltage">25000], - ["construction_frequency"!=0]["construction_voltage">25000] { + + ["frequency"=null][frequency!=0][voltage>=25000] { line-color: #FF9F19; } - - ["frequency"=50]["voltage"=25000], - ["proposed_frequency"=50]["proposed_voltage"=25000], - ["construction_frequency"=50]["construction_voltage"=25000] { + + ["frequency"=50]["voltage"=25000] { line-color: #FF0000; } - - ["frequency"=60]["voltage"=25000], - ["proposed_frequency"=60]["proposed_voltage"=25000], - ["construction_frequency"=60]["construction_voltage"=25000] { + + ["frequency"=60]["voltage"=25000] { line-color: #C00000; } /* [disused!=null], diff --git a/sql/functions.sql b/sql/functions.sql index 2f5665e6..48ed6744 100644 --- a/sql/functions.sql +++ b/sql/functions.sql @@ -353,6 +353,67 @@ BEGIN END; $$ LANGUAGE plpgsql; +-- Get state of electrification +CREATE OR REPLACE FUNCTION railway_electrification_state(railway TEXT, electrified TEXT, deelectrified TEXT, abandoned_electrified TEXT, construction_electrified TEXT, proposed_electrified TEXT) RETURNS TEXT AS $$ +DECLARE + state TEXT; + valid_values TEXT[] := ARRAY['contact_line', 'yes', 'rail', 'ground-level_power_supply', '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 construction_electrified = ANY(valid_values) THEN + RETURN 'construction'; + END IF; + IF proposed_electrified = ANY(valid_values) THEN + RETURN 'proposed'; + END IF; + IF state = 'no' AND deelectrified = ANY(valid_values) THEN + RETURN 'deelectrified'; + END IF; + IF state = 'no' AND abandoned_electrified = ANY(valid_values) THEN + RETURN 'abandoned'; + END IF; + RETURN state; +END; +$$ LANGUAGE plpgsql; + +-- Get voltage for given state +CREATE OR REPLACE FUNCTION railway_voltage_for_state(state TEXT, voltage FLOAT, construction_voltage FLOAT, proposed_voltage FLOAT) RETURNS FLOAT AS $$ +BEGIN + IF state = 'present' THEN + RETURN voltage; + END IF; + IF state = 'construction' THEN + RETURN construction_voltage; + END IF; + IF state = 'proposed' THEN + RETURN proposed_voltage; + END IF; + RETURN NULL; +END; +$$ LANGUAGE plpgsql; + +-- Get frequency for given state +CREATE OR REPLACE FUNCTION railway_frequency_for_state(state TEXT, frequency FLOAT, construction_frequency FLOAT, proposed_frequency FLOAT) RETURNS FLOAT AS $$ +BEGIN + IF state = 'present' THEN + RETURN frequency; + END IF; + IF state = 'construction' THEN + RETURN construction_frequency; + END IF; + IF state = 'proposed' THEN + RETURN proposed_frequency; + END IF; + RETURN NULL; +END; +$$ LANGUAGE plpgsql; + -- Get label for electrification CREATE OR REPLACE FUNCTION railway_electrification_label(electrified TEXT, deelectrified TEXT, construction_electrified TEXT, proposed_electrified TEXT, voltage TEXT, frequency TEXT, From 308bb2819eb7e14e620d7efee4af7e00494056e3 Mon Sep 17 00:00:00 2001 From: Michael Reichert Date: Tue, 25 Feb 2020 22:10:46 +0100 Subject: [PATCH 10/19] Fix various bugs in the electrification style * fix bugs in SQL queries * equal minimal zoom levels for lines and labels * fix SQL function --- electrification.mml | 117 ++++++++++++++------------------------------ electrification.mss | 85 +++++++++++++++++++------------- sql/functions.sql | 16 +++--- 3 files changed, 97 insertions(+), 121 deletions(-) diff --git a/electrification.mml b/electrification.mml index 66e0761f..dea6637c 100644 --- a/electrification.mml +++ b/electrification.mml @@ -53,7 +53,7 @@ Layer: disused, construction, disused_railway, construction_railway, - CASE WHEN railway = 'rail' AND usage IN ('usage', 'military', 'test') AND service IS NULL THEN 400 + CASE WHEN railway = 'rail' AND usage IN ('tourism', 'military', 'test') AND service IS NULL THEN 400 WHEN railway = 'rail' AND usage IS NULL AND service IS NULL THEN 400 WHEN railway = 'rail' AND usage IS NULL AND service = 'siding' THEN 870 WHEN railway = 'rail' AND usage IS NULL AND service = 'yard' THEN 860 @@ -113,43 +113,25 @@ Layer: NULL AS construction_usage, NULL AS construction_service, NULL AS preserved_railway, NULL AS preserved_service, NULL AS preserved_usage, - CASE WHEN railway = 'rail' AND usage = 'main' THEN 1100 - WHEN railway = 'rail' AND usage = 'branch' THEN 1000 - ELSE 50 - END AS rank, - electrified, - frequency, - voltage, - construction_electrified, - construction_frequency, - construction_voltage, - proposed_electrified, - proposed_frequency, - proposed_voltage, - abandoned_electrified, - deelectrified, - railway_no_to_null(deelectrified) + electrification_state AS state, + railway_voltage_for_state(electrification_state, voltage, construction_voltage, proposed_voltage) AS voltage, + railway_frequency_for_state(electrification_state, frequency, construction_frequency, proposed_frequency) AS frequency FROM (SELECT way, railway, usage, - electrified, - railway_to_float(frequency) AS frequency, - railway_to_float(voltage) AS voltage, - construction_electrified, - railway_to_float(construction_frequency) AS construction_frequency, - railway_to_float(construction_voltage) AS construction_voltage, - proposed_electrified, - railway_to_float(proposed_frequency) AS proposed_frequency, - railway_to_float(proposed_voltage) AS proposed_voltage, - abandoned_electrified, - deelectrified, + railway_electrification_state(railway, electrified, deelectrified, abandoned_electrified, construction_electrified, proposed_electrified) AS electrification_state, + frequency AS frequency, + voltage AS voltage, + construction_frequency AS construction_frequency, + construction_voltage AS construction_voltage, + proposed_frequency AS proposed_frequency, + proposed_voltage AS proposed_voltage, z_order FROM openrailwaymap_osm_line - WHERE railway = 'rail' AND usage IN ('main', 'branch') AND service IS NULL + WHERE railway = 'rail' AND usage = 'main' AND service IS NULL ) AS r ORDER BY - z_order, - rank NULLS LAST + z_order ) AS openrailwaymap_line_low properties: maxzoom: 7 @@ -179,16 +161,16 @@ Layer: FROM (SELECT way, railway, usage, - railway_electrification_state(electrified, deelectrified, abandoned_electrified, construction_electrified, proposed_electrified) AS electrification_state, - railway_to_float(frequency) AS frequency, - railway_to_float(voltage) AS voltage, - railway_to_float(construction_frequency) AS construction_frequency, - railway_to_float(construction_voltage) AS construction_voltage, - railway_to_float(proposed_frequency) AS proposed_frequency, - railway_to_float(proposed_voltage) AS proposed_voltage, + railway_electrification_state(railway, electrified, deelectrified, abandoned_electrified, construction_electrified, proposed_electrified) AS electrification_state, + frequency AS frequency, + voltage AS voltage, + construction_frequency AS construction_frequency, + construction_voltage AS construction_voltage, + proposed_frequency AS proposed_frequency, + proposed_voltage AS proposed_voltage, z_order FROM openrailwaymap_osm_line - WHERE railway = 'rail' AND usage = 'main' AND service IS NULL + WHERE railway = 'rail' AND usage IN ('main', 'branch') AND service IS NULL ) AS r ORDER BY z_order, @@ -212,7 +194,7 @@ Layer: construction_usage, construction_service, preserved_railway, preserved_service, preserved_usage, - CASE WHEN railway = 'rail' AND usage IN ('usage', 'military', 'test') AND service IS NULL THEN 400 + CASE WHEN railway = 'rail' AND usage IN ('tourism', 'military', 'test') AND service IS NULL THEN 400 WHEN railway = 'rail' AND usage IS NULL AND service IS NULL THEN 400 WHEN railway = 'rail' AND usage IS NULL AND service = 'siding' THEN 870 WHEN railway = 'rail' AND usage IS NULL AND service = 'yard' THEN 860 @@ -224,20 +206,11 @@ Layer: WHEN railway = 'rail' AND usage = 'industrial' AND service IN ('siding', 'spur', 'yard', 'crossover') THEN 850 WHEN railway IN ('preserved', 'construction') THEN 400 WHEN railway = 'disused' THEN 300 - ELSE 50 END AS rank, - electrified, - frequency, - voltage, - construction_electrified, - construction_frequency, - construction_voltage, - proposed_electrified, - proposed_frequency, - proposed_voltage, - abandoned_electrified, - deelectrified + electrification_state AS state, + railway_voltage_for_state(electrification_state, voltage, construction_voltage, proposed_voltage) AS voltage, + railway_frequency_for_state(electrification_state, frequency, construction_frequency, proposed_frequency) AS frequency FROM (SELECT way, railway, usage, service, @@ -248,17 +221,13 @@ Layer: tags->'construction:usage' AS construction_usage, tags->'construction:service' AS construction_service, tags->'preserved:railway' AS preserved_railway, tags->'preserved:service' AS preserved_service, tags->'preserved:usage' AS preserved_usage, - electrified, - railway_to_float(frequency) AS frequency, - railway_to_float(voltage) AS voltage, - construction_electrified, - railway_to_float(construction_frequency) AS construction_frequency, - railway_to_float(construction_voltage) AS construction_voltage, - proposed_electrified, - railway_to_float(proposed_frequency) AS proposed_frequency, - railway_to_float(proposed_voltage) AS proposed_voltage, - abandoned_electrified, - deelectrified, + railway_electrification_state(railway, electrified, deelectrified, abandoned_electrified, construction_electrified, proposed_electrified) AS electrification_state, + frequency AS frequency, + voltage AS voltage, + construction_frequency AS construction_frequency, + construction_voltage AS construction_voltage, + proposed_frequency AS proposed_frequency, + proposed_voltage AS proposed_voltage, z_order FROM openrailwaymap_osm_line WHERE railway IN ('rail', 'tram', 'light_rail', 'subway', 'narrow_gauge', 'disused', 'construction', 'preserved') @@ -302,18 +271,8 @@ Layer: construction, tags->'disused:railway' AS disused_railway, tags->'construction:railway' AS construction_railway, - CASE WHEN railway = 'rail' AND usage IN ('usage', 'military', 'test') AND service IS NULL THEN 400 - WHEN railway = 'rail' AND usage IS NULL AND service IS NULL THEN 400 - WHEN railway = 'rail' AND usage IS NULL AND service = 'siding' THEN 870 - WHEN railway = 'rail' AND usage IS NULL AND service = 'yard' THEN 860 - WHEN railway = 'rail' AND usage IS NULL AND service = 'spur' THEN 880 - WHEN railway = 'rail' AND usage IS NULL AND service = 'crossover' THEN 300 - WHEN railway = 'rail' AND usage = 'main' AND service IS NULL THEN 1100 - WHEN railway = 'rail' AND usage = 'branch' AND service IS NULL THEN 1000 - WHEN railway = 'rail' AND usage = 'industrial' AND service IS NULL THEN 850 - WHEN railway = 'rail' AND usage = 'industrial' AND service IN ('siding', 'spur', 'yard', 'crossover') THEN 850 - WHEN railway IN ('preserved', 'construction') THEN 400 - WHEN railway = 'disused' THEN 300 + CASE WHEN railway = 'rail' AND usage = 'main' THEN 1100 + WHEN railway = 'rail' AND usage = 'branch' THEN 1000 ELSE 50 END AS rank, z_order, @@ -331,7 +290,7 @@ Layer: deelectrified FROM openrailwaymap_osm_line WHERE - railway IN ('rail', 'disused', 'construction') + railway = 'rail' AND usage IN ('main', 'branch') AND service IS NULL AND ( electrified IS NOT NULL OR deelectrified IS NOT NULL @@ -342,7 +301,7 @@ Layer: ) AS railway_text_high properties: minzoom: 8 - maxzoom: 10 + maxzoom: 8 - id: railway_text_high geometry: line <<: *extents @@ -384,7 +343,7 @@ Layer: deelectrified FROM openrailwaymap_osm_line WHERE - railway IN ('rail', 'tram', 'light_rail', 'subway', 'narrow_gauge', 'disused', 'construction') + railway IN ('rail', 'tram', 'light_rail', 'subway', 'narrow_gauge', 'disused', 'construction', 'preserved') AND ( electrified IS NOT NULL OR deelectrified IS NOT NULL @@ -394,4 +353,4 @@ Layer: ORDER by z_order, rank NULLS LAST ) AS railway_text_high properties: - minzoom: 11 + minzoom: 9 diff --git a/electrification.mss b/electrification.mss index 84f5e00e..3340f151 100644 --- a/electrification.mss +++ b/electrification.mss @@ -24,7 +24,7 @@ #railway_line_fill[zoom>=9]::fill, #railway_line_low[zoom<=7]::fill, -#railway_line_med[zoom>7][zoom<9]::fill { +#railway_line_med[zoom=8]::fill { ["railway"="rail"]["usage"="main"]["service"=null], [zoom>=8]["railway"="rail"]["usage"="branch"]["service"=null], [zoom=10]["railway"="rail"]["usage"="industrial"]["service"=null], @@ -74,67 +74,67 @@ line-dasharray: @proposed-dashes; } - ["frequency"=0]["voltage"<750] { + [frequency=0]["voltage"<750] { line-color: #FF79B8; } - ["frequency"=0]["voltage"=750] { + [frequency=0]["voltage"=750] { line-color: #F930FF; } - ["frequency"=0][voltage>750][voltage<1000] { + [frequency=0][voltage>750][voltage<1000] { line-color: #D033FF; } - ["frequency"=0]["voltage"=1000] { + [frequency=0]["voltage"=1000] { line-color: #5C1CCB; } - ["frequency"=0][voltage>1000][voltage<1500] { + [frequency=0][voltage>1000][voltage<1500] { line-color: #007ACB; } - ["frequency"=0]["voltage"=1500] { + [frequency=0]["voltage"=1500] { line-color: #0098CB; } - ["frequency"=0][voltage>1500][voltage<3000] { + [frequency=0][voltage>1500][voltage<3000] { line-color: #00B7CB; } - ["frequency"=0]["voltage"=3000] { + [frequency=0]["voltage"=3000] { line-color: #0000FF; } - ["frequency"=0][voltage>3000] { + [frequency=0][voltage>3000] { line-color: #1969FF; } - ["frequency"!=null]["frequency"!=0][voltage<15000] { + [frequency!=null]["frequency"!=0][voltage<15000] { line-color: #97FF2F; } - ["frequency"=null][frequency!=0][voltage>=15000][voltage<25000] { + [frequency=null][frequency!=0][voltage>=15000][voltage<25000] { line-color: #F1F100; } - [frequency=16.67]["voltage"=15000] { + [frequency=16.67][voltage=15000] { line-color: #00FF00; } - [frequency=16.7]["voltage"=15000] { + [frequency=16.7][voltage=15000] { line-color: #00CB66; } - ["frequency"=null][frequency!=0][voltage>=25000] { + [frequency=null][frequency!=0][voltage>=25000] { line-color: #FF9F19; } - ["frequency"=50]["voltage"=25000] { + [frequency=50]["voltage"=25000] { line-color: #FF0000; } - ["frequency"=60]["voltage"=25000] { + [frequency=60]["voltage"=25000] { line-color: #C00000; } /* [disused!=null], @@ -144,23 +144,40 @@ } } -#railway_text_med[zoom<=10], -#railway_text_high[zoom>=11] { - [railway="rail"], - [railway="construction"][construction_railway="rail"], - [railway="disused"][disused_railway="rail"], - [zoom>=11][railway="narrow_gauge"], - [zoom>=11][railway="construction"][construction_railway="narrow_gauge"], - [zoom>=11][railway="disused"][disused_railway="narrow_gauge"], - [zoom>=12][railway="light_rail"], - [zoom>=12][railway="construction"][construction_railway="light_rail"], - [zoom>=12][railway="disused"][disused_railway="light_rail"], - [zoom>=12][railway="subway"], - [zoom>=12][railway="construction"][construction_railway="subway"], - [zoom>=12][railway="disused"][disused_railway="subway"], - [zoom>=13][railway="tram"], - [zoom>=13][railway="construction"][construction_railway="tram"], - [zoom>=13][railway="disused"][disused_railway="tram"] { +#railway_text_med[zoom=8], +#railway_text_high[zoom>=9] { + ["railway"="rail"]["usage"="main"]["service"=null], + ["railway"="rail"]["usage"="branch"]["service"=null], + [zoom=10]["railway"="rail"]["usage"="industrial"]["service"=null], + [zoom>=13]["railway"="rail"]["usage"=null]["service"=null], + [zoom>=11]["railway"="rail"]["usage"="industrial"], + [zoom>=11]["railway"="rail"]["usage"=null]["service"="siding"], + [zoom>=11]["railway"="rail"]["usage"=null]["service"="crossover"], + [zoom>=12]["railway"="rail"]["usage"=null]["service"="yard"], + [zoom>=11]["railway"="rail"]["usage"=null]["service"="spur"], + [zoom>=11]["railway"="narrow_gauge"]["service"=null], + [zoom>=11]["railway"="narrow_gauge"]["service"="spur"], + [zoom>=11]["railway"="narrow_gauge"]["service"="siding"], + [zoom>=11]["railway"="narrow_gauge"]["service"="crossover"], + [zoom>=12]["railway"="narrow_gauge"]["service"="yard"], + [zoom>=11]["railway"="disused"]["disused_railway"="rail"]["service"=null], + [zoom>=12]["railway"="disused"]["disused_railway"="subway"]["service"=null], + [zoom>=12]["railway"="disused"]["disused_railway"="light_rail"]["service"=null], + [zoom>=13]["railway"="disused"]["disused_railway"="tram"]["service"=null], + /* service!=null is required to get a smaller Mapnik XML style with the Carto compiler. */ + [zoom>=13]["railway"="disused"]["service"!=null], + [zoom>=11]["railway"="construction"]["construction_railway"="rail"]["usage"="main"]["service"=null], + [zoom>=11]["railway"="construction"]["construction_railway"="rail"]["usage"="branch"]["service"=null], + [zoom>=12]["railway"="construction"]["construction_railway"="subway"]["service"=null], + [zoom>=12]["railway"="construction"]["construction_railway"="light_rail"]["service"=null], + [zoom>=13]["railway"="construction"]["construction_railway"="tram"]["service"=null], + [zoom>=13]["railway"="construction"]["service"!=null], + [zoom>=12]["railway"="subway"]["service"=null], + [zoom>=13]["railway"="subway"]["service"!=null], + [zoom>=12]["railway"="light_rail"]["service"=null], + [zoom>=13]["railway"="light_rail"]["service"!=null], + [zoom>=13]["railway"="tram"]["service"=null], + [zoom>=13]["railway"="tram"]["service"!=null] { text-name: [label]; text-face-name: @bold-fonts; text-size: 11; diff --git a/sql/functions.sql b/sql/functions.sql index 48ed6744..d00dc7db 100644 --- a/sql/functions.sql +++ b/sql/functions.sql @@ -383,32 +383,32 @@ END; $$ LANGUAGE plpgsql; -- Get voltage for given state -CREATE OR REPLACE FUNCTION railway_voltage_for_state(state TEXT, voltage FLOAT, construction_voltage FLOAT, proposed_voltage FLOAT) RETURNS FLOAT AS $$ +CREATE OR REPLACE FUNCTION railway_voltage_for_state(state TEXT, voltage TEXT, construction_voltage TEXT, proposed_voltage TEXT) RETURNS INTEGER AS $$ BEGIN IF state = 'present' THEN - RETURN voltage; + RETURN railway_to_int(voltage); END IF; IF state = 'construction' THEN - RETURN construction_voltage; + RETURN railway_to_int(construction_voltage); END IF; IF state = 'proposed' THEN - RETURN proposed_voltage; + RETURN railway_to_int(proposed_voltage); END IF; RETURN NULL; END; $$ LANGUAGE plpgsql; -- Get frequency for given state -CREATE OR REPLACE FUNCTION railway_frequency_for_state(state TEXT, frequency FLOAT, construction_frequency FLOAT, proposed_frequency FLOAT) RETURNS FLOAT AS $$ +CREATE OR REPLACE FUNCTION railway_frequency_for_state(state TEXT, frequency TEXT, construction_frequency TEXT, proposed_frequency TEXT) RETURNS FLOAT AS $$ BEGIN IF state = 'present' THEN - RETURN frequency; + RETURN railway_to_float(frequency); END IF; IF state = 'construction' THEN - RETURN construction_frequency; + RETURN railway_to_float(construction_frequency); END IF; IF state = 'proposed' THEN - RETURN proposed_frequency; + RETURN railway_to_float(proposed_frequency); END IF; RETURN NULL; END; From a14ded41f0bcf3000e572c4cb61891e01869222d Mon Sep 17 00:00:00 2001 From: Michael Reichert Date: Wed, 26 Feb 2020 00:04:00 +0100 Subject: [PATCH 11/19] Simplify SQL queries, make lines under construction have italic font --- electrification.mml | 24 ++---------------------- electrification.mss | 3 +++ 2 files changed, 5 insertions(+), 22 deletions(-) diff --git a/electrification.mml b/electrification.mml index dea6637c..748c6f8a 100644 --- a/electrification.mml +++ b/electrification.mml @@ -277,17 +277,7 @@ Layer: END AS rank, z_order, railway_electrification_label(electrified, deelectrified, construction_electrified, proposed_electrified, voltage, frequency, construction_voltage, construction_frequency, proposed_voltage, proposed_frequency) AS label, - electrified, - frequency, - voltage, - construction_electrified, - construction_frequency, - construction_voltage, - proposed_electrified, - proposed_frequency, - proposed_voltage, - abandoned_electrified, - deelectrified + railway_electrification_state(railway, electrified, deelectrified, abandoned_electrified, construction_electrified, proposed_electrified) AS state FROM openrailwaymap_osm_line WHERE railway = 'rail' AND usage IN ('main', 'branch') AND service IS NULL @@ -330,17 +320,7 @@ Layer: END AS rank, z_order, railway_electrification_label(electrified, deelectrified, construction_electrified, proposed_electrified, voltage, frequency, construction_voltage, construction_frequency, proposed_voltage, proposed_frequency) AS label, - electrified, - frequency, - voltage, - construction_electrified, - construction_frequency, - construction_voltage, - proposed_electrified, - proposed_frequency, - proposed_voltage, - abandoned_electrified, - deelectrified + railway_electrification_state(railway, electrified, deelectrified, abandoned_electrified, construction_electrified, proposed_electrified) AS state FROM openrailwaymap_osm_line WHERE railway IN ('rail', 'tram', 'light_rail', 'subway', 'narrow_gauge', 'disused', 'construction', 'preserved') diff --git a/electrification.mss b/electrification.mss index 3340f151..23582947 100644 --- a/electrification.mss +++ b/electrification.mss @@ -186,5 +186,8 @@ text-min-distance: 30; text-halo-radius: @text-halo-radius; text-halo-fill: @text-halo-color; + ["state"!="present"] { + text-face-name: @oblique-fonts; + } } } From 111b46389f4cec8e5817b1fe35f763ad30a95816 Mon Sep 17 00:00:00 2001 From: Michael Reichert Date: Fri, 5 Jun 2020 19:51:16 +0200 Subject: [PATCH 12/19] Render future electrification on top of existing state This makes lines without electrification but one in future (proposed/construction) to appea as colored dashed lines on top of a black line. --- electrification.mml | 36 +++-- electrification.mss | 315 ++++++++++++++++++++++++++++++-------------- sql/functions.sql | 8 +- 3 files changed, 247 insertions(+), 112 deletions(-) diff --git a/electrification.mml b/electrification.mml index 748c6f8a..91a752ff 100644 --- a/electrification.mml +++ b/electrification.mml @@ -38,8 +38,8 @@ _parts: Stylesheet: - fonts.mss - electrification_signals.mss - - electrification.mss - common.mss + - electrification.mss Layer: - id: railway_line_casing @@ -114,12 +114,16 @@ Layer: NULL AS preserved_railway, NULL AS preserved_service, NULL AS preserved_usage, electrification_state AS state, - railway_voltage_for_state(electrification_state, voltage, construction_voltage, proposed_voltage) AS voltage, - railway_frequency_for_state(electrification_state, frequency, construction_frequency, proposed_frequency) AS frequency + electrification_state_without_future AS state_now, + railway_voltage_for_state(electrification_state, voltage, construction_voltage, proposed_voltage) AS merged_voltage, + railway_frequency_for_state(electrification_state, frequency, construction_frequency, proposed_frequency) AS merged_frequency, + railway_to_int(voltage) AS voltage, + railway_to_float(frequency) AS frequency FROM (SELECT way, railway, usage, - railway_electrification_state(railway, electrified, deelectrified, abandoned_electrified, construction_electrified, proposed_electrified) AS electrification_state, + 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, frequency AS frequency, voltage AS voltage, construction_frequency AS construction_frequency, @@ -156,12 +160,16 @@ Layer: ELSE 50 END AS rank, electrification_state AS state, - railway_voltage_for_state(electrification_state, voltage, construction_voltage, proposed_voltage) AS voltage, - railway_frequency_for_state(electrification_state, frequency, construction_frequency, proposed_frequency) AS frequency + electrification_state_without_future AS state_now, + railway_voltage_for_state(electrification_state, voltage, construction_voltage, proposed_voltage) AS merged_voltage, + railway_frequency_for_state(electrification_state, frequency, construction_frequency, proposed_frequency) AS merged_frequency, + railway_to_int(voltage) AS voltage, + railway_to_float(frequency) AS frequency FROM (SELECT way, railway, usage, - railway_electrification_state(railway, electrified, deelectrified, abandoned_electrified, construction_electrified, proposed_electrified) AS electrification_state, + 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, frequency AS frequency, voltage AS voltage, construction_frequency AS construction_frequency, @@ -209,8 +217,11 @@ Layer: ELSE 50 END AS rank, electrification_state AS state, - railway_voltage_for_state(electrification_state, voltage, construction_voltage, proposed_voltage) AS voltage, - railway_frequency_for_state(electrification_state, frequency, construction_frequency, proposed_frequency) AS frequency + electrification_state_without_future AS state_now, + railway_voltage_for_state(electrification_state, voltage, construction_voltage, proposed_voltage) AS merged_voltage, + railway_frequency_for_state(electrification_state, frequency, construction_frequency, proposed_frequency) AS merged_frequency, + railway_to_int(voltage) AS voltage, + railway_to_float(frequency) AS frequency FROM (SELECT way, railway, usage, service, @@ -221,7 +232,8 @@ Layer: tags->'construction:usage' AS construction_usage, tags->'construction:service' AS construction_service, 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) AS electrification_state, + 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, frequency AS frequency, voltage AS voltage, construction_frequency AS construction_frequency, @@ -277,7 +289,7 @@ Layer: END AS rank, z_order, railway_electrification_label(electrified, deelectrified, construction_electrified, proposed_electrified, voltage, frequency, construction_voltage, construction_frequency, proposed_voltage, proposed_frequency) AS label, - railway_electrification_state(railway, electrified, deelectrified, abandoned_electrified, construction_electrified, proposed_electrified) AS state + railway_electrification_state(railway, electrified, deelectrified, abandoned_electrified, construction_electrified, proposed_electrified, FALSE) AS state FROM openrailwaymap_osm_line WHERE railway = 'rail' AND usage IN ('main', 'branch') AND service IS NULL @@ -320,7 +332,7 @@ Layer: END AS rank, z_order, railway_electrification_label(electrified, deelectrified, construction_electrified, proposed_electrified, voltage, frequency, construction_voltage, construction_frequency, proposed_voltage, proposed_frequency) AS label, - railway_electrification_state(railway, electrified, deelectrified, abandoned_electrified, construction_electrified, proposed_electrified) AS state + railway_electrification_state(railway, electrified, deelectrified, abandoned_electrified, construction_electrified, proposed_electrified, FALSE) AS state FROM openrailwaymap_osm_line WHERE railway IN ('rail', 'tram', 'light_rail', 'subway', 'narrow_gauge', 'disused', 'construction', 'preserved') diff --git a/electrification.mss b/electrification.mss index 23582947..fd5d757a 100644 --- a/electrification.mss +++ b/electrification.mss @@ -2,7 +2,7 @@ @text-halo-radius: 1; @construction-dashes: 5,5; -@proposed-dashes: 2,8; +@proposed-dashes: 4,8; @color_no: black; @color_delectrified: #70584D; @@ -22,125 +22,246 @@ @color_25kv_50: #FF0000; @color_25kv_60: #C00000; -#railway_line_fill[zoom>=9]::fill, -#railway_line_low[zoom<=7]::fill, -#railway_line_med[zoom=8]::fill { - ["railway"="rail"]["usage"="main"]["service"=null], - [zoom>=8]["railway"="rail"]["usage"="branch"]["service"=null], - [zoom=10]["railway"="rail"]["usage"="industrial"]["service"=null], - [zoom>=13]["railway"="rail"]["usage"=null]["service"=null], - [zoom>=11]["railway"="rail"]["usage"="industrial"], - [zoom>=11]["railway"="rail"]["usage"=null]["service"="siding"], - [zoom>=11]["railway"="rail"]["usage"=null]["service"="crossover"], - [zoom>=12]["railway"="rail"]["usage"=null]["service"="yard"], - [zoom>=11]["railway"="rail"]["usage"=null]["service"="spur"], - [zoom>=10]["railway"="narrow_gauge"]["service"=null], - [zoom>=11]["railway"="narrow_gauge"]["service"="spur"], - [zoom>=11]["railway"="narrow_gauge"]["service"="siding"], - [zoom>=11]["railway"="narrow_gauge"]["service"="crossover"], - [zoom>=12]["railway"="narrow_gauge"]["service"="yard"], - [zoom>=9]["railway"="disused"]["disused_railway"="rail"]["service"=null], - [zoom>=11]["railway"="disused"]["disused_railway"="subway"]["service"=null], - [zoom>=11]["railway"="disused"]["disused_railway"="light_rail"]["service"=null], - [zoom>=12]["railway"="disused"]["disused_railway"="tram"]["service"=null], - /* service!=null is required to get a smaller Mapnik XML style with the Carto compiler. */ - [zoom>=13]["railway"="disused"]["service"!=null], - [zoom>=9]["railway"="construction"]["construction_railway"="rail"]["usage"="main"]["service"=null], - [zoom>=9]["railway"="construction"]["construction_railway"="rail"]["usage"="branch"]["service"=null], - [zoom>=10]["railway"="construction"]["construction_railway"="subway"]["service"=null], - [zoom>=10]["railway"="construction"]["construction_railway"="light_rail"]["service"=null], - [zoom>=11]["railway"="construction"]["construction_railway"="tram"]["service"=null], - [zoom>=13]["railway"="construction"]["service"!=null], - [zoom>=10]["railway"="subway"]["service"=null], - [zoom>=13]["railway"="subway"]["service"!=null], - [zoom>=10]["railway"="light_rail"]["service"=null], - [zoom>=13]["railway"="light_rail"]["service"!=null], - [zoom>=11]["railway"="tram"]["service"=null], - [zoom>=13]["railway"="tram"]["service"!=null] { - ["state"="no"] { - line-color: black; - } +/** + * Railway tracks with electrification under construction or proposed electrification + * are rendered with a second symbolizer called proposed_construction. + * It adds dashed lines on top of existing lines (e.g. black for electrified=no). + * + * Common rules in common.mss are defined for the ::fill and ::casing symbolizers only. + * Therefore, the rules from common.mss for ::fill need to be repeated here. + */ +#railway_line_fill[zoom>=9]["state"="construction"]::proposed_construction, +#railway_line_low[zoom<=7]["state"="construction"]::proposed_construction, +#railway_line_med[zoom=8]["state"="construction"]::proposed_construction, +#railway_line_fill[zoom>=9]["state"="proposed"]::proposed_construction, +#railway_line_low[zoom<=7]["state"="proposed"]::proposed_construction, +#railway_line_med[zoom=8]["state"="proposed"]::proposed_construction { - ["state"="deelectrified"], - ["state"="abandoned"] { - line-color: #70584D; - } + ["railway"="rail"] { + ["usage"="main"]["service"=null] { + line-color: @railway_fill_color; + line-width: 1.5; - ["state"="construction"] { - line-dasharray: @construction-dashes; - } + [zoom>=6][zoom<=8] { + line-width: 2.5; + } - ["state"="proposed"] { - line-dasharray: @proposed-dashes; + [zoom>=9] { + line-width: 3.5; + } } - [frequency=0]["voltage"<750] { - line-color: #FF79B8; - } + [zoom>=8]["usage"="branch"]["service"=null] { + line-color: @railway_fill_color; + line-width: 2.5; - [frequency=0]["voltage"=750] { - line-color: #F930FF; + [zoom>=9] { + line-width: 3.5; + } } - [frequency=0][voltage>750][voltage<1000] { - line-color: #D033FF; - } + [zoom=10]["usage"="industrial"]["service"=null], + [zoom>=11]["usage"="industrial"] { + line-color: @railway_fill_color; + line-width: 2; - [frequency=0]["voltage"=1000] { - line-color: #5C1CCB; + ["service"!=null] { + line-width: 1.5; + } } - [frequency=0][voltage>1000][voltage<1500] { - line-color: #007ACB; + [zoom>=13]["usage"=null]["service"=null], + [zoom>=11]["usage"=null]["service"="siding"], + [zoom>=11]["usage"=null]["service"="crossover"] { + line-color: @railway_fill_color; + line-width: 2; } - [frequency=0]["voltage"=1500] { - line-color: #0098CB; + [zoom>=12]["usage"=null]["service"="yard"], + [zoom>=11]["usage"=null]["service"="spur"] { + line-color: @railway_fill_color; + line-width: 1.5; } + } - [frequency=0][voltage>1500][voltage<3000] { - line-color: #00B7CB; - } + ["railway"="narrow_gauge"] { + [zoom>=10]["service"=null], + [zoom>=11]["service"="spur"], + [zoom>=11]["service"="siding"], + [zoom>=11]["service"="crossover"], + [zoom>=12]["service"="yard"] { + line-width: 3; + line-color: @railway_fill_color; - [frequency=0]["voltage"=3000] { - line-color: #0000FF; + ["usage"="industrial"], + ["service"="spur"], + ["service"!=null] { + line-width: 2; + } } + } - [frequency=0][voltage>3000] { - line-color: #1969FF; - } + [zoom>=9] ["railway"="construction"]["construction_railway"="rail"]["usage"="main"]["service"=null], + [zoom>=9] ["railway"="construction"]["construction_railway"="rail"]["usage"="branch"]["service"=null], + [zoom>=10]["railway"="construction"]["construction_railway"="subway"]["service"=null], + [zoom>=10]["railway"="construction"]["construction_railway"="light_rail"]["service"=null], + [zoom>=11]["railway"="construction"]["construction_railway"="tram"]["service"=null], + [zoom>=13]["railway"="construction"], + [zoom>=10]["railway"="subway"]["service"=null], + [zoom>=13]["railway"="subway"], + [zoom>=10]["railway"="light_rail"]["service"=null], + [zoom>=13]["railway"="light_rail"], + [zoom>=11]["railway"="tram"]["service"=null], + [zoom>=13]["railway"="tram"] { + line-color: @railway_fill_color; + line-width: 3; - [frequency!=null]["frequency"!=0][voltage<15000] { - line-color: #97FF2F; + [service!=null] { + line-width: 1.5; } + } +} - [frequency=null][frequency!=0][voltage>=15000][voltage<25000] { - line-color: #F1F100; - } +::fill, +["state"="construction"]::proposed_construction, +["state"="proposed"]::proposed_construction { + #railway_line_fill[zoom>=9], + #railway_line_low[zoom<=7], + #railway_line_med[zoom=8] { + ["railway"="rail"]["usage"="main"]["service"=null], + [zoom>=8]["railway"="rail"]["usage"="branch"]["service"=null], + [zoom=10]["railway"="rail"]["usage"="industrial"]["service"=null], + [zoom>=13]["railway"="rail"]["usage"=null]["service"=null], + [zoom>=11]["railway"="rail"]["usage"="industrial"], + [zoom>=11]["railway"="rail"]["usage"=null]["service"="siding"], + [zoom>=11]["railway"="rail"]["usage"=null]["service"="crossover"], + [zoom>=12]["railway"="rail"]["usage"=null]["service"="yard"], + [zoom>=11]["railway"="rail"]["usage"=null]["service"="spur"], + [zoom>=10]["railway"="narrow_gauge"]["service"=null], + [zoom>=11]["railway"="narrow_gauge"]["service"="spur"], + [zoom>=11]["railway"="narrow_gauge"]["service"="siding"], + [zoom>=11]["railway"="narrow_gauge"]["service"="crossover"], + [zoom>=12]["railway"="narrow_gauge"]["service"="yard"], + [zoom>=9]["railway"="disused"]["disused_railway"="rail"]["service"=null], + [zoom>=11]["railway"="disused"]["disused_railway"="subway"]["service"=null], + [zoom>=11]["railway"="disused"]["disused_railway"="light_rail"]["service"=null], + [zoom>=12]["railway"="disused"]["disused_railway"="tram"]["service"=null], + /* service!=null is required to get a smaller Mapnik XML style with the Carto compiler. */ + [zoom>=13]["railway"="disused"]["service"!=null], + [zoom>=9]["railway"="construction"]["construction_railway"="rail"]["usage"="main"]["service"=null], + [zoom>=9]["railway"="construction"]["construction_railway"="rail"]["usage"="branch"]["service"=null], + [zoom>=10]["railway"="construction"]["construction_railway"="subway"]["service"=null], + [zoom>=10]["railway"="construction"]["construction_railway"="light_rail"]["service"=null], + [zoom>=11]["railway"="construction"]["construction_railway"="tram"]["service"=null], + [zoom>=13]["railway"="construction"]["service"!=null], + [zoom>=10]["railway"="subway"]["service"=null], + [zoom>=13]["railway"="subway"]["service"!=null], + [zoom>=10]["railway"="light_rail"]["service"=null], + [zoom>=13]["railway"="light_rail"]["service"!=null], + [zoom>=11]["railway"="tram"]["service"=null], + [zoom>=13]["railway"="tram"]["service"!=null] { - [frequency=16.67][voltage=15000] { - line-color: #00FF00; - } + ::fill { + ["state_now"="no"] { + line-color: black; + } + + ["state_now"="deelectrified"], + ["state_now"="abandoned"] { + line-color: #70584D; + } + } + + ::proposed_construction { + ["state"="construction"] { + line-dasharray: @construction-dashes; + } + + ["state"="proposed"] { + line-dasharray: @proposed-dashes; + } + } + + [frequency=0]["voltage"<750]::fill, + [merged_frequency=0]["merged_voltage"<750]::proposed_construction { + line-color: #FF79B8; + } - [frequency=16.7][voltage=15000] { - line-color: #00CB66; - } - - [frequency=null][frequency!=0][voltage>=25000] { - line-color: #FF9F19; - } - - [frequency=50]["voltage"=25000] { - line-color: #FF0000; - } - - [frequency=60]["voltage"=25000] { - line-color: #C00000; - } - /* [disused!=null], - [construction!=null] { - comp-op: screen; - }*/ + [frequency=0]["voltage"=750]::fill, + [merged_frequency=0]["merged_voltage"=750]::proposed_construction { + line-color: #F930FF; + } + + [frequency=0][voltage>750][voltage<1000]::fill, + [merged_frequency=0][merged_voltage>750][merged_voltage<1000]::proposed_construction { + line-color: #D033FF; + } + + [frequency=0]["voltage"=1000]::fill, + [merged_frequency=0]["merged_voltage"=1000]::proposed_construction { + line-color: #5C1CCB; + } + + [frequency=0][voltage>1000][voltage<1500]::fill, + [merged_frequency=0][merged_voltage>1000][merged_voltage<1500]::proposed_construction { + line-color: #007ACB; + } + + [frequency=0]["voltage"=1500]::fill, + [merged_frequency=0]["merged_voltage"=1500]::proposed_construction { + line-color: #0098CB; + } + + [frequency=0][voltage>1500][voltage<3000]::fill, + [merged_frequency=0][merged_voltage>1500][merged_voltage<3000]::proposed_construction { + line-color: #00B7CB; + } + + [frequency=0]["voltage"=3000]::fill, + [merged_frequency=0]["merged_voltage"=3000]::proposed_construction { + line-color: #0000FF; + } + + [frequency=0][voltage>3000]::fill, + [merged_frequency=0][merged_voltage>3000]::proposed_construction { + line-color: #1969FF; + } + + [frequency!=null]["frequency"!=0][voltage<15000]::fill, + [merged_frequency!=null]["merged_frequency"!=0][merged_voltage<15000]::proposed_construction { + line-color: #97FF2F; + } + + [frequency=null][frequency!=0][voltage>=15000][voltage<25000]::fill, + [merged_frequency=null][merged_frequency!=0][merged_voltage>=15000][merged_voltage<25000]::proposed_construction { + line-color: #F1F100; + } + + [frequency=16.67][voltage=15000]::fill, + [merged_frequency=16.67][merged_voltage=15000]::proposed_construction { + line-color: #00FF00; + } + + [frequency=16.7][voltage=15000]::fill, + [merged_frequency=16.7][merged_voltage=15000]::proposed_construction { + line-color: #00CB66; + } + + [frequency=null][frequency!=0][voltage>=25000]::fill, + [merged_frequency=null][merged_frequency!=0][merged_voltage>=25000]::proposed_construction { + line-color: #FF9F19; + } + + [frequency=50]["voltage"=25000]::fill, + [merged_frequency=50]["merged_voltage"=25000]::proposed_construction { + line-color: #FF0000; + } + + [frequency=60]["voltage"=25000]::fill, + [merged_frequency=60]["merged_voltage"=25000]::proposed_construction { + line-color: #C00000; + } + } } } diff --git a/sql/functions.sql b/sql/functions.sql index d00dc7db..a97454fa 100644 --- a/sql/functions.sql +++ b/sql/functions.sql @@ -354,7 +354,9 @@ END; $$ LANGUAGE plpgsql; -- Get state of electrification -CREATE OR REPLACE FUNCTION railway_electrification_state(railway TEXT, electrified TEXT, deelectrified TEXT, abandoned_electrified TEXT, construction_electrified TEXT, proposed_electrified TEXT) RETURNS TEXT AS $$ +CREATE OR REPLACE FUNCTION railway_electrification_state(railway TEXT, electrified TEXT, + deelectrified TEXT, abandoned_electrified TEXT, construction_electrified TEXT, + proposed_electrified TEXT, ignore_future_states BOOLEAN) RETURNS TEXT AS $$ DECLARE state TEXT; valid_values TEXT[] := ARRAY['contact_line', 'yes', 'rail', 'ground-level_power_supply', 'contact_line;rail', 'rail;contact_line']; @@ -366,10 +368,10 @@ BEGIN IF electrified = 'no' THEN state := 'no'; END IF; - IF construction_electrified = ANY(valid_values) THEN + IF NOT ignore_future_states AND construction_electrified = ANY(valid_values) THEN RETURN 'construction'; END IF; - IF proposed_electrified = ANY(valid_values) THEN + 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 From 22e9717202600db28c6995a1c151db375cb757fa Mon Sep 17 00:00:00 2001 From: Michael Reichert Date: Fri, 5 Jun 2020 20:12:14 +0200 Subject: [PATCH 13/19] add electrification style to .gitignore --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 08797d41..058552a3 100644 --- a/.gitignore +++ b/.gitignore @@ -3,5 +3,6 @@ data/ standard.xml maxspeed.xml signals.xml +electrification.xml *.mapcss *.d From 20ce02e2794137191ebfe2ecef5456003bdeeb0f Mon Sep 17 00:00:00 2001 From: Michael Reichert Date: Fri, 5 Jun 2020 22:00:25 +0200 Subject: [PATCH 14/19] Move dashing into its own layer An additional style for the fill layers is not going to work reliably. Changes to order of the .mss files which seem to have to same meaning from a style author point of view lead to different results in XML and make authors become crazy. Splitting of into a separate layer is a bit more difficult because we need compositing operations to achieve the same effect but it makes working on the style easier. --- electrification.mml | 71 ++++++++++++-- electrification.mss | 225 +++++++++++++++++++------------------------- 2 files changed, 163 insertions(+), 133 deletions(-) diff --git a/electrification.mml b/electrification.mml index 91a752ff..4fd86483 100644 --- a/electrification.mml +++ b/electrification.mml @@ -38,8 +38,8 @@ _parts: Stylesheet: - fonts.mss - electrification_signals.mss - - common.mss - electrification.mss + - common.mss Layer: - id: railway_line_casing @@ -216,12 +216,9 @@ Layer: WHEN railway = 'disused' THEN 300 ELSE 50 END AS rank, - electrification_state AS state, - electrification_state_without_future AS state_now, - railway_voltage_for_state(electrification_state, voltage, construction_voltage, proposed_voltage) AS merged_voltage, - railway_frequency_for_state(electrification_state, frequency, construction_frequency, proposed_frequency) AS merged_frequency, - railway_to_int(voltage) AS voltage, - railway_to_float(frequency) AS frequency + electrification_state_without_future AS state, + railway_voltage_for_state(electrification_state_without_future, voltage, construction_voltage, proposed_voltage) AS voltage, + railway_frequency_for_state(electrification_state_without_future, frequency, construction_frequency, proposed_frequency) AS frequency FROM (SELECT way, railway, usage, service, @@ -250,6 +247,66 @@ Layer: ) AS railway_line_fill properties: minzoom: 9 +# electrification_future renders with almost the same styling on top of the line fill and thereby adds dashing. + - id: electrification_future + geometry: line + <<: *extents + Datasource: + <<: *osm2pgsql + table: |- + (SELECT + way, railway, usage, service, + disused, construction, + disused_railway, + construction_railway, + disused_usage, disused_service, + construction_usage, construction_service, + preserved_railway, preserved_service, + preserved_usage, + CASE WHEN railway = 'rail' AND usage IN ('tourism', 'military', 'test') AND service IS NULL THEN 400 + WHEN railway = 'rail' AND usage IS NULL AND service IS NULL THEN 400 + WHEN railway = 'rail' AND usage IS NULL AND service = 'siding' THEN 870 + WHEN railway = 'rail' AND usage IS NULL AND service = 'yard' THEN 860 + WHEN railway = 'rail' AND usage IS NULL AND service = 'spur' THEN 880 + WHEN railway = 'rail' AND usage IS NULL AND service = 'crossover' THEN 300 + WHEN railway = 'rail' AND usage = 'main' AND service IS NULL THEN 1100 + WHEN railway = 'rail' AND usage = 'branch' AND service IS NULL THEN 1000 + WHEN railway = 'rail' AND usage = 'industrial' AND service IS NULL THEN 850 + WHEN railway = 'rail' AND usage = 'industrial' AND service IN ('siding', 'spur', 'yard', 'crossover') THEN 850 + WHEN railway IN ('preserved', 'construction') THEN 400 + WHEN railway = 'disused' THEN 300 + ELSE 50 + END AS rank, + electrification_state AS state, + railway_voltage_for_state(electrification_state, voltage, construction_voltage, proposed_voltage) AS voltage, + railway_frequency_for_state(electrification_state, frequency, construction_frequency, proposed_frequency) AS frequency + FROM + (SELECT + way, railway, usage, service, + tags->'disused' AS disused, construction, + tags->'disused:railway' AS disused_railway, + tags->'construction:railway' AS construction_railway, + tags->'disused:usage' AS disused_usage, tags->'disused:service' AS disused_service, + tags->'construction:usage' AS construction_usage, tags->'construction:service' AS construction_service, + 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, + frequency AS frequency, + voltage AS voltage, + construction_frequency AS construction_frequency, + construction_voltage AS construction_voltage, + proposed_frequency AS proposed_frequency, + proposed_voltage AS proposed_voltage, + z_order + FROM openrailwaymap_osm_line + WHERE railway IN ('rail', 'tram', 'light_rail', 'subway', 'narrow_gauge', 'disused', 'construction', 'preserved') + ) AS r + ORDER BY + z_order, + rank NULLS LAST + ) AS electrification_future + properties: + minzoom: 9 - id: electrification-signals geometry: point <<: *extents diff --git a/electrification.mss b/electrification.mss index fd5d757a..7443fab8 100644 --- a/electrification.mss +++ b/electrification.mss @@ -30,13 +30,7 @@ * Common rules in common.mss are defined for the ::fill and ::casing symbolizers only. * Therefore, the rules from common.mss for ::fill need to be repeated here. */ -#railway_line_fill[zoom>=9]["state"="construction"]::proposed_construction, -#railway_line_low[zoom<=7]["state"="construction"]::proposed_construction, -#railway_line_med[zoom=8]["state"="construction"]::proposed_construction, -#railway_line_fill[zoom>=9]["state"="proposed"]::proposed_construction, -#railway_line_low[zoom<=7]["state"="proposed"]::proposed_construction, -#railway_line_med[zoom=8]["state"="proposed"]::proposed_construction { - +#electrification_future[zoom>=9] { ["railway"="rail"] { ["usage"="main"]["service"=null] { line-color: @railway_fill_color; @@ -122,145 +116,124 @@ } } -::fill, -["state"="construction"]::proposed_construction, -["state"="proposed"]::proposed_construction { - #railway_line_fill[zoom>=9], - #railway_line_low[zoom<=7], - #railway_line_med[zoom=8] { - ["railway"="rail"]["usage"="main"]["service"=null], - [zoom>=8]["railway"="rail"]["usage"="branch"]["service"=null], - [zoom=10]["railway"="rail"]["usage"="industrial"]["service"=null], - [zoom>=13]["railway"="rail"]["usage"=null]["service"=null], - [zoom>=11]["railway"="rail"]["usage"="industrial"], - [zoom>=11]["railway"="rail"]["usage"=null]["service"="siding"], - [zoom>=11]["railway"="rail"]["usage"=null]["service"="crossover"], - [zoom>=12]["railway"="rail"]["usage"=null]["service"="yard"], - [zoom>=11]["railway"="rail"]["usage"=null]["service"="spur"], - [zoom>=10]["railway"="narrow_gauge"]["service"=null], - [zoom>=11]["railway"="narrow_gauge"]["service"="spur"], - [zoom>=11]["railway"="narrow_gauge"]["service"="siding"], - [zoom>=11]["railway"="narrow_gauge"]["service"="crossover"], - [zoom>=12]["railway"="narrow_gauge"]["service"="yard"], - [zoom>=9]["railway"="disused"]["disused_railway"="rail"]["service"=null], - [zoom>=11]["railway"="disused"]["disused_railway"="subway"]["service"=null], - [zoom>=11]["railway"="disused"]["disused_railway"="light_rail"]["service"=null], - [zoom>=12]["railway"="disused"]["disused_railway"="tram"]["service"=null], - /* service!=null is required to get a smaller Mapnik XML style with the Carto compiler. */ - [zoom>=13]["railway"="disused"]["service"!=null], - [zoom>=9]["railway"="construction"]["construction_railway"="rail"]["usage"="main"]["service"=null], - [zoom>=9]["railway"="construction"]["construction_railway"="rail"]["usage"="branch"]["service"=null], - [zoom>=10]["railway"="construction"]["construction_railway"="subway"]["service"=null], - [zoom>=10]["railway"="construction"]["construction_railway"="light_rail"]["service"=null], - [zoom>=11]["railway"="construction"]["construction_railway"="tram"]["service"=null], - [zoom>=13]["railway"="construction"]["service"!=null], - [zoom>=10]["railway"="subway"]["service"=null], - [zoom>=13]["railway"="subway"]["service"!=null], - [zoom>=10]["railway"="light_rail"]["service"=null], - [zoom>=13]["railway"="light_rail"]["service"!=null], - [zoom>=11]["railway"="tram"]["service"=null], - [zoom>=13]["railway"="tram"]["service"!=null] { - - ::fill { - ["state_now"="no"] { - line-color: black; - } - - ["state_now"="deelectrified"], - ["state_now"="abandoned"] { - line-color: #70584D; - } - } +#electrification_future, +#railway_line_fill[zoom>=9]::fill, +#railway_line_low[zoom<=7]::fill, +#railway_line_med[zoom=8]::fill { + ["railway"="rail"]["usage"="main"]["service"=null], + [zoom>=8]["railway"="rail"]["usage"="branch"]["service"=null], + [zoom=10]["railway"="rail"]["usage"="industrial"]["service"=null], + [zoom>=13]["railway"="rail"]["usage"=null]["service"=null], + [zoom>=11]["railway"="rail"]["usage"="industrial"], + [zoom>=11]["railway"="rail"]["usage"=null]["service"="siding"], + [zoom>=11]["railway"="rail"]["usage"=null]["service"="crossover"], + [zoom>=12]["railway"="rail"]["usage"=null]["service"="yard"], + [zoom>=11]["railway"="rail"]["usage"=null]["service"="spur"], + [zoom>=10]["railway"="narrow_gauge"]["service"=null], + [zoom>=11]["railway"="narrow_gauge"]["service"="spur"], + [zoom>=11]["railway"="narrow_gauge"]["service"="siding"], + [zoom>=11]["railway"="narrow_gauge"]["service"="crossover"], + [zoom>=12]["railway"="narrow_gauge"]["service"="yard"], + [zoom>=9]["railway"="disused"]["disused_railway"="rail"]["service"=null], + [zoom>=11]["railway"="disused"]["disused_railway"="subway"]["service"=null], + [zoom>=11]["railway"="disused"]["disused_railway"="light_rail"]["service"=null], + [zoom>=12]["railway"="disused"]["disused_railway"="tram"]["service"=null], + /* service!=null is required to get a smaller Mapnik XML style with the Carto compiler. */ + [zoom>=13]["railway"="disused"]["service"!=null], + [zoom>=9]["railway"="construction"]["construction_railway"="rail"]["usage"="main"]["service"=null], + [zoom>=9]["railway"="construction"]["construction_railway"="rail"]["usage"="branch"]["service"=null], + [zoom>=10]["railway"="construction"]["construction_railway"="subway"]["service"=null], + [zoom>=10]["railway"="construction"]["construction_railway"="light_rail"]["service"=null], + [zoom>=11]["railway"="construction"]["construction_railway"="tram"]["service"=null], + [zoom>=13]["railway"="construction"]["service"!=null], + [zoom>=10]["railway"="subway"]["service"=null], + [zoom>=13]["railway"="subway"]["service"!=null], + [zoom>=10]["railway"="light_rail"]["service"=null], + [zoom>=13]["railway"="light_rail"]["service"!=null], + [zoom>=11]["railway"="tram"]["service"=null], + [zoom>=13]["railway"="tram"]["service"!=null] { - ::proposed_construction { - ["state"="construction"] { - line-dasharray: @construction-dashes; - } + ["state"="no"] { + line-color: black; + } - ["state"="proposed"] { - line-dasharray: @proposed-dashes; - } - } + ["state"="deelectrified"], + ["state"="abandoned"] { + line-color: #70584D; + } - [frequency=0]["voltage"<750]::fill, - [merged_frequency=0]["merged_voltage"<750]::proposed_construction { - line-color: #FF79B8; + #electrification_future { + ["state"="construction"] { + line-dasharray: @construction-dashes; } - [frequency=0]["voltage"=750]::fill, - [merged_frequency=0]["merged_voltage"=750]::proposed_construction { - line-color: #F930FF; + ["state"="proposed"] { + line-dasharray: @proposed-dashes; } + } - [frequency=0][voltage>750][voltage<1000]::fill, - [merged_frequency=0][merged_voltage>750][merged_voltage<1000]::proposed_construction { - line-color: #D033FF; - } + [frequency=0]["voltage"<750] { + line-color: #FF79B8; + } - [frequency=0]["voltage"=1000]::fill, - [merged_frequency=0]["merged_voltage"=1000]::proposed_construction { - line-color: #5C1CCB; - } + [frequency=0]["voltage"=750] { + line-color: #F930FF; + } - [frequency=0][voltage>1000][voltage<1500]::fill, - [merged_frequency=0][merged_voltage>1000][merged_voltage<1500]::proposed_construction { - line-color: #007ACB; - } + [frequency=0][voltage>750][voltage<1000] { + line-color: #D033FF; + } - [frequency=0]["voltage"=1500]::fill, - [merged_frequency=0]["merged_voltage"=1500]::proposed_construction { - line-color: #0098CB; - } + [frequency=0]["voltage"=1000] { + line-color: #5C1CCB; + } - [frequency=0][voltage>1500][voltage<3000]::fill, - [merged_frequency=0][merged_voltage>1500][merged_voltage<3000]::proposed_construction { - line-color: #00B7CB; - } + [frequency=0][voltage>1000][voltage<1500] { + line-color: #007ACB; + } - [frequency=0]["voltage"=3000]::fill, - [merged_frequency=0]["merged_voltage"=3000]::proposed_construction { - line-color: #0000FF; - } + [frequency=0]["voltage"=1500] { + line-color: #0098CB; + } - [frequency=0][voltage>3000]::fill, - [merged_frequency=0][merged_voltage>3000]::proposed_construction { - line-color: #1969FF; - } + [frequency=0][voltage>1500][voltage<3000] { + line-color: #00B7CB; + } - [frequency!=null]["frequency"!=0][voltage<15000]::fill, - [merged_frequency!=null]["merged_frequency"!=0][merged_voltage<15000]::proposed_construction { - line-color: #97FF2F; - } + [frequency=0]["voltage"=3000] { + line-color: #0000FF; + } - [frequency=null][frequency!=0][voltage>=15000][voltage<25000]::fill, - [merged_frequency=null][merged_frequency!=0][merged_voltage>=15000][merged_voltage<25000]::proposed_construction { - line-color: #F1F100; - } + [frequency=0][voltage>3000] { + line-color: #1969FF; + } - [frequency=16.67][voltage=15000]::fill, - [merged_frequency=16.67][merged_voltage=15000]::proposed_construction { - line-color: #00FF00; - } + [frequency!=null]["frequency"!=0][voltage<15000] { + line-color: #97FF2F; + } - [frequency=16.7][voltage=15000]::fill, - [merged_frequency=16.7][merged_voltage=15000]::proposed_construction { - line-color: #00CB66; - } + [frequency=null][frequency!=0][voltage>=15000][voltage<25000] { + line-color: #F1F100; + } - [frequency=null][frequency!=0][voltage>=25000]::fill, - [merged_frequency=null][merged_frequency!=0][merged_voltage>=25000]::proposed_construction { - line-color: #FF9F19; - } + [frequency=16.67][voltage=15000] { + line-color: #00FF00; + } - [frequency=50]["voltage"=25000]::fill, - [merged_frequency=50]["merged_voltage"=25000]::proposed_construction { - line-color: #FF0000; - } + [frequency=16.7][voltage=15000] { + line-color: #00CB66; + } - [frequency=60]["voltage"=25000]::fill, - [merged_frequency=60]["merged_voltage"=25000]::proposed_construction { - line-color: #C00000; - } + [frequency=null][frequency!=0][voltage>=25000] { + line-color: #FF9F19; + } + + [frequency=50]["voltage"=25000] { + line-color: #FF0000; + } + + [frequency=60]["voltage"=25000] { + line-color: #C00000; } } } From 1b484628c411f5d277a724890ef56ee155967be5 Mon Sep 17 00:00:00 2001 From: Michael Reichert Date: Sat, 22 Aug 2020 16:18:10 +0200 Subject: [PATCH 15/19] Replace z_order by layer This applies the changes from #34 to the electrification style. --- electrification.mml | 29 ++++++++++++++--------------- 1 file changed, 14 insertions(+), 15 deletions(-) diff --git a/electrification.mml b/electrification.mml index 4fd86483..97e42a25 100644 --- a/electrification.mml +++ b/electrification.mml @@ -89,11 +89,11 @@ Layer: proposed_electrified, proposed_frequency, deelectrified, - z_order + layer FROM openrailwaymap_osm_line WHERE railway IN ('rail', 'tram', 'light_rail', 'subway', 'narrow_gauge', 'disused', 'construction') ) AS r - ORDER by z_order, rank NULLS LAST + ORDER by layer, rank NULLS LAST ) AS railway_line_casing properties: minzoom: 9 @@ -130,12 +130,11 @@ Layer: construction_voltage AS construction_voltage, proposed_frequency AS proposed_frequency, proposed_voltage AS proposed_voltage, - z_order + layer FROM openrailwaymap_osm_line WHERE railway = 'rail' AND usage = 'main' AND service IS NULL ) AS r - ORDER BY - z_order + ORDER BY layer NULLS LAST ) AS openrailwaymap_line_low properties: maxzoom: 7 @@ -176,12 +175,12 @@ Layer: construction_voltage AS construction_voltage, proposed_frequency AS proposed_frequency, proposed_voltage AS proposed_voltage, - z_order + layer FROM openrailwaymap_osm_line WHERE railway = 'rail' AND usage IN ('main', 'branch') AND service IS NULL ) AS r ORDER BY - z_order, + layer, rank NULLS LAST ) AS railway_line_med properties: @@ -237,12 +236,12 @@ Layer: construction_voltage AS construction_voltage, proposed_frequency AS proposed_frequency, proposed_voltage AS proposed_voltage, - z_order + layer FROM openrailwaymap_osm_line WHERE railway IN ('rail', 'tram', 'light_rail', 'subway', 'narrow_gauge', 'disused', 'construction', 'preserved') ) AS r ORDER BY - z_order, + layer, rank NULLS LAST ) AS railway_line_fill properties: @@ -297,12 +296,12 @@ Layer: construction_voltage AS construction_voltage, proposed_frequency AS proposed_frequency, proposed_voltage AS proposed_voltage, - z_order + layer FROM openrailwaymap_osm_line WHERE railway IN ('rail', 'tram', 'light_rail', 'subway', 'narrow_gauge', 'disused', 'construction', 'preserved') ) AS r ORDER BY - z_order, + layer, rank NULLS LAST ) AS electrification_future properties: @@ -344,7 +343,7 @@ Layer: WHEN railway = 'rail' AND usage = 'branch' THEN 1000 ELSE 50 END AS rank, - z_order, + layer, railway_electrification_label(electrified, deelectrified, construction_electrified, proposed_electrified, voltage, frequency, construction_voltage, construction_frequency, proposed_voltage, proposed_frequency) AS label, railway_electrification_state(railway, electrified, deelectrified, abandoned_electrified, construction_electrified, proposed_electrified, FALSE) AS state FROM openrailwaymap_osm_line @@ -356,7 +355,7 @@ Layer: OR construction_electrified IS NOT NULL OR proposed_electrified IS NOT NULL ) - ORDER by z_order, rank NULLS LAST + ORDER by layer, rank NULLS LAST ) AS railway_text_high properties: minzoom: 8 @@ -387,7 +386,7 @@ Layer: WHEN railway = 'disused' THEN 300 ELSE 50 END AS rank, - z_order, + layer, railway_electrification_label(electrified, deelectrified, construction_electrified, proposed_electrified, voltage, frequency, construction_voltage, construction_frequency, proposed_voltage, proposed_frequency) AS label, railway_electrification_state(railway, electrified, deelectrified, abandoned_electrified, construction_electrified, proposed_electrified, FALSE) AS state FROM openrailwaymap_osm_line @@ -399,7 +398,7 @@ Layer: OR construction_electrified IS NOT NULL OR proposed_electrified IS NOT NULL ) - ORDER by z_order, rank NULLS LAST + ORDER by layer, rank NULLS LAST ) AS railway_text_high properties: minzoom: 9 From ee70ed8c9ad77541c9a89294946cdec1ea7bf1d1 Mon Sep 17 00:00:00 2001 From: Michael Reichert Date: Sat, 22 Aug 2020 16:24:29 +0200 Subject: [PATCH 16/19] Remove railway=disused from electrification style This was a leftover of copy-pasting. --- electrification.mml | 46 ++++++++++++--------------------------------- electrification.mss | 10 ---------- 2 files changed, 12 insertions(+), 44 deletions(-) diff --git a/electrification.mml b/electrification.mml index 97e42a25..92015eab 100644 --- a/electrification.mml +++ b/electrification.mml @@ -50,8 +50,7 @@ Layer: table: |- (SELECT way, railway, usage, service, - disused, construction, - disused_railway, + construction, construction_railway, CASE WHEN railway = 'rail' AND usage IN ('tourism', 'military', 'test') AND service IS NULL THEN 400 WHEN railway = 'rail' AND usage IS NULL AND service IS NULL THEN 400 @@ -64,7 +63,6 @@ Layer: WHEN railway = 'rail' AND usage = 'industrial' AND service IS NULL THEN 850 WHEN railway = 'rail' AND usage = 'industrial' AND service IN ('siding', 'spur', 'yard', 'crossover') THEN 850 WHEN railway IN ('preserved', 'construction') THEN 400 - WHEN railway = 'disused' THEN 300 ELSE 50 END AS rank, electrified, @@ -78,8 +76,7 @@ Layer: FROM (SELECT way, railway, usage, service, - tags->'disused' AS disused, construction, - tags->'disused:railway' AS disused_railway, + construction, tags->'construction:railway' AS construction_railway, electrified, frequency, @@ -91,7 +88,7 @@ Layer: deelectrified, layer FROM openrailwaymap_osm_line - WHERE railway IN ('rail', 'tram', 'light_rail', 'subway', 'narrow_gauge', 'disused', 'construction') + WHERE railway IN ('rail', 'tram', 'light_rail', 'subway', 'narrow_gauge', 'construction') ) AS r ORDER by layer, rank NULLS LAST ) AS railway_line_casing @@ -106,10 +103,8 @@ Layer: (SELECT way, railway, usage, NULL AS service, - NULL AS disused, NULL AS construction, - NULL AS disused_railway, + NULL AS construction, NULL AS construction_railway, - NULL AS disused_usage, NULL AS disused_service, NULL AS construction_usage, NULL AS construction_service, NULL AS preserved_railway, NULL AS preserved_service, NULL AS preserved_usage, @@ -147,10 +142,8 @@ Layer: (SELECT way, railway, usage, NULL AS service, - NULL AS disused, NULL AS construction, - NULL AS disused_railway, + NULL AS construction, NULL AS construction_railway, - NULL AS disused_usage, NULL AS disused_service, NULL AS construction_usage, NULL AS construction_service, NULL AS preserved_railway, NULL AS preserved_service, NULL AS preserved_usage, @@ -194,10 +187,8 @@ Layer: table: |- (SELECT way, railway, usage, service, - disused, construction, - disused_railway, + construction, construction_railway, - disused_usage, disused_service, construction_usage, construction_service, preserved_railway, preserved_service, preserved_usage, @@ -212,7 +203,6 @@ Layer: WHEN railway = 'rail' AND usage = 'industrial' AND service IS NULL THEN 850 WHEN railway = 'rail' AND usage = 'industrial' AND service IN ('siding', 'spur', 'yard', 'crossover') THEN 850 WHEN railway IN ('preserved', 'construction') THEN 400 - WHEN railway = 'disused' THEN 300 ELSE 50 END AS rank, electrification_state_without_future AS state, @@ -221,10 +211,8 @@ Layer: FROM (SELECT way, railway, usage, service, - tags->'disused' AS disused, construction, - tags->'disused:railway' AS disused_railway, + construction, tags->'construction:railway' AS construction_railway, - tags->'disused:usage' AS disused_usage, tags->'disused:service' AS disused_service, tags->'construction:usage' AS construction_usage, tags->'construction:service' AS construction_service, tags->'preserved:railway' AS preserved_railway, tags->'preserved:service' AS preserved_service, tags->'preserved:usage' AS preserved_usage, @@ -238,7 +226,7 @@ Layer: proposed_voltage AS proposed_voltage, layer FROM openrailwaymap_osm_line - WHERE railway IN ('rail', 'tram', 'light_rail', 'subway', 'narrow_gauge', 'disused', 'construction', 'preserved') + WHERE railway IN ('rail', 'tram', 'light_rail', 'subway', 'narrow_gauge', 'construction', 'preserved') ) AS r ORDER BY layer, @@ -255,10 +243,8 @@ Layer: table: |- (SELECT way, railway, usage, service, - disused, construction, - disused_railway, + construction, construction_railway, - disused_usage, disused_service, construction_usage, construction_service, preserved_railway, preserved_service, preserved_usage, @@ -273,7 +259,6 @@ Layer: WHEN railway = 'rail' AND usage = 'industrial' AND service IS NULL THEN 850 WHEN railway = 'rail' AND usage = 'industrial' AND service IN ('siding', 'spur', 'yard', 'crossover') THEN 850 WHEN railway IN ('preserved', 'construction') THEN 400 - WHEN railway = 'disused' THEN 300 ELSE 50 END AS rank, electrification_state AS state, @@ -282,10 +267,8 @@ Layer: FROM (SELECT way, railway, usage, service, - tags->'disused' AS disused, construction, - tags->'disused:railway' AS disused_railway, + construction, tags->'construction:railway' AS construction_railway, - tags->'disused:usage' AS disused_usage, tags->'disused:service' AS disused_service, tags->'construction:usage' AS construction_usage, tags->'construction:service' AS construction_service, tags->'preserved:railway' AS preserved_railway, tags->'preserved:service' AS preserved_service, tags->'preserved:usage' AS preserved_usage, @@ -298,7 +281,7 @@ Layer: proposed_voltage AS proposed_voltage, layer FROM openrailwaymap_osm_line - WHERE railway IN ('rail', 'tram', 'light_rail', 'subway', 'narrow_gauge', 'disused', 'construction', 'preserved') + WHERE railway IN ('rail', 'tram', 'light_rail', 'subway', 'narrow_gauge', 'construction', 'preserved') ) AS r ORDER BY layer, @@ -335,9 +318,7 @@ Layer: table: |- (SELECT way, railway, usage, service, - tags->'disused' AS disused, construction, - tags->'disused:railway' AS disused_railway, tags->'construction:railway' AS construction_railway, CASE WHEN railway = 'rail' AND usage = 'main' THEN 1100 WHEN railway = 'rail' AND usage = 'branch' THEN 1000 @@ -368,9 +349,7 @@ Layer: table: |- (SELECT way, railway, usage, service, - tags->'disused' AS disused, construction, - tags->'disused:railway' AS disused_railway, tags->'construction:railway' AS construction_railway, CASE WHEN railway = 'rail' AND usage IN ('usage', 'military', 'test') AND service IS NULL THEN 400 WHEN railway = 'rail' AND usage IS NULL AND service IS NULL THEN 400 @@ -383,7 +362,6 @@ Layer: WHEN railway = 'rail' AND usage = 'industrial' AND service IS NULL THEN 850 WHEN railway = 'rail' AND usage = 'industrial' AND service IN ('siding', 'spur', 'yard', 'crossover') THEN 850 WHEN railway IN ('preserved', 'construction') THEN 400 - WHEN railway = 'disused' THEN 300 ELSE 50 END AS rank, layer, @@ -391,7 +369,7 @@ Layer: railway_electrification_state(railway, electrified, deelectrified, abandoned_electrified, construction_electrified, proposed_electrified, FALSE) AS state FROM openrailwaymap_osm_line WHERE - railway IN ('rail', 'tram', 'light_rail', 'subway', 'narrow_gauge', 'disused', 'construction', 'preserved') + railway IN ('rail', 'tram', 'light_rail', 'subway', 'narrow_gauge', 'construction', 'preserved') AND ( electrified IS NOT NULL OR deelectrified IS NOT NULL diff --git a/electrification.mss b/electrification.mss index 7443fab8..ccf952c5 100644 --- a/electrification.mss +++ b/electrification.mss @@ -134,12 +134,7 @@ [zoom>=11]["railway"="narrow_gauge"]["service"="siding"], [zoom>=11]["railway"="narrow_gauge"]["service"="crossover"], [zoom>=12]["railway"="narrow_gauge"]["service"="yard"], - [zoom>=9]["railway"="disused"]["disused_railway"="rail"]["service"=null], - [zoom>=11]["railway"="disused"]["disused_railway"="subway"]["service"=null], - [zoom>=11]["railway"="disused"]["disused_railway"="light_rail"]["service"=null], - [zoom>=12]["railway"="disused"]["disused_railway"="tram"]["service"=null], /* service!=null is required to get a smaller Mapnik XML style with the Carto compiler. */ - [zoom>=13]["railway"="disused"]["service"!=null], [zoom>=9]["railway"="construction"]["construction_railway"="rail"]["usage"="main"]["service"=null], [zoom>=9]["railway"="construction"]["construction_railway"="rail"]["usage"="branch"]["service"=null], [zoom>=10]["railway"="construction"]["construction_railway"="subway"]["service"=null], @@ -254,12 +249,7 @@ [zoom>=11]["railway"="narrow_gauge"]["service"="siding"], [zoom>=11]["railway"="narrow_gauge"]["service"="crossover"], [zoom>=12]["railway"="narrow_gauge"]["service"="yard"], - [zoom>=11]["railway"="disused"]["disused_railway"="rail"]["service"=null], - [zoom>=12]["railway"="disused"]["disused_railway"="subway"]["service"=null], - [zoom>=12]["railway"="disused"]["disused_railway"="light_rail"]["service"=null], - [zoom>=13]["railway"="disused"]["disused_railway"="tram"]["service"=null], /* service!=null is required to get a smaller Mapnik XML style with the Carto compiler. */ - [zoom>=13]["railway"="disused"]["service"!=null], [zoom>=11]["railway"="construction"]["construction_railway"="rail"]["usage"="main"]["service"=null], [zoom>=11]["railway"="construction"]["construction_railway"="rail"]["usage"="branch"]["service"=null], [zoom>=12]["railway"="construction"]["construction_railway"="subway"]["service"=null], From ce74361ac8bf34c3a8c4448c5e539b0d7f79e810 Mon Sep 17 00:00:00 2001 From: Michael Reichert Date: Sat, 6 Feb 2021 21:24:39 +0100 Subject: [PATCH 17/19] If electrified tracks have no frequency set, do not treat them as DC powered. --- sql/functions.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sql/functions.sql b/sql/functions.sql index a97454fa..04b44c3a 100644 --- a/sql/functions.sql +++ b/sql/functions.sql @@ -456,7 +456,7 @@ BEGIN volt_text := (volt_int::FLOAT / 1000::FLOAT)::NUMERIC(3, 1)::TEXT || 'kV'; END IF; -- Output voltage and frequency - IF freq = '0' OR freq IS NULL THEN + IF freq = '0' THEN RETURN volt_text || ' ='; END IF; IF freq IS NOT NULL THEN From 6ff03ee5a561d6697622ff059fa91bf580eee813 Mon Sep 17 00:00:00 2001 From: Michael Reichert Date: Thu, 11 Feb 2021 17:49:15 +0100 Subject: [PATCH 18/19] Bugfix electrification style: Render all lines under construction This commit adds coloured dashing for railway=construction without usage=* and service=*. --- electrification.mss | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/electrification.mss b/electrification.mss index ccf952c5..5342732d 100644 --- a/electrification.mss +++ b/electrification.mss @@ -140,7 +140,7 @@ [zoom>=10]["railway"="construction"]["construction_railway"="subway"]["service"=null], [zoom>=10]["railway"="construction"]["construction_railway"="light_rail"]["service"=null], [zoom>=11]["railway"="construction"]["construction_railway"="tram"]["service"=null], - [zoom>=13]["railway"="construction"]["service"!=null], + [zoom>=13]["railway"="construction"], [zoom>=10]["railway"="subway"]["service"=null], [zoom>=13]["railway"="subway"]["service"!=null], [zoom>=10]["railway"="light_rail"]["service"=null], @@ -255,7 +255,7 @@ [zoom>=12]["railway"="construction"]["construction_railway"="subway"]["service"=null], [zoom>=12]["railway"="construction"]["construction_railway"="light_rail"]["service"=null], [zoom>=13]["railway"="construction"]["construction_railway"="tram"]["service"=null], - [zoom>=13]["railway"="construction"]["service"!=null], + [zoom>=13]["railway"="construction"], [zoom>=12]["railway"="subway"]["service"=null], [zoom>=13]["railway"="subway"]["service"!=null], [zoom>=12]["railway"="light_rail"]["service"=null], From a222308a3ab93351fff135ead6eea11d22d20144 Mon Sep 17 00:00:00 2001 From: Michael Reichert Date: Thu, 11 Feb 2021 18:58:38 +0100 Subject: [PATCH 19/19] Render future electrification like no electrification on zoom < 9 On zoom < 9, electrification under construction and proposed electrification is rendered like electrified=no. --- electrification.mss | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/electrification.mss b/electrification.mss index 5342732d..5325126a 100644 --- a/electrification.mss +++ b/electrification.mss @@ -148,7 +148,9 @@ [zoom>=11]["railway"="tram"]["service"=null], [zoom>=13]["railway"="tram"]["service"!=null] { - ["state"="no"] { + ["state"="no"], + ["state"="proposed"][zoom < 9], + ["state"="construction"][zoom < 9] { line-color: black; }