Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ensure proposed, construction, deelectrified and abandoned lines are rendered properly #137

Merged
merged 2 commits into from
Nov 2, 2024
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
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