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

Update leisure=golf_course color and render golf=* features (gravitystorm#661) #4381

Merged
merged 10 commits into from
Sep 11, 2021
28 changes: 23 additions & 5 deletions 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,19 @@ Layer:
properties:
cache-features: true
minzoom: 11
- id: golf-line
geometry: linestring
<<: *extents
Datasource:
<<: *osm2pgsql
table: |-
(SELECT
way, tags->'golf' AS golf, ref, name
jgruca marked this conversation as resolved.
Show resolved Hide resolved
FROM planet_osm_line
WHERE tags->'golf' = 'hole' AND way && !bbox!
jgruca marked this conversation as resolved.
Show resolved Hide resolved
) AS golf_line
properties:
minzoom: 16
- id: necountries
geometry: linestring
<<: *extents
Expand Down Expand Up @@ -1536,7 +1552,8 @@ Layer:
AND way_area IS NULL
THEN amenity END,
'tourism_' || CASE WHEN tourism IN ('viewpoint', 'attraction') THEN tourism END,
'place_' || CASE WHEN place IN ('locality') AND way_area IS NULL THEN place END
'place_' || CASE WHEN place IN ('locality') AND way_area IS NULL THEN place END,
'golf_' || CASE WHEN tags->'golf' IN ('hole', 'pin') THEN tags->'golf' END
) AS feature,
access,
CASE
Expand Down Expand Up @@ -2007,15 +2024,15 @@ Layer:
(SELECT
way,
NULL as way_pixels,
COALESCE('aerialway_' || aerialway, 'attraction_' || CASE WHEN tags @> 'attraction=>water_slide' THEN 'water_slide' END, 'leisure_' || leisure, 'man_made_' || man_made, 'waterway_' || waterway, 'natural_' || "natural") AS feature,
COALESCE('aerialway_' || aerialway, 'attraction_' || CASE WHEN tags @> 'attraction=>water_slide' THEN 'water_slide' END, 'leisure_' || leisure, 'man_made_' || man_made, 'waterway_' || waterway, 'natural_' || "natural", CASE WHEN tags @> 'golf=>hole' THEN 'golf_hole' END) AS feature,
jgruca marked this conversation as resolved.
Show resolved Hide resolved
access,
name,
tags->'operator' as operator,
ref,
NULL AS way_area,
CASE WHEN building = 'no' OR building IS NULL THEN 'no' ELSE 'yes' END AS is_building
FROM planet_osm_line
WHERE (man_made IN ('pier', 'breakwater', 'groyne', 'embankment')
WHERE ((man_made IN ('pier', 'breakwater', 'groyne', 'embankment')
OR (man_made = 'pipeline'
AND tags-> 'location' IN ('overground', 'overhead', 'surface', 'outdoor')
OR bridge IN ('yes', 'aqueduct', 'cantilever', 'covered', 'trestle', 'viaduct'))
Expand All @@ -2024,7 +2041,8 @@ Layer:
OR leisure IN ('slipway', 'track')
OR waterway IN ('dam', 'weir')
OR "natural" IN ('arete', 'cliff', 'ridge'))
AND name IS NOT NULL
AND name IS NOT NULL)
OR tags @> 'golf=>hole'
Copy link
Collaborator

Choose a reason for hiding this comment

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

This is going to have negative performance impacts since it will be unable to use the planet_osm_line_name index

Copy link
Contributor Author

Choose a reason for hiding this comment

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

What's the best way to address this?

Copy link
Collaborator

Choose a reason for hiding this comment

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

I'm thinking WHERE ([existing conditions] AND name IS NOT NULL) OR ([new conditions] AND ref IS NOT NULL) then rename the planet_osm_line_name index to planet_osm_line_label and make it have the condition name IS NOT NULL OR ref IS NOT NULL, but it could use more thought and testing.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I concur - we also have other queries from planet_osm_line which have a ref IS NOT NULL condition, that is roads-text-ref and roads-text-ref-minor.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I've updated the index defined in indexes.sql/indexes.yml and reformatted the query's condition as described.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I ran EXPLAIN on a sample query, and it does appear the index is being used and has a positive effect on query cost.

With only planet_osm_line_name:

 Bitmap Heap Scan on planet_osm_line  (cost=55.42..3376.13 rows=7 width=85)
   Recheck Cond: (way && '<snip>'::geometry)
   Filter: ((((man_made = ANY ('{pier,breakwater,groyne,embankment}'::text[])) OR ((man_made = 'pipeline'::text) AND ((tags -> 'location'::text) =
ANY ('{overground,overhead,surface,outdoor}'::text[]))) OR (bridge = ANY ('{yes,aqueduct,cantilever,covered,trestle,viaduct}'::text[])) OR (tags @>
 '"attraction"=>"water_slide"'::hstore) OR (aerialway = ANY ('{cable_car,gondola,mixed_lift,goods,chair_lift,drag_lift,t-bar,j-bar,platter,rope_tow
,zip_line}'::text[])) OR (leisure = ANY ('{slipway,track}'::text[])) OR (waterway = ANY ('{dam,weir}'::text[])) OR ("natural" = ANY ('{arete,cliff,
ridge}'::text[]))) AND (name IS NOT NULL)) OR ((tags @> '"golf"=>"hole"'::hstore) AND (ref IS NOT NULL)))
   ->  Bitmap Index Scan on planet_osm_line_way_idx  (cost=0.00..55.42 rows=951 width=0)
         Index Cond: (way && '<snip>'::geometry)

After creating planet_osm_line_label:

 Bitmap Heap Scan on planet_osm_line  (cost=18.47..1116.75 rows=7 width=85)
   Recheck Cond: ((way && '<snip>'::geometry) AND ((name IS NOT NULL) OR (ref IS NOT NULL)))
   Filter: ((((man_made = ANY ('{pier,breakwater,groyne,embankment}'::text[])) OR ((man_made = 'pipeline'::text) AND ((tags -> 'location'::text) =
ANY ('{overground,overhead,surface,outdoor}'::text[]))) OR (bridge = ANY ('{yes,aqueduct,cantilever,covered,trestle,viaduct}'::text[])) OR (tags @>
 '"attraction"=>"water_slide"'::hstore) OR (aerialway = ANY ('{cable_car,gondola,mixed_lift,goods,chair_lift,drag_lift,t-bar,j-bar,platter,rope_tow
,zip_line}'::text[])) OR (leisure = ANY ('{slipway,track}'::text[])) OR (waterway = ANY ('{dam,weir}'::text[])) OR ("natural" = ANY ('{arete,cliff,
ridge}'::text[]))) AND (name IS NOT NULL)) OR ((tags @> '"golf"=>"hole"'::hstore) AND (ref IS NOT NULL)))
   ->  Bitmap Index Scan on planet_osm_line_label  (cost=0.00..18.47 rows=292 width=0)
         Index Cond: (way && '<snip>'::geometry)

) AS text_line
properties:
minzoom: 10
Expand Down
62 changes: 62 additions & 0 deletions style/golf.mss
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
#landcover[zoom >= 12] {
::high-zoom[zoom >= 12] {
jgruca marked this conversation as resolved.
Show resolved Hide resolved
[feature = 'golf_tee'],
[feature = 'golf_fairway'],
[feature = 'golf_rough'],
[feature = 'golf_driving_range'] {
polygon-fill: @grass;
}
}
::high-zoom[zoom >= 13] {
[feature = 'golf_green'] {
polygon-fill: @pitch;
}
[feature = 'golf_bunker'] {
polygon-fill: @sand;
}
}
::high-zoom[zoom >= 15] {
[feature = 'golf_rough'] {
polygon-pattern-file: url('symbols/golf_rough.svg');
polygon-pattern-opacity: 0.2;
}
}
}

#golf-line[zoom >= 16] {
[golf = 'hole'] {
line-color: @leisure-green;
line-width: 0.5;
}
}

#text-line[zoom >= 16] {
[feature = 'golf_hole'][ref != ''] {
text-placement: line;
text-name: "[ref]";
text-size: 11;
text-fill: @leisure-green;
text-face-name: @book-fonts;
text-halo-radius: 1.5;
text-halo-fill: fadeout(white, 30%);
[zoom >= 17] {
text-size: 13;
}
}
}

#amenity-points[zoom >= 16] {
[feature = 'golf_hole'],
[feature = 'golf_pin'] {
marker-file: url('symbols/golf_pin.svg');
marker-fill: @leisure-green;
[ref != ''] {
text-fill: #444;
text-name: "[ref]";
text-face-name: @book-fonts;
text-dy: -10;
text-halo-radius: 1.5;
text-halo-fill: fadeout(white, 30%);
}
}
}
5 changes: 2 additions & 3 deletions style/landcover.mss
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
// --- Other ----

@bare_ground: #eee5dc;
@campsite: #def6c0; // also caravan_site, picnic_site
@campsite: #def6c0; // also caravan_site, picnic_site, golf_course
@cemetery: #aacbaf; // also grave_yard
@construction: #c7c7b4; // also brownfield
@heath: #d6d99f;
Expand All @@ -66,7 +66,6 @@
@pitch: #aae0cb; // Lch(85,22,168) also track
@track: @pitch;
@stadium: @leisure; // also sports_centre
@golf_course: #b5e3b5;
jgruca marked this conversation as resolved.
Show resolved Hide resolved

#landcover-low-zoom[zoom < 10],
#landcover[zoom >= 10] {
Expand Down Expand Up @@ -277,7 +276,7 @@

[feature = 'leisure_golf_course'][zoom >= 10],
[feature = 'leisure_miniature_golf'][zoom >= 15] {
polygon-fill: @golf_course;
polygon-fill: @campsite;
[way_pixels >= 4] { polygon-gamma: 0.75; }
[way_pixels >= 64] { polygon-gamma: 0.3; }
}
Expand Down
9 changes: 9 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.
9 changes: 9 additions & 0 deletions symbols/golf_rough.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.