Skip to content

Commit

Permalink
Improve milestone visibility on the map (#143)
Browse files Browse the repository at this point in the history
Followup from #139

Changes:
- Font to a monospaced font (Fira Code)
- Color to slightly purple to differentiate from railway line labels
- Fix for railway positions without decimals cut off


![image](https://github.com/user-attachments/assets/0705f116-adcb-4d55-b100-19755cf7e38b)


![image](https://github.com/user-attachments/assets/dc8232cd-bc83-4442-9cee-adac3172edd4)


![image](https://github.com/user-attachments/assets/15f99b26-e005-4b7a-90fe-27402167fae5)
  • Loading branch information
hiddewie authored Nov 9, 2024
1 parent 30c57b4 commit f48c727
Show file tree
Hide file tree
Showing 5 changed files with 63 additions and 7 deletions.
6 changes: 3 additions & 3 deletions import/sql/functions.sql
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ $$ LANGUAGE plpgsql
LEAKPROOF
PARALLEL SAFE;

CREATE OR REPLACE FUNCTION railway_pos_round(km_pos TEXT) RETURNS NUMERIC AS $$
CREATE OR REPLACE FUNCTION railway_pos_round(km_pos TEXT, decimals int) RETURNS NUMERIC AS $$
DECLARE
pos_part1 TEXT;
km_float NUMERIC(8, 3);
Expand All @@ -59,8 +59,8 @@ BEGIN
RETURN NULL;
END IF;
km_float := pos_part1::NUMERIC(8, 3);
km_float := round(km_float, 1);
RETURN trunc(km_float, 1);
km_float := round(km_float, decimals);
RETURN trunc(km_float, decimals);
END;
$$ LANGUAGE plpgsql
IMMUTABLE
Expand Down
4 changes: 2 additions & 2 deletions import/sql/tile_views.sql
Original file line number Diff line number Diff line change
Expand Up @@ -248,13 +248,13 @@ CREATE OR REPLACE VIEW railway_text_km AS
railway,
pos,
(railway_pos_decimal(pos) = '0') as zero,
left(pos, -2) as pos_int
railway_pos_round(pos, 0)::text as pos_int
FROM
(SELECT
id,
way,
railway,
COALESCE(railway_position, railway_pos_round(railway_position_exact)::text) AS pos
COALESCE(railway_position, railway_pos_round(railway_position_exact, 1)::text) AS pos
FROM railway_positions
) AS r
WHERE pos IS NOT NULL
Expand Down
Binary file added martin/fonts/FiraCode-Bold.ttf
Binary file not shown.
Binary file added martin/fonts/FiraCode-Regular.ttf
Binary file not shown.
60 changes: 58 additions & 2 deletions proxy/js/styles.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -1078,7 +1078,7 @@ const railwayKmText = {
true,
],
paint: {
'text-color': 'black',
'text-color': 'hsl(268, 100%, 40%)',
'text-halo-color': ['case',
['boolean', ['feature-state', 'hover'], false], colors.hover.textHalo,
'white',
Expand All @@ -1092,7 +1092,7 @@ const railwayKmText = {
13,
['get', 'pos'],
],
'text-font': ['Noto Sans Bold'],
'text-font': ['Fira Code Bold'],
'text-size': 11,
},
};
Expand Down Expand Up @@ -3945,6 +3945,7 @@ const legendData = {
type: 'point',
properties: {
zero: true,
pos_int: '47',
pos: '47.0',
},
},
Expand Down Expand Up @@ -4039,6 +4040,17 @@ const legendData = {
},
},
],
"high-railway_text_km": [
{
legend: 'Milestone',
type: 'point',
properties: {
zero: true,
pos_int: '47',
pos: '47.0',
},
},
],
'openrailwaymap_speed-speed_railway_signals': [
// TODO filter per country polygon
...speed_railway_signals.features.map(feature => ({
Expand Down Expand Up @@ -4197,6 +4209,17 @@ const legendData = {
],
},
],
"high-railway_text_km": [
{
legend: 'Milestone',
type: 'point',
properties: {
zero: true,
pos_int: '47',
pos: '47.0',
},
},
],
'openrailwaymap_signals-signals_railway_signals': [
...signals_railway_signals.features.map(feature => ({
legend: `${feature.country ? `(${feature.country}) ` : ''}${feature.description}`,
Expand Down Expand Up @@ -4447,6 +4470,17 @@ const legendData = {
},
},
],
"high-railway_text_km": [
{
legend: 'Milestone',
type: 'point',
properties: {
zero: true,
pos_int: '47',
pos: '47.0',
},
},
],
'openrailwaymap_electrification-electrification_signals': [
...electrification_signals.features.map(feature => ({
legend: `(${feature.country}) ${feature.description}`,
Expand Down Expand Up @@ -4802,6 +4836,17 @@ const legendData = {
},
},
],
"high-railway_text_km": [
{
legend: 'Milestone',
type: 'point',
properties: {
zero: true,
pos_int: '47',
pos: '47.0',
},
},
],
},
loading_gauge: {
'openrailwaymap_low-railway_line_low': [
Expand Down Expand Up @@ -4876,6 +4921,17 @@ const legendData = {
},
},
],
"high-railway_text_km": [
{
legend: 'Milestone',
type: 'point',
properties: {
zero: true,
pos_int: '47',
pos: '47.0',
},
},
],
},
}

Expand Down

0 comments on commit f48c727

Please sign in to comment.