Skip to content

Open Infrastructure Map, a view of infrastructure data in OpenStreetMap

Handle rendering of low voltages better

Russ Garrett257b18e22079
diff --git a/web/src/style/style_oim_power.js b/web/src/style/style_oim_power.js
index e899650..9fa6120 100644
--- a/web/src/style/style_oim_power.js
+++ b/web/src/style/style_oim_power.js
@@ -357,6 +357,14 @@ const freq = [
'',
];
+function round(field, places) {
+ const pow = Math.pow(10, places);
+ return ["/",
+ ["round", ["*", field, pow]],
+ pow
+ ];
+}
+
const line_voltage = [
'case',
[
@@ -366,11 +374,11 @@ const line_voltage = [
],
[
'concat',
- ['get', 'voltage'],
+ round(['get', 'voltage'], 3),
'/',
- ['get', 'voltage_2'],
+ round(['get', 'voltage_2'], 3),
'/',
- ['get', 'voltage_3'],
+ round(['get', 'voltage_3'], 3),
' kV',
],
[
@@ -378,9 +386,9 @@ const line_voltage = [
['has', 'voltage_2'],
['!=', ['get', 'voltage_2'], ['get', 'voltage']],
],
- ['concat', ['get', 'voltage'], '/', ['get', 'voltage_2'], ' kV'],
+ ['concat', round(['get', 'voltage'], 3), '/', round(['get', 'voltage_2'], 3), ' kV'],
['has', 'voltage'],
- ['concat', ['get', 'voltage'], ' kV'],
+ ['concat', round(['get', 'voltage'], 3), ' kV'],
'',
];