Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 23 additions & 4 deletions analysers/analyser_osmosis_powerline.py
Original file line number Diff line number Diff line change
Expand Up @@ -398,7 +398,7 @@

UNION

-- Nodes with no voltages
-- Nodes with no (numerical) voltages
SELECT
nid,
tid,
Expand Down Expand Up @@ -575,13 +575,32 @@
sql70 = """
CREATE TEMP TABLE power_lines_mgmt AS

WITH vertices AS (
WITH nodes_voltage AS (
SELECT
nid,
tid,
unnest(voltages)::varchar AS voltage
FROM
power_lines_topoedges
),
-- We process nodes with voltage > 50 kV only
nodes_selected AS (
SELECT
nid
FROM nodes_voltage
WHERE voltage ~ '^[0-9.]+$' AND
voltage::numeric >= 50000
GROUP BY nid
),
vertices AS (
SELECT
e.nid,
string_agg(CASE e.location WHEN 'overhead' THEN e.circuits::varchar ELSE NULL END, '-' ORDER BY e.circuits desc) AS circuits_overhead,
string_agg(CASE WHEN e.location!='overhead' THEN e.circuits::varchar ELSE NULL END, '-' ORDER BY e.circuits desc) AS circuits_elsewhere
FROM
power_lines_topoedges e
JOIN nodes_selected ns ON
ns.nid=e.nid
JOIN nodes n ON
n.id=e.nid
GROUP BY
Expand Down Expand Up @@ -749,9 +768,9 @@ def __callback80_fix(self, res):
result.append({"~": {"line_management": res[2]}})
if res[3]:
if res[5] is None:
result.append({"+": {"line_management": res[3]}})
result.append({"+": {"location:transition": res[3]}})
elif res[5] != res[3]:
result.append({"~": {"line_management": res[3]}})
result.append({"~": {"location:transition": res[3]}})

return result

Expand Down
4 changes: 2 additions & 2 deletions tests/osmosis_powerline.test.osm
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
<tag k='location' v='underground' />
<tag k='power' v='pole' />
</node>
<node id='25880' timestamp='2025-04-24T15:00:00Z' version='1' lat='46.19018976738' lon='4.47730911825'>
<tag k='line_management' v='branch' />
<node id='25880' action='modify' timestamp='2025-04-24T15:00:00Z' version='1' lat='46.19018976738' lon='4.47730911825'>
<tag k='note' v='Should NOT raise class 8 warning line_management suggestion: below 50 kV' />
<tag k='power' v='pole' />
</node>
<node id='25881' timestamp='2025-04-24T15:00:00Z' version='1' lat='46.19025116596' lon='4.47738773173'>
Expand Down
Loading