Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Render railway:preserved=yes as preserved railway #4965

Merged
merged 21 commits into from
Jun 13, 2024
Merged
Show file tree
Hide file tree
Changes from 13 commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
66 changes: 44 additions & 22 deletions project.mml
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ Layer:
CASE WHEN tags->'intermittent' IN ('yes')
OR tags->'seasonal' IN ('yes', 'spring', 'summer', 'autumn', 'winter', 'wet_season', 'dry_season')
THEN 'yes' ELSE 'no' END AS int_intermittent,
CASE WHEN tunnel IN ('yes', 'culvert')
CASE WHEN tunnel IN ('yes', 'culvert')
hiddewie marked this conversation as resolved.
Show resolved Hide resolved
OR waterway = 'canal' AND tunnel = 'flooded'
THEN 'yes' ELSE 'no' END AS int_tunnel,
'no' AS bridge
Expand Down Expand Up @@ -453,6 +453,7 @@ Layer:
construction,
service,
link,
preserved,
layernotnull
FROM ( -- subselect that contains both roads and rail
SELECT
Expand All @@ -479,6 +480,7 @@ Layer:
WHEN highway IN ('motorway_link', 'trunk_link', 'primary_link', 'secondary_link', 'tertiary_link') THEN 'yes'
ELSE 'no'
END AS link,
'no' as preserved,
COALESCE(layer,0) AS layernotnull,
z_order
FROM planet_osm_line
Expand All @@ -487,7 +489,7 @@ Layer:
UNION ALL
SELECT
way,
'railway_' || (CASE WHEN railway = 'preserved' AND service IN ('spur', 'siding', 'yard') THEN 'INT-preserved-ssy'::text
'railway_' || (CASE
WHEN (railway = 'rail' AND service IN ('spur', 'siding', 'yard')) THEN 'INT-spur-siding-yard'
WHEN (railway = 'tram' AND service IN ('spur', 'siding', 'yard')) THEN 'tram-service'
ELSE railway END) AS feature,
Expand All @@ -503,6 +505,10 @@ Layer:
construction,
CASE WHEN service IN ('parking_aisle', 'drive-through', 'driveway') THEN 'INT-minor'::text ELSE 'INT-normal'::text END AS service,
'no' AS link,
(CASE
WHEN railway IN ('rail', 'light_rail', 'funicular', 'narrow_gauge', 'miniature', 'subway', 'tram', 'monorail', 'disused') AND tags->'railway:preserved' = 'yes' THEN 'yes'
hiddewie marked this conversation as resolved.
Show resolved Hide resolved
ELSE 'no'
END) AS preserved,
COALESCE(layer,0) AS layernotnull,
z_order
FROM planet_osm_line
Expand All @@ -513,7 +519,7 @@ Layer:
layernotnull,
z_order,
CASE WHEN substring(feature for 8) = 'railway_' THEN 2 ELSE 1 END,
CASE WHEN feature IN ('railway_INT-preserved-ssy', 'railway_INT-spur-siding-yard', 'railway_tram-service') THEN 0 ELSE 1 END,
CASE WHEN feature IN ('railway_INT-spur-siding-yard', 'railway_tram-service') THEN 0 ELSE 1 END,
CASE WHEN access IN ('no', 'private') THEN 0 WHEN access IN ('destination') THEN 1 ELSE 2 END,
CASE WHEN int_surface IN ('unpaved') THEN 0 ELSE 1 END
) AS tunnels
Expand Down Expand Up @@ -690,6 +696,7 @@ Layer:
construction,
service,
link,
preserved,
layernotnull
FROM ( -- subselect that contains both roads and rail/aero
SELECT
Expand All @@ -716,6 +723,7 @@ Layer:
WHEN highway IN ('motorway_link', 'trunk_link', 'primary_link', 'secondary_link', 'tertiary_link') THEN 'yes'
ELSE 'no'
END AS link,
'no' AS preserved,
COALESCE(layer,0) AS layernotnull,
osm_id,
z_order
Expand All @@ -727,10 +735,10 @@ Layer:
UNION ALL
SELECT
way,
('railway_' || (CASE WHEN railway = 'preserved' AND service IN ('spur', 'siding', 'yard') THEN 'INT-preserved-ssy'::text
WHEN (railway = 'rail' AND service IN ('spur', 'siding', 'yard')) THEN 'INT-spur-siding-yard'
WHEN (railway = 'tram' AND service IN ('spur', 'siding', 'yard')) THEN 'tram-service'
ELSE railway END)) AS feature,
'railway_' || (CASE
WHEN (railway = 'rail' AND service IN ('spur', 'siding', 'yard')) THEN 'INT-spur-siding-yard'
WHEN (railway = 'tram' AND service IN ('spur', 'siding', 'yard')) THEN 'tram-service'
ELSE railway END) AS feature,
horse,
foot,
bicycle,
Expand All @@ -748,6 +756,10 @@ Layer:
construction,
CASE WHEN service IN ('parking_aisle', 'drive-through', 'driveway') OR leisure IN ('slipway') THEN 'INT-minor'::text ELSE 'INT-normal'::text END AS service,
'no' AS link,
(CASE
WHEN railway IN ('rail', 'light_rail', 'funicular', 'narrow_gauge', 'miniature', 'subway', 'tram', 'monorail', 'disused') AND tags->'railway:preserved' = 'yes' THEN 'yes'
ELSE 'no'
END) AS preserved,
COALESCE(layer,0) AS layernotnull,
osm_id,
z_order
Expand All @@ -762,7 +774,7 @@ Layer:
layernotnull,
z_order,
CASE WHEN substring(feature for 8) = 'railway_' THEN 2 ELSE 1 END,
CASE WHEN feature IN ('railway_INT-preserved-ssy', 'railway_INT-spur-siding-yard', 'railway_tram-service') THEN 0 ELSE 1 END,
CASE WHEN feature IN ('railway_INT-spur-siding-yard', 'railway_tram-service') THEN 0 ELSE 1 END,
CASE WHEN access IN ('no', 'private') THEN 0 WHEN access IN ('destination') THEN 1 ELSE 2 END,
CASE WHEN int_surface IN ('unpaved') THEN 0 ELSE 1 END,
osm_id
Expand Down Expand Up @@ -860,8 +872,7 @@ Layer:
COALESCE(
('highway_' || (CASE WHEN highway IN ('motorway_link', 'trunk_link', 'primary_link', 'secondary_link', 'tertiary_link')
THEN substr(highway, 0, length(highway)-4) ELSE highway end)),
('railway_' || (CASE WHEN (railway = 'rail' AND service IN ('spur', 'siding', 'yard')) THEN 'INT-spur-siding-yard'
WHEN railway IN ('rail', 'tram', 'light_rail', 'funicular', 'narrow_gauge') THEN railway END))
('railway_' || railway)
) AS feature,
CASE WHEN tunnel = 'yes' OR tunnel = 'building_passage' OR covered = 'yes' THEN 'yes' ELSE 'no' END AS int_tunnel,
CASE WHEN highway IN ('motorway_link', 'trunk_link', 'primary_link', 'secondary_link', 'tertiary_link') THEN 'yes' ELSE 'no' END AS link,
Expand All @@ -872,7 +883,7 @@ Layer:
END AS int_surface
FROM planet_osm_roads
WHERE highway IS NOT NULL
OR (railway IS NOT NULL AND railway != 'preserved'
OR (railway IN ('rail', 'tram', 'light_rail', 'funicular', 'narrow_gauge')
AND (service IS NULL OR service NOT IN ('spur', 'siding', 'yard')))
ORDER BY
z_order
Expand All @@ -893,7 +904,7 @@ Layer:
CASE WHEN tags->'intermittent' IN ('yes')
OR tags->'seasonal' IN ('yes', 'spring', 'summer', 'autumn', 'winter', 'wet_season', 'dry_season')
THEN 'yes' ELSE 'no' END AS int_intermittent,
CASE WHEN tunnel IN ('yes', 'culvert')
CASE WHEN tunnel IN ('yes', 'culvert')
OR waterway = 'canal' AND tunnel = 'flooded'
THEN 'yes' ELSE 'no' END AS int_tunnel,
'yes' AS bridge
Expand Down Expand Up @@ -922,6 +933,7 @@ Layer:
construction,
service,
link,
preserved,
layernotnull
FROM ( -- subselect that contains both roads and rail/aero
SELECT
Expand All @@ -948,6 +960,7 @@ Layer:
WHEN highway IN ('motorway_link', 'trunk_link', 'primary_link', 'secondary_link', 'tertiary_link') THEN 'yes'
ELSE 'no'
END AS link,
'no' AS preserved,
COALESCE(layer,0) AS layernotnull,
z_order
FROM planet_osm_line
Expand All @@ -956,7 +969,7 @@ Layer:
UNION ALL
SELECT
way,
'railway_' || (CASE WHEN railway = 'preserved' AND service IN ('spur', 'siding', 'yard') THEN 'INT-preserved-ssy'::text
'railway_' || (CASE
WHEN (railway = 'rail' AND service IN ('spur', 'siding', 'yard')) THEN 'INT-spur-siding-yard'
WHEN (railway = 'tram' AND service IN ('spur', 'siding', 'yard')) THEN 'tram-service'
ELSE railway END) AS feature,
Expand All @@ -972,6 +985,10 @@ Layer:
construction,
CASE WHEN service IN ('parking_aisle', 'drive-through', 'driveway') THEN 'INT-minor'::text ELSE 'INT-normal'::text END AS service,
'no' AS link,
(CASE
WHEN railway IN ('rail', 'light_rail', 'funicular', 'narrow_gauge', 'miniature', 'subway', 'tram', 'monorail', 'disused') AND tags->'railway:preserved' = 'yes' THEN 'yes'
ELSE 'no'
END) AS preserved,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a reason to use yes/no instead of a boolean?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So far we only have one boolean column in the whole style i think (bridge in the aeroways layer). It would create an additional difficulty for MSS editing if different yes/no columns (or other binary/ternary attributes like surface) are of different type.

COALESCE(layer,0) AS layernotnull,
z_order
FROM planet_osm_line
Expand All @@ -982,7 +999,7 @@ Layer:
layernotnull,
z_order,
CASE WHEN substring(feature for 8) = 'railway_' THEN 2 ELSE 1 END,
CASE WHEN feature IN ('railway_INT-preserved-ssy', 'railway_INT-spur-siding-yard', 'railway_tram-service') THEN 0 ELSE 1 END,
CASE WHEN feature IN ('railway_INT-spur-siding-yard', 'railway_tram-service') THEN 0 ELSE 1 END,
CASE WHEN access IN ('no', 'private') THEN 0 WHEN access IN ('destination') THEN 1 ELSE 2 END,
CASE WHEN int_surface IN ('unpaved') THEN 0 ELSE 1 END
) AS bridges
Expand Down Expand Up @@ -1623,7 +1640,7 @@ Layer:
) AS feature,
CASE WHEN access IN ('private', 'no', 'customers', 'permit', 'delivery') THEN 'restricted' ELSE 'yes' END AS int_access,
CASE
WHEN "natural" IN ('peak', 'volcano', 'saddle')
WHEN "natural" IN ('peak', 'volcano', 'saddle')
OR tags->'mountain_pass' = 'yes' THEN
CASE
WHEN tags->'ele' ~ '^-?\d{1,4}(\.\d+)?$' THEN (tags->'ele')::NUMERIC
Expand Down Expand Up @@ -1975,17 +1992,22 @@ Layer:
table: |-
(SELECT
way,
CASE WHEN railway = 'preserved' AND service IN ('spur', 'siding', 'yard') THEN 'INT-preserved-ssy'::text
WHEN (railway = 'rail' AND service IN ('spur', 'siding', 'yard')) THEN 'INT-spur-siding-yard'
WHEN (railway = 'tram' AND service IN ('spur', 'siding', 'yard')) THEN 'tram-service' ELSE railway END AS railway,
CASE
WHEN (railway = 'rail' AND service IN ('spur', 'siding', 'yard')) THEN 'INT-spur-siding-yard'
WHEN (railway = 'tram' AND service IN ('spur', 'siding', 'yard')) THEN 'tram-service'
ELSE railway
END AS railway,
CASE WHEN (tunnel = 'yes' OR tunnel = 'building_passage' OR covered = 'yes') THEN 'yes' ELSE 'no' END AS tunnel,
tags->'highspeed' as highspeed,
tags->'usage' as usage,
construction,
name
name,
(CASE
WHEN railway IN ('rail', 'light_rail', 'funicular', 'narrow_gauge', 'miniature', 'subway', 'tram', 'monorail', 'disused') AND tags->'railway:preserved' = 'yes' THEN 'yes'
hiddewie marked this conversation as resolved.
Show resolved Hide resolved
ELSE 'no'
END) AS preserved
FROM planet_osm_line l
WHERE railway IN ('rail', 'subway', 'narrow_gauge', 'light_rail', 'preserved', 'funicular',
'monorail', 'miniature', 'tram', 'disused', 'construction')
WHERE railway IN ('rail', 'subway', 'narrow_gauge', 'light_rail', 'funicular', 'monorail', 'miniature', 'tram', 'disused', 'construction')
AND (tunnel IS NULL OR NOT tunnel IN ('yes', 'building_passage'))
AND highway IS NULL -- Prevent duplicate rendering
AND name IS NOT NULL
Expand Down Expand Up @@ -2204,7 +2226,7 @@ Layer:
CASE WHEN tags->'intermittent' IN ('yes')
OR tags->'seasonal' IN ('yes', 'spring', 'summer', 'autumn', 'winter', 'wet_season', 'dry_season')
THEN 'yes' ELSE 'no' END AS int_intermittent,
CASE WHEN tunnel IN ('yes', 'culvert')
CASE WHEN tunnel IN ('yes', 'culvert')
OR waterway = 'canal' AND tunnel = 'flooded'
THEN 'yes' ELSE 'no' END AS int_tunnel
FROM planet_osm_line
Expand Down
Loading
Loading