From 2f2addb8a1016aa2951983deb5ec4cb215e9ae3b Mon Sep 17 00:00:00 2001 From: Hidde Wieringa Date: Sat, 2 Nov 2024 22:11:29 +0100 Subject: [PATCH] Render railway positions for low zooms without decimal This solves some of the clutter on the map, now that railway positions are shown in every layer. --- import/sql/tile_views.sql | 3 ++- martin/configuration.yml | 1 + proxy/js/styles.mjs | 6 +++++- 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/import/sql/tile_views.sql b/import/sql/tile_views.sql index 08c16494..c7c6a7ed 100644 --- a/import/sql/tile_views.sql +++ b/import/sql/tile_views.sql @@ -247,7 +247,8 @@ CREATE OR REPLACE VIEW railway_text_km AS way, railway, pos, - (railway_pos_decimal(pos) = '0') as zero + (railway_pos_decimal(pos) = '0') as zero, + left(pos, -2) as pos_int FROM (SELECT id, diff --git a/martin/configuration.yml b/martin/configuration.yml index ad6ba899..49ab6682 100644 --- a/martin/configuration.yml +++ b/martin/configuration.yml @@ -212,6 +212,7 @@ postgres: id: integer railway: string pos: string + pos_int: string zero: boolean standard_railway_switch_ref: diff --git a/proxy/js/styles.mjs b/proxy/js/styles.mjs index 4e732f7c..d8d155e3 100644 --- a/proxy/js/styles.mjs +++ b/proxy/js/styles.mjs @@ -1087,7 +1087,11 @@ const railwayKmText = { }, layout: { 'symbol-z-order': 'source', - 'text-field': '{pos}', + 'text-field': ['step', ['zoom'], + ['get', 'pos_int'], + 13, + ['get', 'pos'], + ], 'text-font': ['Noto Sans Bold'], 'text-size': 11, },