Skip to content

Commit

Permalink
merge text layers with line layers
Browse files Browse the repository at this point in the history
  • Loading branch information
hiddewie committed Mar 3, 2024
1 parent 0cf05d4 commit 14dcd2e
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 84 deletions.
2 changes: 1 addition & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ services:
martin-cp --config /config/configuration.yml --mbtiles-type flat --min-zoom "$$MIN_ZOOM" --max-zoom "$$MAX_ZOOM" "--bbox=$$BBOX" --source speed_railway_line_casing,speed_railway_line_med,speed_railway_line_fill,speed_railway_signals,speed_railway_line_text --output-file /tiles/speed.mbtiles --on-duplicate override &&
martin-cp --config /config/configuration.yml --mbtiles-type flat --min-zoom "$$MIN_ZOOM" --max-zoom "$$MAX_ZOOM" "--bbox=$$BBOX" --source signals_railway_line,signals_railway_signals,signals_signal_boxes --output-file /tiles/signals.mbtiles --on-duplicate override &&
martin-cp --config /config/configuration.yml --mbtiles-type flat --min-zoom "$$MIN_ZOOM" --max-zoom "$$MAX_ZOOM" "--bbox=$$BBOX" --source electrification_railway_line_med,electrification_railway_line,electrification_future,electrification_signals,electrification_railway_text_med,electrification_railway_text_high --output-file /tiles/electrification.mbtiles --on-duplicate override &&
martin-cp --config /config/configuration.yml --mbtiles-type flat --min-zoom "$$MIN_ZOOM" --max-zoom "$$MAX_ZOOM" "--bbox=$$BBOX" --source gauge_railway_line_low,gauge_railway_line_med,gauge_railway_line,gauge_railway_text_med,gauge_railway_text_high --output-file /tiles/gauge.mbtiles --on-duplicate override'
martin-cp --config /config/configuration.yml --mbtiles-type flat --min-zoom "$$MIN_ZOOM" --max-zoom "$$MAX_ZOOM" "--bbox=$$BBOX" --source gauge_railway_line_low,gauge_railway_line_med,gauge_railway_line --output-file /tiles/gauge.mbtiles --on-duplicate override'
]
volumes:
- ./martin:/config
Expand Down
26 changes: 1 addition & 25 deletions martin/configuration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -338,6 +338,7 @@ postgres:
service: string
gauge0: string
gaugeint0: number
label: string

gauge_railway_line:
schema: public
Expand All @@ -356,31 +357,6 @@ postgres:
gaugeint1: number
gauge2: string
gaugeint2: number

gauge_railway_text_med:
schema: public
table: gauge_railway_text_med
srid: 3857
geometry_column: way
geometry_type: LINESTRING
properties:
railway: string
feature: string
usage: string
service: string
label: string

gauge_railway_text_high:
schema: public
table: gauge_railway_text_high
srid: 3857
geometry_column: way
geometry_type: LINESTRING
properties:
railway: string
feature: string
usage: string
service: string
label: string

fonts:
Expand Down
4 changes: 2 additions & 2 deletions proxy/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -2685,7 +2685,7 @@
minzoom: 8,
maxzoom: 9,
source: 'openrailwaymap',
'source-layer': 'gauge_railway_text_med',
'source-layer': 'gauge_railway_line_med',
filter: ['all',
['==', ['get', 'railway'], 'rail'],
['any',
Expand Down Expand Up @@ -2714,7 +2714,7 @@
type: 'symbol',
minzoom: 9,
source: 'openrailwaymap',
'source-layer': 'gauge_railway_text_high',
'source-layer': 'gauge_railway_line',
filter: ['step', ['zoom'],
['all',
['==', ['get', 'railway'], 'rail'],
Expand Down
2 changes: 1 addition & 1 deletion proxy/proxy.conf.template
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ server {
rewrite ^/speed$ /speed_railway_line_casing,speed_railway_line_med,speed_railway_line_fill,speed_railway_signals,speed_railway_line_text last;
rewrite ^/signals$ /signals_railway_line,signals_railway_signals,signals_signal_boxes last;
rewrite ^/electrification$ /electrification_railway_line_med,electrification_railway_line,electrification_future,electrification_signals,electrification_railway_text_med,electrification_railway_text_high last;
rewrite ^/gauge$ /gauge_railway_line_low,gauge_railway_line_med,gauge_railway_line,gauge_railway_text_med,gauge_railway_text_high last;
rewrite ^/gauge$ /gauge_railway_line_low,gauge_railway_line_med,gauge_railway_line last;
}

proxy_pass http://${PROXY_UPSTREAM};
Expand Down
61 changes: 6 additions & 55 deletions sql/tile_views.sql
Original file line number Diff line number Diff line change
Expand Up @@ -1550,11 +1550,13 @@ CREATE OR REPLACE VIEW gauge_railway_line_med AS
ELSE 50
END AS rank,
railway_to_int(gauge) AS gaugeint0,
gauge as gauge0
gauge as gauge0,
label
FROM
(SELECT
way, railway, usage,
railway_desired_value_from_list(1, tags->'gauge') AS gauge,
railway_gauge_label(COALESCE(tags->'gauge', tags->'construction:gauge')) AS label,
layer
FROM openrailwaymap_osm_line
WHERE railway = 'rail' AND usage IN ('main', 'branch') AND service IS NULL
Expand Down Expand Up @@ -1596,7 +1598,8 @@ CREATE OR REPLACE VIEW gauge_railway_line AS
railway_to_int(gauge1) AS gaugeint1,
gauge1,
railway_to_int(gauge2) AS gaugeint2,
gauge2
gauge2,
label
FROM
(SELECT
way, railway, usage, service,
Expand All @@ -1610,63 +1613,11 @@ CREATE OR REPLACE VIEW gauge_railway_line AS
railway_desired_value_from_list(1, COALESCE(tags->'gauge', tags->'construction:gauge')) AS gauge0,
railway_desired_value_from_list(2, COALESCE(tags->'gauge', tags->'construction:gauge')) AS gauge1,
railway_desired_value_from_list(3, COALESCE(tags->'gauge', tags->'construction:gauge')) AS gauge2,
railway_gauge_label(tags->'gauge') AS label,
layer
FROM openrailwaymap_osm_line
WHERE railway IN ('rail', 'tram', 'light_rail', 'subway', 'narrow_gauge', 'construction', 'preserved', 'monorail', 'miniature')
) AS r
ORDER BY
layer,
rank NULLS LAST;

CREATE OR REPLACE VIEW gauge_railway_text_med AS
SELECT
way, railway, usage, service,
CASE
WHEN railway = 'construction' THEN tags->'construction:railway'
ELSE railway
END as feature,
construction,
tags->'construction:railway' AS construction_railway,
CASE WHEN railway = 'rail' AND usage = 'main' THEN 1100
WHEN railway = 'rail' AND usage = 'branch' THEN 1000
ELSE 50
END AS rank,
layer,
railway_gauge_label(tags->'gauge') AS label,
tags->'gauge' AS gauge,
NULL AS construction_gauge
FROM openrailwaymap_osm_line
WHERE
railway = 'rail' AND usage IN ('main', 'branch') AND service IS NULL
ORDER by layer, rank NULLS LAST;

CREATE OR REPLACE VIEW gauge_railway_text_high AS
SELECT
way, railway, usage, service,
CASE
WHEN railway = 'construction' THEN tags->'construction:railway'
ELSE railway
END as feature,
construction,
tags->'construction:railway' AS construction_railway,
CASE WHEN railway = 'rail' AND usage IN ('usage', 'military', 'test') AND service IS NULL THEN 400
WHEN railway = 'rail' AND usage IS NULL AND service IS NULL THEN 400
WHEN railway = 'rail' AND usage IS NULL AND service = 'siding' THEN 870
WHEN railway = 'rail' AND usage IS NULL AND service = 'yard' THEN 860
WHEN railway = 'rail' AND usage IS NULL AND service = 'spur' THEN 880
WHEN railway = 'rail' AND usage IS NULL AND service = 'crossover' THEN 300
WHEN railway = 'rail' AND usage = 'main' AND service IS NULL THEN 1100
WHEN railway = 'rail' AND usage = 'branch' AND service IS NULL THEN 1000
WHEN railway = 'rail' AND usage = 'industrial' AND service IS NULL THEN 850
WHEN railway = 'rail' AND usage = 'industrial' AND service IN ('siding', 'spur', 'yard', 'crossover') THEN 850
WHEN railway IN ('preserved', 'construction') THEN 400
ELSE 50
END AS rank,
layer,
railway_gauge_label(COALESCE(tags->'gauge', tags->'construction:gauge')) AS label,
tags->'gauge' AS gauge,
tags->'construction:gauge' AS construction_gauge
FROM openrailwaymap_osm_line
WHERE
railway IN ('rail', 'tram', 'light_rail', 'subway', 'narrow_gauge', 'construction', 'preserved', 'monorail', 'miniature')
ORDER by layer, rank NULLS LAST;

0 comments on commit 14dcd2e

Please sign in to comment.