Skip to content

Commit

Permalink
rewrite signals boxes to single layer
Browse files Browse the repository at this point in the history
  • Loading branch information
hiddewie committed Feb 29, 2024
1 parent 79d738f commit 0cca8dc
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 60 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,8 @@ jobs:
- name: Print tiles summary
run: |
docker run --rm -v $PWD:/code --entrypoint mbtiles ghcr.io/maplibre/martin summary /code/tiles/tiles.mbtiles
docker run --rm -v $PWD:/code --entrypoint mbtiles ghcr.io/maplibre/martin summary /code/tiles/standard.mbtiles
docker run --rm -v $PWD:/code --entrypoint mbtiles ghcr.io/maplibre/martin summary /code/tiles/signals.mbtiles
- name: Deploy
run: |
Expand Down
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:
# DE: --bbox=5.864417,47.26543,15.05078,55.14777
# FI: --bbox=19.02427,59.28783,31.6159,70.09959
# NL: --bbox=2.99,50.74753,7.230455,54.01786
'martin-cp --config /config/configuration.yml --mbtiles-type flat --min-zoom 0 --max-zoom 14 "--bbox=2.99,50.74753,7.230455,54.01786" --source railway_line_low,railway_line_med,railway_turntables,railway_line_fill,railway_text_stations_med,railway_text_stations_high,railway_symbols,railway_text_med,railway_text_high,railway_text_km_med,railway_text_km_high,railway_switch_ref,railway_text_detail --output-file /tiles/standard.mbtiles --on-duplicate override && martin-cp --config /config/configuration.yml --mbtiles-type flat --min-zoom 0 --max-zoom 14 "--bbox=2.99,50.74753,7.230455,54.01786" --source railway_line,railway_signals,signal_boxes_point,signal_boxes_polygon,signal_boxes_text --output-file /tiles/signals.mbtiles --on-duplicate override'
'martin-cp --config /config/configuration.yml --mbtiles-type flat --min-zoom 0 --max-zoom 14 "--bbox=2.99,50.74753,7.230455,54.01786" --source railway_line_low,railway_line_med,railway_turntables,railway_line_fill,railway_text_stations_med,railway_text_stations_high,railway_symbols,railway_text_med,railway_text_high,railway_text_km_med,railway_text_km_high,railway_switch_ref,railway_text_detail --output-file /tiles/standard.mbtiles --on-duplicate override && martin-cp --config /config/configuration.yml --mbtiles-type flat --min-zoom 0 --max-zoom 14 "--bbox=2.99,50.74753,7.230455,54.01786" --source railway_line,railway_signals,signal_boxes --output-file /tiles/signals.mbtiles --on-duplicate override'
]
volumes:
- ./martin:/config
Expand Down
20 changes: 3 additions & 17 deletions martin/configuration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -223,26 +223,12 @@ postgres:
feature: string
deactivated: boolean

signal_boxes_point:
signal_boxes:
schema: public
table: signal_boxes_point
table: signal_boxes
srid: 3857
geometry_column: way
geometry_type: POINT

signal_boxes_polygon:
schema: public
table: signal_boxes_polygon
srid: 3857
geometry_column: way
geometry_type: POLYGON

signal_boxes_text:
schema: public
table: signal_boxes_text
srid: 3857
geometry_column: way
geometry_type: POINT
geometry_type: GEOMETRY
properties:
ref: string
name: string
Expand Down
19 changes: 14 additions & 5 deletions proxy/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -1689,7 +1689,8 @@
type: 'circle',
minzoom: 11,
source: 'openrailwaymap',
'source-layer': 'signal_boxes_point',
'source-layer': 'signal_boxes',
filter: ['==', ["geometry-type"], 'Point'],
paint: {
'circle-color': '#008206',
'circle-radius': ['step', ['zoom'],
Expand All @@ -1706,7 +1707,11 @@
type: 'fill',
minzoom: 13,
source: 'openrailwaymap',
'source-layer': 'signal_boxes_polygon',
'source-layer': 'signal_boxes',
filter: ['any',
['==', ["geometry-type"], 'Polygon'],
['==', ["geometry-type"], 'MultiPolygon'],
],
paint: {
'fill-color': '#008206',
'fill-outline-color': 'white',
Expand All @@ -1717,7 +1722,11 @@
type: 'line',
minzoom: 13,
source: 'openrailwaymap',
'source-layer': 'signal_boxes_polygon',
'source-layer': 'signal_boxes',
filter: ['any',
['==', ["geometry-type"], 'Polygon'],
['==', ["geometry-type"], 'MultiPolygon'],
],
paint: {
'line-color': 'white',
'line-width': 1,
Expand Down Expand Up @@ -1790,7 +1799,7 @@
minzoom: 13,
maxzoom: 16,
source: 'openrailwaymap',
'source-layer': 'signal_boxes_text',
'source-layer': 'signal_boxes',
paint: {
'text-color': '#404040',
'text-halo-color': '#bfffb3',
Expand All @@ -1807,7 +1816,7 @@
type: 'symbol',
minzoom: 16,
source: 'openrailwaymap',
'source-layer': 'signal_boxes_text',
'source-layer': 'signal_boxes',
paint: {
'text-color': '#404040',
'text-halo-color': '#bfffb3',
Expand Down
2 changes: 1 addition & 1 deletion proxy/proxy.conf.template
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ server {

location / {
# rewrite ^/standard$ /railway_line_low,railway_line_med,railway_turntables,railway_line_fill,railway_text_stations_med,railway_text_stations_high,railway_symbols,railway_text_med,railway_text_high,railway_text_km_med,railway_text_km_high,railway_switch_ref,railway_text_detail last;
# rewrite ^/signals$ /railway_line,railway_signals,signal_boxes_point,signal_boxes_polygon,signal_boxes_text last;
# rewrite ^/signals$ /railway_line,railway_signals,signal_boxes last;

proxy_pass http://${PROXY_UPSTREAM};
proxy_http_version 1.1;
Expand Down
52 changes: 17 additions & 35 deletions sql/tile_views.sql
Original file line number Diff line number Diff line change
Expand Up @@ -452,23 +452,23 @@ CREATE OR REPLACE VIEW railway_line AS
COALESCE(layer, 0),
rank NULLS LAST;

CREATE OR REPLACE VIEW signal_boxes_point AS
SELECT
way
FROM (
SELECT
way
FROM openrailwaymap_osm_point
WHERE railway = 'signal_box'
) AS boxes;

CREATE OR REPLACE VIEW signal_boxes_polygon AS
SELECT
way
FROM openrailwaymap_osm_polygon
WHERE
railway = 'signal_box'
;
CREATE OR REPLACE VIEW signal_boxes AS
(SELECT
way,
tags->'railway:ref' AS ref,
name
FROM openrailwaymap_osm_polygon
WHERE railway = 'signal_box'
ORDER BY way_area DESC NULLS LAST)

UNION ALL

(SELECT
way,
tags->'railway:ref' AS ref,
name
FROM openrailwaymap_osm_point
WHERE railway = 'signal_box');

CREATE OR REPLACE VIEW railway_signals AS
WITH pre_signals AS (
Expand Down Expand Up @@ -1064,21 +1064,3 @@ CREATE OR REPLACE VIEW railway_signals AS
WHEN railway_has_key(tags, 'railway:signal:departure') THEN 400
ELSE 0
END) ASC NULLS FIRST;

CREATE OR REPLACE VIEW signal_boxes_text AS
(SELECT
ST_PointOnSurface(way) AS way,
tags->'railway:ref' AS ref,
name
FROM openrailwaymap_osm_polygon
WHERE railway = 'signal_box'
ORDER BY way_area DESC NULLS LAST)

UNION ALL

(SELECT
way,
tags->'railway:ref' AS ref,
name
FROM openrailwaymap_osm_point
WHERE railway = 'signal_box');

0 comments on commit 0cca8dc

Please sign in to comment.