Skip to content

Instantly share code, notes, and snippets.

@az09
Last active April 11, 2018 17:36
Show Gist options
  • Save az09/b1ffd238b9149ffba19418849fe984b3 to your computer and use it in GitHub Desktop.
Save az09/b1ffd238b9149ffba19418849fe984b3 to your computer and use it in GitHub Desktop.
Предлагаемое изменение в слое bridge (https://github.com/mapbox/osm-bright/blob/master/osm-bright/osm-bright.osm2pgsql.mml#L392)
SELECT way, COALESCE(p_o_l.highway, p_o_l.railway) AS "type", 1 AS bridge, access, render.render, layer, 0 as tunnel,
COALESCE(hw.stylegroup, constr.stylegroup, rw.stylegroup, 'other') AS stylegroup
FROM planet_osm_line as p_o_l
INNER JOIN (values
('1_outline')
, ('2_line')
, ('3_inline')
) AS render (render) ON 1=1
LEFT JOIN (values
('motorway', 'motorway')
, ('trunk', 'motorway')
, ('primary', 'mainroad')
, ('secondary', 'mainroad')
, ('motorway_link', 'minorroad')
, ('trunk_link', 'minorroad')
, ('primary_link', 'minorroad')
, ('secondary_link', 'minorroad')
, ('tertiary', 'minorroad')
, ('tertiary_link', 'minorroad')
, ('residential', 'minorroad')
, ('unclassified', 'minorroad')
, ('road', 'minorroad')
, ('living_street', 'minorroad')
, ('service', 'service')
, ('track', 'service')
, ('path', 'noauto')
, ('cycleway', 'noauto')
, ('footway', 'noauto')
, ('pedestrian', 'noauto')
, ('steps', 'noauto')
, ('bridleway', 'noauto')
) as hw (k, stylegroup) ON hw.k = p_o_l.highway
LEFT JOIN (values
('tertiary', 'construction')
, ('motorway', 'construction')
, ('trunk', 'construction')
, ('unclassified', 'construction')
, ('primary', 'construction')
, ('motorway_link', 'construction')
, ('secondary', 'construction')
, ('residential', 'construction')
, ('trunk_link', 'construction')
) as constr (k, stylegroup) ON constr.k = p_o_l.construction
LEFT JOIN (values
('light_rail', 'railway')
, ('subway', 'railway')
, ('narrow_gauge', 'railway')
, ('rail', 'railway')
, ('tram', 'railway')
) as rw (k, stylegroup) ON rw.k = p_o_l.railway
WHERE p_o_l.bridge NOT IN ('', '0', 'no')
AND "way" && ST_SetSRID('BOX3D(14861804.28355137 3903791.908582617,15037915.19672051 4079902.821751758)'::box3d, 3857)
ORDER BY layer ASC, render ASC;
SELECT way, COALESCE(construction, highway, railway) AS "type", 1 AS bridge, access, render, layer, 0 as tunnel,
CASE
WHEN construction IN ('tertiary','motorway','trunk','unclassified','primary','motorway_link','secondary','residential','trunk_link') THEN 'construction'
WHEN highway IN ('motorway', 'trunk') THEN 'motorway'
WHEN highway IN ('primary', 'secondary') THEN 'mainroad'
WHEN highway IN ('motorway_link', 'trunk_link', 'primary_link', 'secondary_link', 'tertiary', 'tertiary_link', 'residential', 'unclassified', 'road', 'living_street') THEN 'minorroad'
WHEN highway IN ('service', 'track') THEN 'service'
WHEN highway IN ('path', 'cycleway', 'footway', 'pedestrian', 'steps', 'bridleway') THEN 'noauto'
WHEN railway IN ('light_rail', 'subway', 'narrow_gauge', 'rail', 'tram') THEN 'railway'
ELSE 'other'
END AS stylegroup
FROM (
SELECT *, '1_outline' AS render FROM planet_osm_line WHERE bridge NOT IN ('', '0', 'no')
UNION ALL
SELECT *, '2_line' AS render FROM planet_osm_line WHERE bridge NOT IN ('', '0', 'no')
UNION ALL
SELECT *, '3_inline' AS render FROM planet_osm_line WHERE bridge NOT IN ('', '0', 'no')
) AS bridges
WHERE "way" && ST_SetSRID('BOX3D(14861804.28355137 3903791.908582617,15037915.19672051 4079902.821751758)'::box3d, 3857)
ORDER BY layer ASC, render ASC;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment