Skip to content

Commit 5185729

Browse files
committed
fix blockkennzeichen multiline rendering
1 parent e0636d2 commit 5185729

File tree

3 files changed

+36
-26
lines changed

3 files changed

+36
-26
lines changed

features/signals_railway_signals.yaml

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -826,9 +826,18 @@ signals_railway_signals:
826826

827827
- description: Blockkennzeichen
828828
country: DE
829-
# TODO match width and height
830-
# WHEN ref_width <= 4 AND ref_height <= 2 THEN CONCAT('de/blockkennzeichen-', ref_width, 'x', ref_height)
831-
icon: { default: 'de/blockkennzeichen' }
829+
icon:
830+
match: 'ref_multiline'
831+
cases:
832+
- { regex: '^([^\n]{4}\n[^\n]{1,4})|([^\n]{1,4}\n[^\n]{4})$', value: 'de/blockkennzeichen-4x2' }
833+
- { regex: '^[^\n]{4}$', value: 'de/blockkennzeichen-4x1' }
834+
- { regex: '^([^\n]{3}\n[^\n]{1,3})|([^\n]{1,3}\n[^\n]{3})$', value: 'de/blockkennzeichen-3x2' }
835+
- { regex: '^[^\n]{3}$', value: 'de/blockkennzeichen-3x1' }
836+
- { regex: '^([^\n]{2}\n[^\n]{1,2})|([^\n]{1,2}\n[^\n]{2})$', value: 'de/blockkennzeichen-2x2' }
837+
- { regex: '^[^\n]{2}$', value: 'de/blockkennzeichen-2x1' }
838+
- { regex: '^[^\n]\n[^\n]$', value: 'de/blockkennzeichen-1x2' }
839+
- { regex: '^[^\n]$', value: 'de/blockkennzeichen-1x1' }
840+
default: 'de/blockkennzeichen'
832841
tags:
833842
- { tag: 'railway:signal:train_protection', value: 'DE-ESO:blockkennzeichen' }
834843

import/openrailwaymap.lua

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -169,8 +169,6 @@ local signals = osm2pgsql.define_table({
169169
{ column = 'deactivated', type = 'boolean' },
170170
{ column = 'ref', type = 'text' },
171171
{ column = 'ref_multiline', type = 'text' },
172-
{ column = 'ref_width', type = 'smallint' },
173-
{ column = 'ref_height', type = 'smallint' },
174172
{ column = 'signal_direction', type = 'text' },
175173
{% for tag in signals_railway_signals.tags %}
176174
{ column = '{% tag %}', type = 'text' },
@@ -429,11 +427,6 @@ function osm2pgsql.process_node(object)
429427
tags['railway:signal:speed_limit:deactivated']
430428
) == 'yes'
431429
local ref_multiline, newline_count = (tags.ref or ''):gsub(' ', '\n')
432-
local ref_height = newline_count + 1
433-
local ref_width = 0
434-
for part in string.gmatch(tags.ref or '', '[^ ]+') do
435-
ref_width = math.max(ref_width, part:len())
436-
end
437430

438431
signals:insert({
439432
way = object:as_point(),
@@ -442,8 +435,6 @@ function osm2pgsql.process_node(object)
442435
deactivated = deactivated,
443436
ref = tags.ref,
444437
ref_multiline = ref_multiline ~= '' and ref_multiline or nil,
445-
ref_height = ref_multiline ~= '' and ref_height or nil,
446-
ref_width = ref_multiline ~= '' and ref_width or nil,
447438
signal_direction = tags['railway:signal:direction'],
448439
{% for tag in signals_railway_signals.tags %}
449440
["{% tag %}"] = tags['{% tag %}'],

proxy/js/styles.mjs

Lines changed: 24 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2383,14 +2383,31 @@ const layers = {
23832383
}
23842384
},
23852385
...imageLayerWithOutline(
2386-
'railway_signals',
2387-
['get', 'feature'],
2386+
'railway_signals_medium',
2387+
['case',
2388+
['==', ['slice', ['get', 'feature'], 0, 20], 'de/blockkennzeichen-'], 'de/blockkennzeichen',
2389+
['get', 'feature'],
2390+
],
23882391
{
23892392
type: 'symbol',
23902393
minzoom: 13,
2394+
maxzoom: 16,
2395+
source: 'openrailwaymap_signals',
2396+
'source-layer': 'signals_railway_signals',
2397+
layout: {
2398+
'symbol-z-order': 'source',
2399+
'icon-overlap': 'always',
2400+
},
2401+
},
2402+
),
2403+
...imageLayerWithOutline(
2404+
'railway_signals_high',
2405+
['get', 'feature'],
2406+
{
2407+
type: 'symbol',
2408+
minzoom: 16,
23912409
source: 'openrailwaymap_signals',
23922410
'source-layer': 'signals_railway_signals',
2393-
// TODO fix blockkennzeichen
23942411
layout: {
23952412
'symbol-z-order': 'source',
23962413
'icon-overlap': 'always',
@@ -2483,17 +2500,10 @@ const layers = {
24832500
minzoom: 13,
24842501
source: 'openrailwaymap_signals',
24852502
'source-layer': 'signals_railway_signals',
2486-
filter: ['step', ['zoom'],
2487-
['all',
2488-
['!=', ['get', 'ref'], null],
2489-
['!=', ['get', 'feature'], ''],
2490-
],
2491-
16,
2492-
['all',
2493-
['!=', ['get', 'ref'], null],
2494-
['!=', ['get', 'feature'], ''],
2495-
['!=', ['slice', ['get', 'feature'], 0, 20], 'de/blockkennzeichen-'],
2496-
],
2503+
filter: ['all',
2504+
['!=', ['get', 'ref'], null],
2505+
['!=', ['get', 'feature'], ''],
2506+
['!=', ['slice', ['get', 'feature'], 0, 20], 'de/blockkennzeichen-'],
24972507
],
24982508
paint: {
24992509
'text-halo-color': ['case',

0 commit comments

Comments
 (0)