Open Infrastructure Map, a view of infrastructure data in OpenStreetMap
Power style updates
Russ Garrett0f17b237fb14
diff --git a/sprites/power_plant_biomass.svg b/sprites/power_plant_biomass.svgnew file mode 100644index 0000000..270aac7--- /dev/null+++ b/sprites/power_plant_biomass.svg@@ -0,0 +1,15 @@+<?xml version="1.0" encoding="UTF-8"?>+<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">+<svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0" y="0" width="28.346" height="28.346" viewBox="0, 0, 28.346, 28.346">+ <g id="Background">+ <rect x="0" y="0" width="28.346" height="28.346" fill="#000000" fill-opacity="0"/>+ </g>+ <g id="Layer_1">+ <g>+ <path d="M2.079,2.079 L26.267,2.079 L26.267,26.267 L2.079,26.267 L2.079,2.079 z" fill="#FFFFFF"/>+ <path d="M2.079,2.079 L26.267,2.079 L26.267,26.267 L2.079,26.267 L2.079,2.079 z" fill-opacity="0" stroke="#3B3B3B" stroke-width="4"/>+ </g>+ <path d="M6.872,19.12 L21.122,19.057 L15.504,13.432 L21.122,13.432 L13.553,5.87 L6.872,13.432 L12.489,13.432 L6.872,19.12 z" fill-opacity="0" stroke="#3B3B3B" stroke-width="1.8"/>+ <path d="M14.173,19.12 L14.173,23.307" fill-opacity="0" stroke="#3B3B3B" stroke-width="2"/>+ </g>+</svg>diff --git a/sprites/power_plant_waste.svg b/sprites/power_plant_waste.svgnew file mode 100644index 0000000..4dc4c5e--- /dev/null+++ b/sprites/power_plant_waste.svg@@ -0,0 +1,19 @@+<?xml version="1.0" encoding="UTF-8"?>+<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">+<svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0" y="0" width="28.346" height="28.346" viewBox="0, 0, 28.346, 28.346">+ <g id="Background">+ <rect x="0" y="0" width="28.346" height="28.346" fill="#000000" fill-opacity="0"/>+ </g>+ <g id="Layer_1">+ <g>+ <path d="M2.079,2.079 L26.267,2.079 L26.267,26.267 L2.079,26.267 L2.079,2.079 z" fill="#FFFFFF"/>+ <path d="M2.079,2.079 L26.267,2.079 L26.267,26.267 L2.079,26.267 L2.079,2.079 z" fill-opacity="0" stroke="#3B3B3B" stroke-width="4"/>+ </g>+ <path d="M21.159,9.495 L19.346,22.557 L9,22.557 L7.187,9.495 L21.159,9.495 z" fill-opacity="0" stroke="#3B3B3B" stroke-width="1.5"/>+ <path d="M6.142,7.37 L22.204,7.37" fill-opacity="0" stroke="#3B3B3B" stroke-width="1"/>+ <path d="M11.97,7.091 L11.97,5.497 L16.376,5.497 L16.376,7.091" fill-opacity="0" stroke="#3B3B3B" stroke-width="1"/>+ <path d="M14.227,11.713 L14.227,20.338" fill-opacity="0" stroke="#3B3B3B" stroke-width="1.5" stroke-linecap="round"/>+ <path d="M11.236,11.713 L11.236,20.338" fill-opacity="0" stroke="#3B3B3B" stroke-width="1.5" stroke-linecap="round"/>+ <path d="M17.111,11.713 L17.111,20.338" fill-opacity="0" stroke="#3B3B3B" stroke-width="1.5" stroke-linecap="round"/>+ </g>+</svg>diff --git a/sprites/power_pole_transition.svg b/sprites/power_pole_transition.svgnew file mode 100644index 0000000..bdb82a0--- /dev/null+++ b/sprites/power_pole_transition.svg@@ -0,0 +1,17 @@+<?xml version="1.0" encoding="UTF-8"?>+<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">+<svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0" y="0" width="20" height="20" viewBox="0, 0, 20, 20">+ <g id="Background">+ <rect x="0" y="0" width="20" height="20" fill="#000000" fill-opacity="0"/>+ </g>+ <g id="Layer_1">+ <g>+ <path d="M0.75,0.858 L19.25,0.858 L9.848,18.979 L0.75,0.858 z" fill="#FFFFFF"/>+ <path d="M0.75,0.858 L19.25,0.858 L9.848,18.979 L0.75,0.858 z" fill-opacity="0" stroke="#3B3B3B" stroke-width="1.333" stroke-linejoin="round"/>+ </g>+ <g>+ <path d="M10,9.156 C9.059,9.156 8.297,8.394 8.297,7.453 C8.297,6.513 9.059,5.75 10,5.75 C10.941,5.75 11.703,6.513 11.703,7.453 C11.703,8.394 10.941,9.156 10,9.156 z" fill="#3B3B3B"/>+ <path d="M10,9.156 C9.059,9.156 8.297,8.394 8.297,7.453 C8.297,6.513 9.059,5.75 10,5.75 C10.941,5.75 11.703,6.513 11.703,7.453 C11.703,8.394 10.941,9.156 10,9.156 z" fill-opacity="0" stroke="#3B3B3B" stroke-width="1.333"/>+ </g>+ </g>+</svg>diff --git a/sprites/power_tower.svg b/sprites/power_tower.svgindex 9c26121..12a0077 100644--- a/sprites/power_tower.svg+++ b/sprites/power_tower.svg@@ -1,10 +1,15 @@<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"><svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0" y="0" width="15" height="15" viewBox="0, 0, 15, 15">+ <g id="Background">+ <rect x="0" y="0" width="15" height="15" fill="#000000" fill-opacity="0"/>+ </g><g id="Layer_1">- <path d="M0,-0 L15,-0 L15,15 L0,15 z" fill="#3B3B3B"/>- <path d="M12.857,7.5 C12.857,10.459 10.459,12.857 7.5,12.857 C4.541,12.857 2.143,10.459 2.143,7.5 C2.143,4.541 4.541,2.143 7.5,2.143 C10.459,2.143 12.857,4.541 12.857,7.5 z" fill="#FFFFFF"/>- <path d="M1.339,2.143 L12.857,13.661 L13.661,12.857 L2.143,1.339 z" fill="#3B3B3B"/>- <path d="M12.857,1.339 L1.339,12.857 L2.143,13.661 L13.661,2.143 z" fill="#3B3B3B"/>+ <g>+ <path d="M1.094,13.947 L1.093,1.072 L13.969,1.071 L13.969,13.946 z" fill="#FFFFFF"/>+ <path d="M1.094,13.947 L1.093,1.072 L13.969,1.071 L13.969,13.946 z" fill-opacity="0" stroke="#3B3B3B" stroke-width="2" stroke-linejoin="bevel"/>+ </g>+ <path d="M0.267,1.391 L13.587,14.478 L14.517,13.564 L1.197,0.478 z" fill="#3B3B3B"/>+ <path d="M13.595,0.478 L0.392,13.564 L1.313,14.478 L14.517,1.391 z" fill="#3B3B3B"/></g></svg>diff --git a/sprites/power_tower_transition.svg b/sprites/power_tower_transition.svgnew file mode 100644index 0000000..4866883--- /dev/null+++ b/sprites/power_tower_transition.svg@@ -0,0 +1,16 @@+<?xml version="1.0" encoding="UTF-8"?>+<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">+<svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0" y="0" width="20" height="20" viewBox="0, 0, 20, 20">+ <g id="Background">+ <rect x="0" y="0" width="20" height="20" fill="#000000" fill-opacity="0"/>+ </g>+ <g id="Background"/>+ <g id="Layer_1">+ <g>+ <path d="M1.061,1.109 L18.874,1.107 L9.824,18.979 L1.061,1.109 z" fill="#FFFFFF"/>+ <path d="M1.061,1.109 L18.874,1.107 L9.824,18.979 L1.061,1.109 z" fill-opacity="0" stroke="#3B3B3B" stroke-width="2" stroke-linejoin="round"/>+ </g>+ <path d="M0.75,0.858 L14.514,10.354" fill-opacity="0" stroke="#3B3B3B" stroke-width="1.333"/>+ <path d="M19.25,0.858 L5.264,10.354" fill-opacity="0" stroke="#3B3B3B" stroke-width="1.333"/>+ </g>+</svg>diff --git a/src/infopopup.js b/src/infopopup.jsindex d912fa2..586f9c9 100644--- a/src/infopopup.js+++ b/src/infopopup.js@@ -50,7 +50,7 @@ class InfoPopup {return null;}- if (key == 'voltage') {+ if (key.startsWith('voltage')) {value += ' kV';}diff --git a/src/style_oim_power.js b/src/style_oim_power.jsindex e1c6712..c3c13de 100644--- a/src/style_oim_power.js+++ b/src/style_oim_power.js@@ -1,22 +1,56 @@import {text_paint, underground_p} from './style_oim_common.js';// OpenInfraMap layers+// === Frequency predicates+const traction_freq_p = ["all",+ ['has', 'frequency'],+ ["!=", ["get", "frequency"], ''],+ ["!=", ["to-number", ["get", "frequency"]], 50],+ ["!=", ["to-number", ["get", "frequency"]], 60]+];++const hvdc_p = ["all",+ ['has', 'frequency'],+ ["!=", ["get", "frequency"], ''],+ ["==", ["to-number", ["get", "frequency"]], 0]+];++// Stepwise function to assign colour by voltage:-const voltage_color = ["match",- ['string', ['coalesce', ['get', 'frequency'], '50']],- '0', '#4E01B5', // HVDC (frequency == 0)- ['step',- ["coalesce", ['get', 'voltage'], 0],- '#7A7A85',- 9.9, '#6E97B8',- 24.1, '#55B555',- 52.1, '#B59F10',- 123.1, '#B55D00',- 219.9, '#C73030',- 300.1, '#B54EB2',- 500.1, '#00C1CF'+function voltage_color(field) {+ return ["case",+ hvdc_p, '#4E01B5', // HVDC (frequency == 0)+ traction_freq_p, '#A8B596', // Traction power+ ['step',+ ["coalesce", ['get', field], 0],+ '#7A7A85',+ 9.9, '#6E97B8',+ 24.1, '#55B555',+ 52.1, '#B59F10',+ 123.1, '#B55D00',+ 219.9, '#C73030',+ 300.1, '#B54EB2',+ 500.1, '#00C1CF'+ ]]-]+}++// Generate an expression to determine the offset of a power line+// segment with multiple voltages+function voltage_offset(index) {+ let offset = 0;+ if (index == 1) {+ offset = -2;+ }+ if (index == 2) {+ offset = 2+ }++ return ['interpolate', ['linear'], ['zoom'],+ 4, ['case', ['has', 'voltage_2'], offset * 0.25, 0],+ 10, ['case', ['has', 'voltage_2'], offset, 0],+ ]+}// Function to assign power line thickness.// Interpolate first by zoom level and then by voltage.@@ -169,22 +203,14 @@ const plant_image = ["match",'gas', 'power_plant_oilgas','solar', 'power_plant_solar','wind', 'power_plant_wind',+ 'biomass', 'power_plant_biomass',+ 'waste', 'power_plant_waste','power_plant'];-const freq = ["case",- ["all",- ["!=", ["get", "frequency"], ''],- ["==", ["to-number", ["get", "frequency"]], 0]- ],- " DC",- ["all",- ["!=", ["get", "frequency"], ''],- ["!=", ["to-number", ["get", "frequency"]], 50],- ["!=", ["to-number", ["get", "frequency"]], 60]- ],- ["concat", " ", ["get", "frequency"], " Hz"],+ hvdc_p, " DC",+ traction_freq_p, ["concat", " ", ["get", "frequency"], " Hz"],""];@@ -198,24 +224,39 @@ const circuits = ["case",""]+const line_voltage = ["case",+ ["has", "voltage_3"],+ ["concat",+ ["get", "voltage"], "/",+ ["get", "voltage_2"], "/",+ ["get", "voltage_3"], " kV"],+ ["has", "voltage_2"],+ ["concat",+ ["get", "voltage"], "/",+ ["get", "voltage_2"], " kV"],+ ["has", "voltage"],+ ["concat",+ ["get", "voltage"], " kV"],+ ""+]+const line_label = ["case",["all", ["has", "voltage"], ["!=", ["get", "name"], ""]],- ["concat", ["get", "name"], " (", circuits, ["get", "voltage"], " kV", freq, ")"],+ ["concat", ["get", "name"], " (", line_voltage, freq, ")"],["has", "voltage"],- ["concat", circuits, ["get", "voltage"], " kV", freq],+ ["concat", circuits, line_voltage, freq],["get", "name"]];-// TODO: frequency would be nice here but it's not in the DB.const substation_label = ["step",["zoom"],["get", "name"],12, ["case",['all', ['!=', ['get', 'name'], ''], ["has", "voltage"]],- ["concat", ["get", "name"], " ", ["get", "voltage"], " kV"],+ ["concat", ["get", "name"], " ", ["get", "voltage"], " kV", freq],['all', ['==', ['get', 'name'], ''], ['has', 'voltage']],- ["concat", "Substation ", ["get", "voltage"], " kV"],+ ["concat", "Substation ", ["get", "voltage"], " kV", freq],["get", "name"]]];@@ -243,16 +284,36 @@ const layers = [},{zorder: 61,- id: 'power_line_underground',+ id: 'power_line_underground_1',type: 'line',filter: ['all', underground_p, power_visible_p],source: 'openinframap','source-layer': 'power_line',minzoom: 0,paint: {- 'line-color': voltage_color,+ 'line-color': voltage_color('voltage'),+ 'line-width': voltage_line_thickness,+ 'line-dasharray': [3, 2],+ 'line-offset': voltage_offset(1),+ },+ layout: {+ 'line-join': 'round',+ 'line-cap': 'round'+ }+ },+ {+ zorder: 61,+ id: 'power_line_underground_2',+ type: 'line',+ filter: ['all', underground_p, power_visible_p, ['has', 'voltage_2']],+ source: 'openinframap',+ 'source-layer': 'power_line',+ minzoom: 0,+ paint: {+ 'line-color': voltage_color('voltage_2'),'line-width': voltage_line_thickness,- 'line-dasharray': [3, 2]+ 'line-dasharray': [3, 2],+ 'line-offset': voltage_offset(2),},layout: {'line-join': 'round',@@ -281,7 +342,7 @@ const layers = [minzoom: 13,paint: {'fill-opacity': 0.3,- 'fill-color': voltage_color,+ 'fill-color': voltage_color('voltage'),'fill-outline-color': 'rgba(0, 0, 0, 1)',},},@@ -300,15 +361,34 @@ const layers = [},{zorder: 260,- id: 'power_line',+ id: 'power_line_1',type: 'line',source: 'openinframap','source-layer': 'power_line',filter: ['all', ['!', underground_p], power_visible_p],minzoom: 0,paint: {- 'line-color': voltage_color,+ 'line-color': voltage_color('voltage'),'line-width': voltage_line_thickness,+ 'line-offset': voltage_offset(1)+ },+ layout: {+ 'line-join': 'round',+ 'line-cap': 'round',+ }+ },+ {+ zorder: 260,+ id: 'power_line_2',+ type: 'line',+ source: 'openinframap',+ 'source-layer': 'power_line',+ filter: ['all', ['!', underground_p], power_visible_p, ['has', 'voltage_2']],+ minzoom: 0,+ paint: {+ 'line-color': voltage_color('voltage_2'),+ 'line-width': voltage_line_thickness,+ 'line-offset': voltage_offset(2),},layout: {'line-join': 'round',@@ -361,7 +441,7 @@ const layers = [minzoom: 13,paint: text_paint,layout: {- 'icon-image': 'power_tower',+ 'icon-image': ["case", ["get", "transition"], 'power_tower_transition', 'power_tower'],'icon-size': ["interpolate", ["linear"], ["zoom"],13, 0.4,17, 1@@ -387,7 +467,7 @@ const layers = [minzoom: 14,paint: text_paint,layout: {- 'icon-image': 'power_pole',+ 'icon-image': ["case", ["get", "transition"], 'power_pole_transition', 'power_pole'],'icon-size': 0.5,'text-field': '{ref}','text-size': ["step",@@ -458,7 +538,7 @@ const layers = [layout: {},paint: {'circle-radius': substation_radius,- 'circle-color': voltage_color,+ 'circle-color': voltage_color('voltage'),'circle-stroke-width': ['interpolate', ['linear'], ['zoom'],5, 0,6, 0.01,@@ -477,7 +557,7 @@ const layers = [layout: {},paint: {'circle-radius': 4,- 'circle-color': voltage_color,+ 'circle-color': voltage_color('voltage'),'circle-stroke-width': 1},},@@ -515,7 +595,7 @@ const layers = ['symbol-placement': 'line','symbol-spacing': 400,'text-size': 10,- 'text-offset': [0, 1],+ 'text-offset': ['case', ['has', 'voltage_2'], ['literal', [0, 1.25]], ['literal', [0, 1]]],'text-max-angle': 10}},