Skip to content

Commit

Permalink
roads names use cyclosm_ways view
Browse files Browse the repository at this point in the history
  • Loading branch information
quasart committed Apr 24, 2021
1 parent a2cd2f1 commit 1220f7a
Show file tree
Hide file tree
Showing 2 changed files with 89 additions and 31 deletions.
106 changes: 77 additions & 29 deletions project.mml
Original file line number Diff line number Diff line change
Expand Up @@ -460,7 +460,28 @@ Layer:
<<: *osm2pgsql
table: |-
(
SELECT *
SELECT
way,
type,
access,
maxspeed_kmh,
bicycle,
motor_vehicle,
cyclestreet,
oneway,
cycleway_left_render,
cycleway_right_render,
cycleway_left_oneway,
cycleway_right_oneway,
can_bicycle,
segregated,
oneway_bicycle,
has_ramp,
surface_type,
service,
mtb_scale,
mtb_scale_imba,
tunnel
FROM cyclosm_ways
WHERE tunnel NOT IN ('no')
) AS data
Expand Down Expand Up @@ -502,7 +523,27 @@ Layer:
<<: *osm2pgsql
table: |-
(
SELECT *
SELECT
way,
type,
access,
maxspeed_kmh,
bicycle,
motor_vehicle,
cyclestreet,
oneway,
cycleway_left_render,
cycleway_right_render,
cycleway_left_oneway,
cycleway_right_oneway,
can_bicycle,
segregated,
oneway_bicycle,
has_ramp,
surface_type,
service,
mtb_scale,
mtb_scale_imba
FROM cyclosm_ways
WHERE (tunnel IS NULL OR tunnel = 'no')
AND (bridge IS NULL OR bridge = 'no')
Expand Down Expand Up @@ -619,7 +660,28 @@ Layer:
<<: *osm2pgsql
table: |-
(
SELECT *
SELECT
way,
type,
access,
maxspeed_kmh,
bicycle,
motor_vehicle,
cyclestreet,
oneway,
cycleway_left_render,
cycleway_right_render,
cycleway_left_oneway,
cycleway_right_oneway,
can_bicycle,
segregated,
oneway_bicycle,
has_ramp,
surface_type,
service,
mtb_scale,
mtb_scale_imba,
bridge
FROM cyclosm_ways
WHERE bridge NOT IN ('no')
) AS data
Expand Down Expand Up @@ -2211,28 +2273,15 @@ Layer:
SELECT
way,
CASE
WHEN substr(highway, length(highway)-4, 5) = '_link' THEN substr(highway, 0, length(highway)-4)
ELSE highway
WHEN substr(type, length(type)-4, 5) = '_link' THEN substr(type, 0, length(type)-4)
ELSE type
END AS highway,
CASE WHEN (tunnel = 'yes' OR tunnel = 'building_passage' OR covered = 'yes') THEN 'yes' ELSE 'no' END AS tunnel,
tunnel,
name,
CASE
WHEN oneway IN ('yes', '-1') THEN oneway
WHEN junction IN ('roundabout') AND (oneway IS NULL OR NOT oneway IN ('no', 'reversible')) THEN 'yes'
ELSE 'no'
END AS oneway,
CASE
WHEN tags->'oneway:bicycle' IS NOT NULL THEN tags->'oneway:bicycle'
WHEN highway='cycleway' AND oneway IS NOT NULL THEN oneway
WHEN tags->'cycleway' IN ('opposite', 'opposite_lane', 'opposite_track', 'opposite_share_busway')
OR tags->'cycleway:both' IN ('opposite', 'opposite_lane', 'opposite_track', 'opposite_share_busway')
OR tags->'cycleway:left' IN ('opposite', 'opposite_lane', 'opposite_track', 'opposite_share_busway')
OR tags->'cycleway:right' IN ('opposite', 'opposite_lane', 'opposite_track', 'opposite_share_busway')
THEN 'no'
ELSE NULL
END AS oneway_bicycle,
horse, bicycle
FROM planet_osm_line l
oneway,
oneway_bicycle,
bicycle
FROM cyclosm_ways l
JOIN (VALUES -- this join is also putting a condition on what is selected. features not matching it do not make it into the results.
('motorway', 380),
('trunk', 370),
Expand All @@ -2250,15 +2299,14 @@ Layer:
('secondary_link', 210),
('tertiary_link', 200),
('service', 150)
) AS ordertable (highway, prio)
USING (highway)
WHERE highway IN ('motorway', 'motorway_link', 'trunk', 'trunk_link', 'primary', 'primary_link', 'secondary', 'secondary_link', 'tertiary',
) AS ordertable (type, prio)
USING (type)
WHERE type IN ('motorway', 'motorway_link', 'trunk', 'trunk_link', 'primary', 'primary_link', 'secondary', 'secondary_link', 'tertiary',
'tertiary_link', 'residential', 'unclassified', 'road', 'service', 'pedestrian', 'living_street')
AND (
AND ( -- There is a label to render
name IS NOT NULL
OR oneway IN ('yes', '-1')
OR tags->'oneway:bicycle' IN ('yes', '-1')
OR junction IN ('roundabout')
OR oneway_bicycle IN ('yes', '-1')
)
ORDER BY
z_order DESC, -- put important roads first
Expand Down
14 changes: 12 additions & 2 deletions project.sql
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ CREATE VIEW cyclosm_ways AS
WHEN tags->'maxspeed'='walk' THEN 5
ELSE NULL
END AS maxspeed_kmh,
bicycle,
CASE
WHEN COALESCE(motorcar, tags->'motor_vehicle', tags->'vehicle', access, 'yes') NOT IN ('no', 'private') THEN 'yes'
-- goods and hgv don't need COALESCE chains, because the next step would be motorcar, which is checked above
Expand All @@ -47,6 +48,7 @@ CREATE VIEW cyclosm_ways AS
END AS cyclestreet,
CASE
WHEN oneway IN ('yes', '-1') THEN oneway
WHEN junction IN ('roundabout') AND (oneway IS NULL OR NOT oneway IN ('no', 'reversible')) THEN 'yes'
ELSE 'no'
END AS oneway,
CASE
Expand Down Expand Up @@ -109,8 +111,14 @@ CREATE VIEW cyclosm_ways AS
ELSE 'no'
END AS segregated,
CASE
WHEN tags->'oneway:bicycle' IN ('yes', '-1') THEN tags->'oneway:bicycle'
ELSE 'no'
WHEN tags->'oneway:bicycle' IS NOT NULL THEN tags->'oneway:bicycle'
WHEN highway='cycleway' AND oneway IS NOT NULL THEN oneway
WHEN tags->'cycleway' IN ('opposite', 'opposite_lane', 'opposite_track', 'opposite_share_busway')
OR tags->'cycleway:both' IN ('opposite', 'opposite_lane', 'opposite_track', 'opposite_share_busway')
OR tags->'cycleway:left' IN ('opposite', 'opposite_lane', 'opposite_track', 'opposite_share_busway')
OR tags->'cycleway:right' IN ('opposite', 'opposite_lane', 'opposite_track', 'opposite_share_busway')
THEN 'no'
ELSE NULL
END AS oneway_bicycle,
COALESCE(
tags->'ramp:bicycle',
Expand Down Expand Up @@ -154,6 +162,8 @@ CREATE VIEW cyclosm_ways AS
WHEN tags->'mtb:scale:imba'~E'^\\d+$' THEN (tags->'mtb:scale:imba')::integer
ELSE NULL
END AS mtb_scale_imba,
name,
osm_id,
CASE
WHEN highway='cycleway' OR (highway IN ('path', 'footway', 'pedestrian', 'bridleway') AND bicycle IN ('yes', 'designated')) THEN CASE WHEN layer~E'^\\d+$' THEN 100*layer::integer+199 ELSE 199 END
WHEN highway IN ('path', 'footway', 'pedestrian', 'bridleway') THEN CASE WHEN layer~E'^\\d+$' THEN 100*layer::integer+198 ELSE 198 END
Expand Down

0 comments on commit 1220f7a

Please sign in to comment.