Skip to content

Commit

Permalink
Improve signal features rendering (#149)
Browse files Browse the repository at this point in the history
Changes:
- Show references for speed and electrification signals
- Fix sizes of some icons
- Merge layers of symbol text into same layer as the icons.
  • Loading branch information
hiddewie authored Nov 17, 2024
1 parent 694b5d6 commit c3d60cf
Show file tree
Hide file tree
Showing 19 changed files with 134 additions and 142 deletions.
6 changes: 4 additions & 2 deletions import/sql/tile_views.sql
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,8 @@ CREATE OR REPLACE VIEW speed_railway_signals AS
speed_feature as feature,
speed_feature_type as type,
azimuth,
(signal_direction = 'both') as direction_both
(signal_direction = 'both') as direction_both,
ref
FROM signals_with_azimuth
WHERE railway = 'signal'
AND speed_feature IS NOT NULL
Expand Down Expand Up @@ -346,7 +347,8 @@ CREATE OR REPLACE VIEW electrification_signals AS
way,
electrification_feature as feature,
azimuth,
(signal_direction = 'both') as direction_both
(signal_direction = 'both') as direction_both,
ref
FROM signals_with_azimuth
WHERE
railway = 'signal'
Expand Down
2 changes: 2 additions & 0 deletions martin/configuration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,7 @@ postgres:
id: integer
feature: string
type: string
ref: string
azimuth: number
direction_both: boolean

Expand Down Expand Up @@ -279,6 +280,7 @@ postgres:
feature: string
azimuth: number
direction_both: boolean
ref: string


functions:
Expand Down
121 changes: 55 additions & 66 deletions proxy/js/styles.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -2256,9 +2256,23 @@ const layers = {
16,
['!=', ['get', 'feature'], null],
],
paint: {
'text-halo-color': ['case',
['boolean', ['feature-state', 'hover'], false], colors.hover.textHalo,
'white'
],
'text-halo-width': 1.5,
'text-halo-blur': 1,
},
layout: {
'symbol-z-order': 'source',
'icon-overlap': 'always',
'text-field': '{ref}',
'text-font': ['Noto Sans Medium'],
'text-size': 9,
'text-optional': true,
'text-anchor': 'top',
'text-offset': ['literal', [0, 1.5]],
},
},
),
Expand Down Expand Up @@ -2301,7 +2315,7 @@ const layers = {
'text-font': ['Noto Sans Bold'],
'text-size': 11,
'text-padding': 30,
'symbol-spacing': 100,
'symbol-spacing': 200,
},
},
searchResults,
Expand Down Expand Up @@ -2503,9 +2517,35 @@ const layers = {
minzoom: 16,
source: 'openrailwaymap_signals',
'source-layer': 'signals_railway_signals',
paint: {
'text-halo-color': ['case',
['boolean', ['feature-state', 'hover'], false], colors.hover.textHalo,
'white'
],
'text-halo-width': ['case',
['==', ['slice', ['get', 'feature'], 0, 20], 'de/blockkennzeichen-'], 2.0,
1.5,
],
'text-halo-blur': 1,
},
layout: {
'symbol-z-order': 'source',
'icon-overlap': 'always',
'text-field': ['case',
['==', ['slice', ['get', 'feature'], 0, 20], 'de/blockkennzeichen-'], ['get', 'ref_multiline'],
['get', 'ref'],
],
'text-font': ['Noto Sans Medium'],
'text-size': 9,
'text-optional': true,
'text-anchor': ['case',
['==', ['slice', ['get', 'feature'], 0, 20], 'de/blockkennzeichen-'], 'center',
'top',
],
'text-offset': ['case',
['==', ['slice', ['get', 'feature'], 0, 20], 'de/blockkennzeichen-'], ['literal', [0, 0]],
['literal', [0, 1.5]],
],
},
},
),
Expand Down Expand Up @@ -2565,71 +2605,6 @@ const layers = {
'text-size': 11,
}
},
{
id: 'railway_signals_blockkennzeichen_text',
type: 'symbol',
minzoom: 16,
source: 'openrailwaymap_signals',
'source-layer': 'signals_railway_signals',
filter: ['all',
['!=', ['get', 'ref_multiline'], null],
['==', ['slice', ['get', 'feature'], 0, 20], 'de/blockkennzeichen-'],
],
paint: {
'text-halo-color': ['case',
['boolean', ['feature-state', 'hover'], false], colors.hover.textHalo,
'white'
],
'text-halo-width': 2,
},
layout: {
'text-field': '{ref_multiline}',
'text-font': ['Noto Sans Bold'],
'text-size': 9,
'text-anchor': 'center',
'text-overlap': 'always',
},
},
{
id: 'railway_signals_text',
type: 'symbol',
minzoom: 13,
source: 'openrailwaymap_signals',
'source-layer': 'signals_railway_signals',
filter: ['all',
['!=', ['get', 'ref'], null],
['!=', ['get', 'feature'], ''],
['!=', ['slice', ['get', 'feature'], 0, 20], 'de/blockkennzeichen-'],
],
paint: {
'text-halo-color': ['case',
['boolean', ['feature-state', 'hover'], false], colors.hover.textHalo,
'white'
],
'text-halo-width': 1.5,
'text-halo-blur': 1,
},
layout: {
'text-field': '{ref}',
'text-font': ['Noto Sans Medium'],
'text-size': 9,
'text-anchor': 'top',
'text-offset': ['case',
['==', ['get', 'main_height'], 'dwarf'], ['literal', [0, 1]],
['any',
['all',
['==', ['get', 'main_form'], 'light'],
['==', ['get', 'speed_limit_form'], 'light'],
],
['all',
['==', ['get', 'distant_form'], 'light'],
['==', ['get', 'speed_limit_form'], 'light'],
],
], ['literal', [0, 2]],
['literal', [0, 1.5]],
],
}
},
searchResults,
],

Expand Down Expand Up @@ -2759,9 +2734,23 @@ const layers = {
minzoom: 15,
source: 'openrailwaymap_electrification',
'source-layer': 'electrification_signals',
paint: {
'text-halo-color': ['case',
['boolean', ['feature-state', 'hover'], false], colors.hover.textHalo,
'white'
],
'text-halo-width': 1.5,
'text-halo-blur': 1,
},
layout: {
'symbol-z-order': 'source',
'icon-overlap': 'always',
'text-field': '{ref}',
'text-font': ['Noto Sans Medium'],
'text-size': 9,
'text-optional': true,
'text-anchor': 'top',
'text-offset': ['literal', [0, 1.5]],
},
},
),
Expand Down
1 change: 0 additions & 1 deletion proxy/js/ui.js
Original file line number Diff line number Diff line change
Expand Up @@ -668,7 +668,6 @@ function popupContent(properties) {
${properties.tunnel === true ? `<span class="badge rounded-pill text-bg-light">tunnel</span>` : ''}
${properties.bridge === true ? `<span class="badge rounded-pill text-bg-light">bridge</span>` : ''}
${properties.railway_local_operated === true ? `<span class="badge rounded-pill text-bg-light">operated locally</span>` : ''}
${properties.maxspeed ? `<span class="badge rounded-pill text-bg-light">maximum speed: ${properties.maxspeed} km/h</span>` : ''}
${properties.track_class ? `<span class="badge rounded-pill text-bg-light">track class: ${properties.track_class}</span>` : ''}
${properties.direction_both ? `<span class="badge rounded-pill text-bg-light">both directions</span>` : ''}
${properties.train_protection ? `<span class="badge rounded-pill text-bg-light">train protection: <span class="text-monospace">${properties.train_protection}</span></span>` : ''}
Expand Down
2 changes: 1 addition & 1 deletion symbols/de/bostrab/f0.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion symbols/de/bostrab/f1.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion symbols/de/bostrab/f2.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 5 additions & 5 deletions symbols/de/bostrab/f3.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 5 additions & 5 deletions symbols/de/bostrab/f5.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 3 additions & 3 deletions symbols/de/hl0.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
14 changes: 7 additions & 7 deletions symbols/de/hl1-distant.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit c3d60cf

Please sign in to comment.