Skip to content

Commit 0914577

Browse files
committed
Restrict osmosis_powerline class 8 to 50 kV and above
1 parent 382431b commit 0914577

File tree

2 files changed

+25
-6
lines changed

2 files changed

+25
-6
lines changed

analysers/analyser_osmosis_powerline.py

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -398,7 +398,7 @@
398398
399399
UNION
400400
401-
-- Nodes with no voltages
401+
-- Nodes with no (numerical) voltages
402402
SELECT
403403
nid,
404404
tid,
@@ -575,13 +575,32 @@
575575
sql70 = """
576576
CREATE TEMP TABLE power_lines_mgmt AS
577577
578-
WITH vertices AS (
578+
WITH nodes_voltage AS (
579+
SELECT
580+
nid,
581+
tid,
582+
unnest(voltages)::varchar AS voltage
583+
FROM
584+
power_lines_topoedges
585+
),
586+
-- We process nodes with voltage > 50 kV only
587+
nodes_selected AS (
588+
SELECT
589+
nid
590+
FROM nodes_voltage
591+
WHERE voltage ~ '^[0-9.]+$' AND
592+
voltage::numeric >= 50000
593+
GROUP BY nid
594+
),
595+
vertices AS (
579596
SELECT
580597
e.nid,
581598
string_agg(CASE e.location WHEN 'overhead' THEN e.circuits::varchar ELSE NULL END, '-' ORDER BY e.circuits desc) AS circuits_overhead,
582599
string_agg(CASE WHEN e.location!='overhead' THEN e.circuits::varchar ELSE NULL END, '-' ORDER BY e.circuits desc) AS circuits_elsewhere
583600
FROM
584601
power_lines_topoedges e
602+
JOIN nodes_selected ns ON
603+
ns.nid=e.nid
585604
JOIN nodes n ON
586605
n.id=e.nid
587606
GROUP BY
@@ -749,9 +768,9 @@ def __callback80_fix(self, res):
749768
result.append({"~": {"line_management": res[2]}})
750769
if res[3]:
751770
if res[5] is None:
752-
result.append({"+": {"line_management": res[3]}})
771+
result.append({"+": {"location:transition": res[3]}})
753772
elif res[5] != res[3]:
754-
result.append({"~": {"line_management": res[3]}})
773+
result.append({"~": {"location:transition": res[3]}})
755774

756775
return result
757776

tests/osmosis_powerline.test.osm

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@
1717
<tag k='location' v='underground' />
1818
<tag k='power' v='pole' />
1919
</node>
20-
<node id='25880' timestamp='2025-04-24T15:00:00Z' version='1' lat='46.19018976738' lon='4.47730911825'>
21-
<tag k='line_management' v='branch' />
20+
<node id='25880' action='modify' timestamp='2025-04-24T15:00:00Z' version='1' lat='46.19018976738' lon='4.47730911825'>
21+
<tag k='note' v='Should NOT raise class 8 warning line_management suggestion: below 50 kV' />
2222
<tag k='power' v='pole' />
2323
</node>
2424
<node id='25881' timestamp='2025-04-24T15:00:00Z' version='1' lat='46.19025116596' lon='4.47738773173'>

0 commit comments

Comments
 (0)