Skip to content

Commit

Permalink
Ensure proposed, construction, deelectrified and abandoned lines are …
Browse files Browse the repository at this point in the history
…rendered properly
  • Loading branch information
hiddewie committed Nov 2, 2024
1 parent 9f4756a commit 65c8360
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 10 deletions.
19 changes: 9 additions & 10 deletions import/openrailwaymap.lua
Original file line number Diff line number Diff line change
Expand Up @@ -298,23 +298,23 @@ function train_protection(tags)
end

local electrification_values = osm2pgsql.make_check_values_func({'contact_line', 'yes', 'rail', 'ground-level_power_supply', '4th_rail', 'contact_line;rail', 'rail;contact_line'})
function electrification_state(tags, ignore_future_states)
function electrification_state(tags)
local electrified = tags['electrified']

if electrification_values(electrified) then
return 'present', tonumber(tags['voltage']), tonumber(tags['frequency'])
return 'present', tonumber(tags['voltage']), tonumber(tags['frequency']), nil, nil
end
if (not ignore_future_states) and electrification_values(tags['construction:electrified']) then
return 'construction', tonumber(tags['construction:voltage']), tonumber(tags['construction:frequency'])
if electrification_values(tags['construction:electrified']) then
return 'construction', nil, nil, tonumber(tags['construction:voltage']), tonumber(tags['construction:frequency'])
end
if (not ignore_future_states) and electrification_values(tags['proposed:electrified']) then
return 'proposed', tonumber(tags['proposed:voltage']), tonumber(tags['proposed:frequency'])
if electrification_values(tags['proposed:electrified']) then
return 'proposed', nil, nil, tonumber(tags['proposed:voltage']), tonumber(tags['proposed:frequency'])
end
if electrified == 'no' and electrification_values(tags['deelectrified']) then
return 'deelectrified', nil, nil
return 'deelectrified', nil, nil, nil, nil
end
if electrified == 'no' and electrification_values(tags['abandoned:electrified']) then
return 'abandoned', nil, nil
return 'abandoned', nil, nil, nil, nil
end

return nil, nil, nil
Expand Down Expand Up @@ -535,8 +535,7 @@ function osm2pgsql.process_way(object)
if railway_values(tags.railway) then
local railway_train_protection, railway_train_protection_rank = train_protection(tags)

local current_electrification_state, voltage, frequency = electrification_state(tags, true)
local _, future_voltage, future_frequency = electrification_state(tags, false)
local current_electrification_state, voltage, frequency, future_voltage, future_frequency = electrification_state(tags)

local gauges = {}
local gauge_tag = tags['gauge'] or tags['construction:gauge']
Expand Down
2 changes: 2 additions & 0 deletions proxy/js/ui.js
Original file line number Diff line number Diff line change
Expand Up @@ -676,6 +676,8 @@ function popupContent(properties) {
${properties.speed_label ? `<span class="badge rounded-pill text-bg-light">speed: ${properties.speed_label}</span>` : ''}
${properties.voltage ? `<span class="badge rounded-pill text-bg-light">voltage: ${properties.voltage} V</span>` : ''}
${properties.frequency ? `<span class="badge rounded-pill text-bg-light">frequency: ${properties.frequency.toFixed(2)} Hz</span>` : ''}
${properties.future_voltage ? `<span class="badge rounded-pill text-bg-light">voltage (future): ${properties.future_voltage} V</span>` : ''}
${properties.future_frequency ? `<span class="badge rounded-pill text-bg-light">frequency (future): ${properties.future_frequency.toFixed(2)} Hz</span>` : ''}
${properties.gauge_label ? `<span class="badge rounded-pill text-bg-light">gauge: ${properties.gauge_label}</span>` : ''}
${properties.loading_gauge ? `<span class="badge rounded-pill text-bg-light">loading gauge: ${properties.loading_gauge}</span>` : ''}
</h6>
Expand Down

0 comments on commit 65c8360

Please sign in to comment.