Skip to content

Commit

Permalink
Merge pull request gravitystorm#4666 from tjur0/feature/roller_coaster
Browse files Browse the repository at this point in the history
feat: Render roller_coaster=track ✨🎢
  • Loading branch information
pnorman authored May 30, 2023
2 parents dae7527 + 1da7305 commit 1b68d57
Show file tree
Hide file tree
Showing 2 changed files with 103 additions and 0 deletions.
35 changes: 35 additions & 0 deletions project.mml
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ Stylesheet:
- style/admin.mss
- style/addressing.mss
- style/golf.mss
- style/tourism.mss
Layer:
- id: landcover-low-zoom
geometry: polygon
Expand Down Expand Up @@ -1004,6 +1005,40 @@ Layer:
) AS guideways
properties:
minzoom: 11
- id: roller-coaster-gap-fill
geometry: linestring
<<: *extents
Datasource:
<<: *osm2pgsql
table: |-
(SELECT
way,
CASE WHEN (tunnel = 'yes' OR tunnel = 'building_passage' OR covered = 'yes' OR tags->'indoor' = 'yes') THEN 'yes' ELSE 'no' END AS tunnel,
CASE WHEN (bridge = 'yes' OR bridge = 'covered' OR bridge = 'viaduct') THEN 'yes' ELSE 'no' END AS bridge
FROM planet_osm_line
WHERE tags @> 'roller_coaster=>track' AND railway IS NULL
) AS roller_coaster
properties:
minzoom: 15
- id: roller-coaster
geometry: linestring
<<: *extents
Datasource:
<<: *osm2pgsql
table: |-
(SELECT
way,
COALESCE(layer,0) AS layernotnull,
CASE WHEN (tunnel = 'yes' OR tunnel = 'building_passage' OR covered = 'yes' OR tags->'indoor' = 'yes') THEN 'yes' ELSE 'no' END AS tunnel,
CASE WHEN (bridge = 'yes' OR bridge = 'covered' OR bridge = 'viaduct') THEN 'yes' ELSE 'no' END AS bridge
FROM planet_osm_line
WHERE tags @> 'roller_coaster=>track' AND railway IS NULL
ORDER BY
layernotnull -- put bottom layered track first
) AS roller_coaster
properties:
group-by: layernotnull
minzoom: 15
- id: entrances
geometry: point
<<: *extents
Expand Down
68 changes: 68 additions & 0 deletions style/tourism.mss
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
/* For tourism features like roller coasters */

@track-casing: #707070;
@track-fill: #ddd;

/* The purpose of “roller-coaster-gap-fill” layer is to fill in the gaps between sections of roller coaster track. */
#roller-coaster-gap-fill[zoom >= 15] {
::bridges { line-cap: round; }
::casing { line-cap: round; }
::fill { line-cap: round; }
}

#roller-coaster, #roller-coaster-gap-fill {
[zoom >= 15] {
::bridges[bridge = 'yes'][zoom >= 16] {
line-width: 2.5 + @bridge-casing-width-z16;
line-color: #000;
line-join: round;

[tunnel = 'yes'] { line-color: lighten(#000, 20%); }

[zoom >= 17] { line-width: 4 + @bridge-casing-width-z17; }
[zoom >= 18] { line-width: 6 + 1.5 * @bridge-casing-width-z18; }
[zoom >= 19] { line-width: 8 + 2 * @bridge-casing-width-z19; }
[zoom >= 20] { line-width: 12 + 2 * @bridge-casing-width-z20; }
}

::casing {
line-width: 1;
line-color: mix(@track-casing, @track-fill, 50%);
line-join: round;

[tunnel = 'yes'][zoom >= 16] {
line-color: lighten(@track-casing, 20%);
}
[zoom >= 16] {
line-color: @track-casing;
line-width: 2.5;
}
[zoom >= 17] { line-width: 4; }
[zoom >= 18] { line-width: 6; }
[zoom >= 19] { line-width: 8; }
[zoom >= 20] { line-width: 12; }
}

::fill[zoom >= 16] {
line-width: 1.25;
line-color: @track-fill;
line-join: round;

[tunnel = 'yes'] {
line-color: lighten(@track-fill, 5%);
}
[zoom >= 17] { line-width: 2; }
[zoom >= 18] { line-width: 3; }
[zoom >= 19] { line-width: 4; }
[zoom >= 20] { line-width: 6; }
}
}
}

#roller-coaster::fill[zoom >= 16] {
line-dasharray: 2.5,0.5;
[zoom >= 17] { line-dasharray: 4,0.8; }
[zoom >= 18] { line-dasharray: 6,1.2; }
[zoom >= 19] { line-dasharray: 8,1.6; }
[zoom >= 20] { line-dasharray: 12,2.4; }
}

0 comments on commit 1b68d57

Please sign in to comment.