Skip to content

Commit

Permalink
fix blockkennzeichen multiline rendering
Browse files Browse the repository at this point in the history
  • Loading branch information
hiddewie committed Oct 26, 2024
1 parent e0636d2 commit 5185729
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 26 deletions.
15 changes: 12 additions & 3 deletions features/signals_railway_signals.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -826,9 +826,18 @@ signals_railway_signals:

- description: Blockkennzeichen
country: DE
# TODO match width and height
# WHEN ref_width <= 4 AND ref_height <= 2 THEN CONCAT('de/blockkennzeichen-', ref_width, 'x', ref_height)
icon: { default: 'de/blockkennzeichen' }
icon:
match: 'ref_multiline'
cases:
- { regex: '^([^\n]{4}\n[^\n]{1,4})|([^\n]{1,4}\n[^\n]{4})$', value: 'de/blockkennzeichen-4x2' }
- { regex: '^[^\n]{4}$', value: 'de/blockkennzeichen-4x1' }
- { regex: '^([^\n]{3}\n[^\n]{1,3})|([^\n]{1,3}\n[^\n]{3})$', value: 'de/blockkennzeichen-3x2' }
- { regex: '^[^\n]{3}$', value: 'de/blockkennzeichen-3x1' }
- { regex: '^([^\n]{2}\n[^\n]{1,2})|([^\n]{1,2}\n[^\n]{2})$', value: 'de/blockkennzeichen-2x2' }
- { regex: '^[^\n]{2}$', value: 'de/blockkennzeichen-2x1' }
- { regex: '^[^\n]\n[^\n]$', value: 'de/blockkennzeichen-1x2' }
- { regex: '^[^\n]$', value: 'de/blockkennzeichen-1x1' }
default: 'de/blockkennzeichen'
tags:
- { tag: 'railway:signal:train_protection', value: 'DE-ESO:blockkennzeichen' }

Expand Down
9 changes: 0 additions & 9 deletions import/openrailwaymap.lua
Original file line number Diff line number Diff line change
Expand Up @@ -169,8 +169,6 @@ local signals = osm2pgsql.define_table({
{ column = 'deactivated', type = 'boolean' },
{ column = 'ref', type = 'text' },
{ column = 'ref_multiline', type = 'text' },
{ column = 'ref_width', type = 'smallint' },
{ column = 'ref_height', type = 'smallint' },
{ column = 'signal_direction', type = 'text' },
{% for tag in signals_railway_signals.tags %}
{ column = '{% tag %}', type = 'text' },
Expand Down Expand Up @@ -429,11 +427,6 @@ function osm2pgsql.process_node(object)
tags['railway:signal:speed_limit:deactivated']
) == 'yes'
local ref_multiline, newline_count = (tags.ref or ''):gsub(' ', '\n')
local ref_height = newline_count + 1
local ref_width = 0
for part in string.gmatch(tags.ref or '', '[^ ]+') do
ref_width = math.max(ref_width, part:len())
end

signals:insert({
way = object:as_point(),
Expand All @@ -442,8 +435,6 @@ function osm2pgsql.process_node(object)
deactivated = deactivated,
ref = tags.ref,
ref_multiline = ref_multiline ~= '' and ref_multiline or nil,
ref_height = ref_multiline ~= '' and ref_height or nil,
ref_width = ref_multiline ~= '' and ref_width or nil,
signal_direction = tags['railway:signal:direction'],
{% for tag in signals_railway_signals.tags %}
["{% tag %}"] = tags['{% tag %}'],
Expand Down
38 changes: 24 additions & 14 deletions proxy/js/styles.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -2383,14 +2383,31 @@ const layers = {
}
},
...imageLayerWithOutline(
'railway_signals',
['get', 'feature'],
'railway_signals_medium',
['case',
['==', ['slice', ['get', 'feature'], 0, 20], 'de/blockkennzeichen-'], 'de/blockkennzeichen',
['get', 'feature'],
],
{
type: 'symbol',
minzoom: 13,
maxzoom: 16,
source: 'openrailwaymap_signals',
'source-layer': 'signals_railway_signals',
layout: {
'symbol-z-order': 'source',
'icon-overlap': 'always',
},
},
),
...imageLayerWithOutline(
'railway_signals_high',
['get', 'feature'],
{
type: 'symbol',
minzoom: 16,
source: 'openrailwaymap_signals',
'source-layer': 'signals_railway_signals',
// TODO fix blockkennzeichen
layout: {
'symbol-z-order': 'source',
'icon-overlap': 'always',
Expand Down Expand Up @@ -2483,17 +2500,10 @@ const layers = {
minzoom: 13,
source: 'openrailwaymap_signals',
'source-layer': 'signals_railway_signals',
filter: ['step', ['zoom'],
['all',
['!=', ['get', 'ref'], null],
['!=', ['get', 'feature'], ''],
],
16,
['all',
['!=', ['get', 'ref'], null],
['!=', ['get', 'feature'], ''],
['!=', ['slice', ['get', 'feature'], 0, 20], 'de/blockkennzeichen-'],
],
filter: ['all',
['!=', ['get', 'ref'], null],
['!=', ['get', 'feature'], ''],
['!=', ['slice', ['get', 'feature'], 0, 20], 'de/blockkennzeichen-'],
],
paint: {
'text-halo-color': ['case',
Expand Down

0 comments on commit 5185729

Please sign in to comment.