Skip to content

Commit

Permalink
Initial pass at rendering golf=* features (gravitystorm#661)
Browse files Browse the repository at this point in the history
- Update landcover layer to include golf area features
- Add golf-lines layer
- Add style/golf.mss and specify rendering for:
  - golf=green and golf=tee (light green color between @grass and @park;
    tee with gray point labeled with ref)
  - golf=fairway and golf=driving_range (@grass)
  - golf=bunker (color and pattern for @sand and beach)
  - golf=rough (darker green between @scrub and @grass)
  - golf=hole as way (dashed line, darker green derived from @golf_course; labeled with ref)
  - golf=hole as point and golf=pin (symbols/golf_pin.svg; labeled with ref)

Based largely on imagico/osm-carto-alternative-colors.
  • Loading branch information
justingruca committed Apr 19, 2021
1 parent a2077c0 commit 48ec53d
Show file tree
Hide file tree
Showing 3 changed files with 107 additions and 1 deletion.
31 changes: 30 additions & 1 deletion project.mml
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ Stylesheet:
- style/aerialways.mss
- style/admin.mss
- style/addressing.mss
- style/golf.mss
Layer:
- id: landcover-low-zoom
geometry: polygon
Expand Down Expand Up @@ -87,10 +88,11 @@ Layer:
table: |-
(SELECT
way, name, religion, way_pixels, is_building,
COALESCE(aeroway, amenity, wetland, power, landuse, leisure, man_made, "natural", shop, tourism, highway, railway) AS feature
COALESCE(aeroway, golf, amenity, wetland, power, landuse, leisure, man_made, "natural", shop, tourism, highway, railway) AS feature
FROM (SELECT
way, COALESCE(name, '') AS name,
('aeroway_' || (CASE WHEN aeroway IN ('apron', 'aerodrome') THEN aeroway END)) AS aeroway,
('golf_' || (CASE WHEN (tags->'golf') IN ('rough', 'fairway', 'driving_range', 'water_hazard', 'green', 'bunker', 'tee') THEN tags->'golf' ELSE NULL END)) AS golf,
('amenity_' || (CASE WHEN amenity IN ('bicycle_parking', 'motorcycle_parking', 'university', 'college', 'school', 'taxi',
'hospital', 'kindergarten', 'grave_yard', 'prison', 'place_of_worship', 'clinic', 'ferry_terminal',
'marketplace', 'community_centre', 'social_facility', 'arts_centre', 'parking_space', 'bus_station',
Expand Down Expand Up @@ -119,6 +121,7 @@ Layer:
WHERE (landuse IS NOT NULL
OR leisure IS NOT NULL
OR aeroway IN ('apron', 'aerodrome')
OR (tags->'golf') IS NOT NULL
OR amenity IN ('parking', 'bicycle_parking', 'motorcycle_parking', 'taxi', 'university', 'college', 'school', 'hospital', 'kindergarten',
'grave_yard', 'place_of_worship', 'prison', 'clinic', 'ferry_terminal', 'marketplace', 'community_centre', 'social_facility',
'arts_centre', 'parking_space', 'bus_station', 'fire_station', 'police')
Expand Down Expand Up @@ -1044,6 +1047,32 @@ Layer:
properties:
cache-features: true
minzoom: 11
- id: golf-lines
<<: *extents
Datasource:
<<: *osm2pgsql
table: |-
(SELECT
way, geo, golf, ref, name
FROM
(SELECT
way, tags->'golf' AS golf, name, ref, 0 AS prio, 'polygon' AS geo
FROM planet_osm_polygon
WHERE (tags->'golf') IS NOT NULL AND way && !bbox!
UNION ALL
SELECT
p.way, p.tags->'golf' AS golf, p.name, coalesce(p.ref,l.ref) AS ref, 0 AS prio, 'point' AS geo
FROM planet_osm_point p LEFT JOIN planet_osm_line l ON (ST_Intersects(p.way, l.way) AND (l.tags->'golf') IS NOT NULL)
WHERE p.tags ? 'golf' AND p.way && !bbox!
UNION ALL
SELECT
way, tags->'golf' AS golf, name, ref, 1 AS prio, 'line' AS geo
FROM planet_osm_line WHERE (tags->'golf') IS NOT NULL AND way && !bbox!
) AS golf
ORDER BY prio
) AS golf_lines
properties:
minzoom: 16
- id: necountries
geometry: linestring
<<: *extents
Expand Down
60 changes: 60 additions & 0 deletions style/golf.mss
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
#landcover[zoom >= 14] {
::high-zoom[zoom >= 12] {
[feature = 'golf_green'],
[feature = 'golf_tee'] {
polygon-fill: mix(@grass, @park, 50%);
}
[feature = 'golf_fairway'],
[feature = 'golf_driving_range'] {
polygon-fill: @grass;
}
[feature = 'golf_bunker'] {
polygon-fill: @sand;
polygon-pattern-file: url('symbols/beach.png');
}
[feature = 'golf_rough'] {
polygon-fill: mix(@scrub, @grass, 50%);
}
}
}

#golf-lines[zoom >= 16] {
[golf = 'hole'][geo = 'line'] {
line-color: darken(@golf_course, 40%);
line-width: 0.5;
line-dasharray: 6, 2;
[name = ''][ref != ''] {
text-placement: line;
text-name: "[ref]";
text-size: 11;
text-fill: darken(@golf_course, 40%);
text-face-name: @oblique-fonts;
text-halo-radius: 1;
text-halo-fill: fadeout(white, 30%);
}
}
[golf = 'hole'][geo = 'point'],
[golf = 'pin'] {
point-file: url('symbols/golf_pin.svg');
[ref != ''] {
text-fill: #444;
text-name: "[ref]";
text-face-name: @book-fonts;
text-dy: -10;
text-halo-radius: 1;
text-halo-fill: fadeout(white, 30%);
}
}
[golf = 'tee'] {
marker-fill: grey;
marker-width: 3;
marker-height: 3;
[ref != ''] {
text-name: "[ref]";
text-face-name: @book-fonts;
text-dy: 6;
text-halo-radius: 1;
text-halo-fill: fadeout(white, 30%);
}
}
}
17 changes: 17 additions & 0 deletions symbols/golf_pin.svg
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 48ec53d

Please sign in to comment.