Skip to content

Commit

Permalink
Render natural=shrubbery
Browse files Browse the repository at this point in the history
Render `natural=shrubbery`. The three `shrubbery:density` values
(`sparse`, `medium`, and `dense`) are reflected in the pattern.

Fixes #4473
  • Loading branch information
jdhoek committed Apr 7, 2022
1 parent 1178dfb commit f372f04
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 7 deletions.
21 changes: 14 additions & 7 deletions project.mml
Original file line number Diff line number Diff line change
Expand Up @@ -64,13 +64,13 @@ Layer:
way,
('landuse_' || (CASE WHEN landuse IN ('forest', 'farmland', 'residential', 'commercial', 'retail', 'industrial',
'meadow', 'grass', 'village_green', 'vineyard', 'orchard') THEN landuse END)) AS landuse,
('natural_' || (CASE WHEN "natural" IN ('wood', 'sand', 'scree', 'shingle', 'bare_rock', 'heath', 'grassland', 'scrub') THEN "natural" END)) AS "natural",
('natural_' || (CASE WHEN "natural" IN ('wood', 'sand', 'scree', 'shingle', 'bare_rock', 'heath', 'grassland', 'scrub', 'shrubbery') THEN "natural" END)) AS "natural",
('wetland_' || (CASE WHEN "natural" IN ('wetland', 'mud') THEN (CASE WHEN "natural" IN ('mud') THEN "natural" ELSE tags->'wetland' END) END)) AS wetland,
way_area/NULLIF(POW(!scale_denominator!*0.001*0.28,2),0) AS way_pixels,
way_area
FROM planet_osm_polygon
WHERE (landuse IN ('forest', 'farmland', 'residential', 'commercial', 'retail', 'industrial', 'meadow', 'grass', 'village_green', 'vineyard', 'orchard')
OR "natural" IN ('wood', 'wetland', 'mud', 'sand', 'scree', 'shingle', 'bare_rock', 'heath', 'grassland', 'scrub'))
OR "natural" IN ('wood', 'wetland', 'mud', 'sand', 'scree', 'shingle', 'bare_rock', 'heath', 'grassland', 'scrub', 'shrubbery'))
AND way_area > 0.01*!pixel_width!::real*!pixel_height!::real
AND building IS NULL
) AS features
Expand All @@ -87,7 +87,7 @@ Layer:
<<: *osm2pgsql
table: |-
(SELECT
way, name, religion, way_pixels, is_building,
way, name, religion, density, way_pixels, is_building,
COALESCE(aeroway, golf, amenity, wetland, power, landuse, leisure, man_made, "natural", shop, tourism, highway, railway) AS feature
FROM (SELECT
way, COALESCE(name, '') AS name,
Expand All @@ -107,13 +107,16 @@ Layer:
'golf_course', 'miniature_golf', 'sports_centre', 'stadium', 'pitch', 'ice_rink',
'track', 'dog_park', 'fitness_station', 'water_park') THEN leisure END)) AS leisure,
('man_made_' || (CASE WHEN man_made IN ('works', 'wastewater_plant', 'water_works') THEN man_made END)) AS man_made,
('natural_' || (CASE WHEN "natural" IN ('beach', 'shoal', 'heath', 'grassland', 'wood', 'sand', 'scree', 'shingle', 'bare_rock', 'scrub') THEN "natural" END)) AS "natural",
('natural_' || (CASE WHEN "natural" IN ('beach', 'shoal', 'heath', 'grassland', 'wood', 'sand', 'scree', 'shingle', 'bare_rock', 'scrub', 'shrubbery') THEN "natural" END)) AS "natural",
('wetland_' || (CASE WHEN "natural" IN ('wetland', 'mud') THEN (CASE WHEN "natural" = 'mud' THEN "natural" ELSE tags->'wetland' END) END)) AS wetland,
('power_' || (CASE WHEN power IN ('plant', 'substation', 'generator') THEN power END)) AS power,
('tourism_' || (CASE WHEN tourism IN ('camp_site', 'caravan_site', 'picnic_site') THEN tourism END)) AS tourism,
('highway_' || (CASE WHEN highway IN ('services', 'rest_area') THEN highway END)) AS highway,
('railway_' || (CASE WHEN railway = 'station' THEN railway END)) AS railway,
CASE WHEN religion IN ('christian', 'jewish', 'muslim') THEN religion ELSE 'INT-generic'::text END AS religion,
CASE WHEN "natural" = 'shrubbery'
THEN tags->'shrubbery:density'
END AS density,
way_area/NULLIF(POW(!scale_denominator!*0.001*0.28,2),0) AS way_pixels,
CASE WHEN building = 'no' OR building IS NULL THEN 'no' ELSE 'yes' END AS is_building,
way_area
Expand All @@ -126,7 +129,7 @@ Layer:
'grave_yard', 'place_of_worship', 'prison', 'clinic', 'ferry_terminal', 'marketplace', 'community_centre', 'social_facility',
'arts_centre', 'parking_space', 'bus_station', 'fire_station', 'police')
OR man_made IN ('works', 'wastewater_plant','water_works')
OR "natural" IN ('beach', 'shoal', 'heath', 'mud', 'wetland', 'grassland', 'wood', 'sand', 'scree', 'shingle', 'bare_rock', 'scrub')
OR "natural" IN ('beach', 'shoal', 'heath', 'mud', 'wetland', 'grassland', 'wood', 'sand', 'scree', 'shingle', 'bare_rock', 'scrub', 'shrubbery')
OR power IN ('plant', 'substation', 'generator')
OR shop IN ('mall')
OR tourism IN ('camp_site', 'caravan_site', 'picnic_site')
Expand Down Expand Up @@ -298,9 +301,13 @@ Layer:
END AS int_wetland,
landuse,
tags->'leaf_type' AS leaf_type,
-- Could be extended with wood:density or scrub:density:
CASE WHEN "natural" = 'shrubbery'
THEN tags->'shrubbery:density'
END AS density,
way_area/NULLIF(POW(!scale_denominator!*0.001*0.28,2),0) AS way_pixels
FROM planet_osm_polygon
WHERE ("natural" IN ('mud', 'wetland', 'wood', 'beach', 'shoal', 'reef', 'scrub') OR landuse IN ('forest', 'salt_pond'))
WHERE ("natural" IN ('mud', 'wetland', 'wood', 'beach', 'shoal', 'reef', 'scrub', 'shrubbery') OR landuse IN ('forest', 'salt_pond'))
AND building IS NULL
AND way_area > 1*!pixel_width!::real*!pixel_height!::real
ORDER BY COALESCE(layer,0), way_area DESC
Expand Down Expand Up @@ -1527,7 +1534,7 @@ Layer:
'construction', 'salt_pond', 'military', 'plant_nursery') THEN landuse END,
'natural_' || CASE WHEN "natural" IN ('peak', 'volcano', 'saddle', 'cave_entrance') AND way_area IS NULL THEN "natural" END,
'natural_' || CASE WHEN "natural" IN ('wood', 'water', 'mud', 'wetland', 'bay', 'spring', 'scree', 'shingle', 'bare_rock', 'sand', 'heath',
'grassland', 'scrub', 'beach', 'glacier', 'tree', 'strait', 'cape')
'grassland', 'scrub', 'shrubbery', 'beach', 'glacier', 'tree', 'strait', 'cape')
THEN "natural" END,
'waterway_' || CASE WHEN "waterway" IN ('waterfall') AND way_area IS NULL THEN waterway END,
'place_' || CASE WHEN place IN ('island', 'islet', 'square') THEN place END,
Expand Down
25 changes: 25 additions & 0 deletions style/landcover.mss
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
@allotments: #c9e1bf; // Lch(87,20,135)
@orchard: #aedfa3; // also vineyard, plant_nursery
@hedge: @forest; // Lch(80,30,135)
@shrubbery: @scrub;
@shrubbery-barrier: @forest;

// --- "Base" landuses ---

Expand Down Expand Up @@ -530,6 +532,15 @@
[way_pixels >= 64] { polygon-gamma: 0.3; }
}

[feature = 'natural_shrubbery'][zoom >= 5] {
polygon-fill: @shrubbery;
[density = 'dense'] {
polygon-fill: @shrubbery-barrier;
}
[way_pixels >= 4] { polygon-gamma: 0.75; }
[way_pixels >= 64] { polygon-gamma: 0.3; }
}

[feature = 'wetland_swamp'][zoom >= 5] {
polygon-fill: @forest;
[way_pixels >= 4] { polygon-gamma: 0.75; }
Expand Down Expand Up @@ -792,6 +803,20 @@
polygon-pattern-file: url('symbols/scrub.png');
polygon-pattern-alignment: global;
}
[natural = 'shrubbery'] {
[density = 'sparse'] {
polygon-pattern-file: url('symbols/shrubbery/sparse.png');
polygon-pattern-alignment: global;
}
[density = 'medium'] {
polygon-pattern-file: url('symbols/shrubbery/medium.png');
polygon-pattern-alignment: global;
}
[density = 'dense'] {
polygon-pattern-file: url('symbols/shrubbery/dense.png');
polygon-pattern-alignment: global;
}
}
}

//Also landuse = forest, converted in the SQL
Expand Down
Binary file added symbols/shrubbery/dense.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added symbols/shrubbery/medium.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added symbols/shrubbery/sparse.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit f372f04

Please sign in to comment.