Skip to content

Commit

Permalink
Squashed commit of the following:
Browse files Browse the repository at this point in the history
Refactor buildings code

Replace the old buildings SQL and MSS. This involves resulting changes to landcover stylings to handle landcover which was previously in buildings.mss.

Stops rendering supermarkets in a crazy pink to fix #520. Superceeds #550.

Moves the rendering of train station areas to landcover. Fixes #327. Fixes #389

Removes outline differences based on a distinction that no one fully understands. Superceeds #533. Fixes #68

Rebased in 6b2a4de by math1985 <[email protected]>
  • Loading branch information
pnorman committed Oct 16, 2014
1 parent 555c868 commit 7af7a31
Show file tree
Hide file tree
Showing 4 changed files with 64 additions and 72 deletions.
69 changes: 23 additions & 46 deletions buildings.mss
Original file line number Diff line number Diff line change
@@ -1,58 +1,35 @@
@building: #bca9a9;
@station: #d4aaaa;
@supermarket: pink;
@placeOfWorship: #777;
@terminal: #cc99ff;
@building-fill: #dcd5c6;
@building-line: darken(@building-fill, 10%);

#buildings-lz {
[zoom >= 10] {
[railway = 'station']::railway,
[building = 'station'] {
polygon-fill: @station;
polygon-clip: false;
}
@building-aeroway-fill: #cc99ff;
@building-aeroway-line: darken(@building-aeroway-fill,15%);

[building = 'supermarket'] {
polygon-fill: @supermarket;
polygon-opacity: 0.5;
polygon-clip: false;
}

[amenity = 'place_of_worship']::amenity {
polygon-opacity: 0.5;
polygon-fill: @placeOfWorship;
polygon-clip: false;
[zoom >= 15] {
polygon-opacity: 0.9;
polygon-fill: lighten(@placeOfWorship, 20%);
line-width: 0.3;
line-color: darken(@placeOfWorship, 40%);
}
}
#buildings-major {
[zoom >= 10][zoom < 12] {
polygon-fill: @building-fill;
polygon-clip: false;
}
}

#buildings {
[building = 'INT-light'][zoom >= 12] {
polygon-fill: @building;
polygon-opacity: 0.7;
[zoom >= 12] {
/* Set the base styling for buildings. We'll need to reset the fill and
line colours for more specialized building rendering lower down, but
not the clipping or line-width.
*/
polygon-fill: @building-fill;
polygon-clip: false;
}
[building != 'INT-light'][building != ''][zoom >= 12] {
polygon-fill: @building;
polygon-opacity: 0.9;
polygon-clip: false;
[zoom >= 16] {
line-color: saturate(darken(@building, 50%), 10%);
line-width: 0.2;
[zoom >= 15] {
line-color: @building-line;
line-width: .75;
line-clip: false;
}
}
[aeroway = 'terminal'][zoom >= 12]::aeroway {
polygon-fill: @terminal;
polygon-clip: false;
[zoom >= 14] {
line-color: saturate(darken(@terminal, 50%), 20%);
line-width: 0.2;
[aeroway = 'terminal'] {
polygon-fill: @building-aeroway-fill;
[zoom >= 15] {
line-color: @building-aeroway-line;
}
}
}
}
17 changes: 17 additions & 0 deletions landcover.mss
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,14 @@
@garages: #dfddce;
@heath: #d6d99f;
@parking: #f7efb7;
@place_of_worship: #cdccc9;
@place_of_worship_outline: #111;
@playground: #ccfff1;
@power: #bbb;
@rest_area: #efc8c8; // also services
@sand: #ffdf88;
@school: #f0f0d8; // also university, college, hospital, kindergarten
@station: #d4aaaa;

#landcover {
[feature = 'leisure_swimming_pool'][zoom >= 14] {
Expand Down Expand Up @@ -113,6 +116,16 @@
}
}

[feature = 'amenity_place_of_worship'] {
polygon-fill: @place_of_worship;
polygon-clip: false;
[zoom >= 15] {
line-color: @place_of_worship_outline;
line-width: 0.3;
line-clip: false;
}
}

[feature = 'landuse_residential'][zoom >= 10] {
polygon-fill: @residential;
[zoom >= 16] {
Expand Down Expand Up @@ -372,6 +385,10 @@
}
}

[feature = 'railway_station'][zoom >= 10] {
polygon-fill: @station;
}

[feature = 'leisure_sports_centre'],
[feature = 'leisure_stadium'] {
[zoom >= 10] {
Expand Down
10 changes: 5 additions & 5 deletions project.mml
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@
"srs": "+proj=merc +a=6378137 +b=6378137 +lat_ts=0.0 +lon_0=0.0 +x_0=0.0 +y_0=0.0 +k=1.0 +units=m +nadgrids=@null +wktext +no_defs +over",
"Datasource": {
"extent": "-20037508,-20037508,20037508,20037508",
"table": "(SELECT \n way, name, religion,\n COALESCE(aeroway, amenity, landuse, leisure, military, \"natural\", power, tourism, highway) AS feature \n FROM (SELECT \n way, COALESCE(name, '') AS name, \n ('aeroway_' || (CASE WHEN aeroway IN ('apron', 'aerodrome') THEN aeroway ELSE NULL END)) AS aeroway,\n ('amenity_' || (CASE WHEN amenity IN ('parking', 'university', 'college', 'school', 'hospital', 'kindergarten', 'grave_yard') THEN amenity ELSE NULL END)) AS amenity,\n ('landuse_' || (CASE WHEN landuse IN ('quarry', 'vineyard', 'orchard', 'cemetery', 'residential', 'garages', 'field', 'meadow', 'grass', 'allotments', 'forest', 'farmyard', 'farm', 'farmland', 'recreation_ground', 'conservation', 'village_green', 'retail', 'industrial', 'railway', 'commercial', 'brownfield', 'landfill', 'construction') THEN landuse ELSE NULL END)) AS landuse,\n ('leisure_' || (CASE WHEN leisure IN ('swimming_pool', 'playground', 'park', 'recreation_ground', 'common', 'garden', 'golf_course', 'picnic_table', 'sports_centre', 'stadium', 'pitch', 'track') THEN leisure ELSE NULL END)) AS leisure,\n ('military_' || (CASE WHEN military IN ('barracks', 'danger_area') THEN military ELSE NULL END)) AS military,\n ('natural_' || (CASE WHEN \"natural\" IN ('beach', 'desert', 'heath', 'mud', 'grassland', 'wood', 'sand', 'scrub') THEN \"natural\" ELSE NULL END)) AS \"natural\",\n ('power_' || (CASE WHEN power IN ('station', 'sub_station', 'substation', 'generator') THEN power ELSE NULL END)) AS power,\n ('tourism_' || (CASE WHEN tourism IN ('attraction', 'camp_site', 'caravan_site', 'picnic_site', 'zoo') THEN tourism ELSE NULL END)) AS tourism,\n ('highway_' || (CASE WHEN highway IN ('services', 'rest_area') THEN highway ELSE NULL END)) AS highway,\n CASE WHEN religion IN ('christian', 'jewish') THEN religion ELSE 'INT-generic'::text END AS religion\n FROM planet_osm_polygon\n WHERE landuse IS NOT NULL\n OR leisure IS NOT NULL\n OR aeroway IN ('apron', 'aerodrome')\n OR amenity IN ('parking', 'university', 'college', 'school', 'hospital', 'kindergarten', 'grave_yard')\n OR military IN ('barracks', 'danger_area')\n OR \"natural\" IN ('beach', 'desert', 'heath', 'mud', 'grassland', 'wood', 'sand', 'scrub')\n OR power IN ('station', 'sub_station', 'substation', 'generator')\n OR tourism IN ('attraction', 'camp_site', 'caravan_site', 'picnic_site', 'zoo')\n OR highway IN ('services', 'rest_area')\n ORDER BY z_order, way_area DESC\n ) AS landcover\n) AS features",
"table": "(SELECT \n way, name, religion,\n COALESCE(aeroway, amenity, landuse, leisure, military, \"natural\", power, tourism, highway, railway) AS feature \n FROM (SELECT \n way, COALESCE(name, '') AS name, \n ('aeroway_' || (CASE WHEN aeroway IN ('apron', 'aerodrome') THEN aeroway ELSE NULL END)) AS aeroway,\n ('amenity_' || (CASE WHEN amenity IN ('parking', 'university', 'college', 'school', 'hospital', 'kindergarten', 'grave_yard') THEN amenity ELSE NULL END)) AS amenity,\n ('landuse_' || (CASE WHEN landuse IN ('quarry', 'vineyard', 'orchard', 'cemetery', 'residential', 'garages', 'field', 'meadow', 'grass', 'allotments', 'forest', 'farmyard', 'farm', 'farmland', 'recreation_ground', 'conservation', 'village_green', 'retail', 'industrial', 'railway', 'commercial', 'brownfield', 'landfill', 'construction') THEN landuse ELSE NULL END)) AS landuse,\n ('leisure_' || (CASE WHEN leisure IN ('swimming_pool', 'playground', 'park', 'recreation_ground', 'common', 'garden', 'golf_course', 'picnic_table', 'sports_centre', 'stadium', 'pitch', 'track') THEN leisure ELSE NULL END)) AS leisure,\n ('military_' || (CASE WHEN military IN ('barracks', 'danger_area') THEN military ELSE NULL END)) AS military,\n ('natural_' || (CASE WHEN \"natural\" IN ('beach', 'desert', 'heath', 'mud', 'grassland', 'wood', 'sand', 'scrub') THEN \"natural\" ELSE NULL END)) AS \"natural\",\n ('power_' || (CASE WHEN power IN ('station', 'sub_station', 'substation', 'generator') THEN power ELSE NULL END)) AS power,\n ('tourism_' || (CASE WHEN tourism IN ('attraction', 'camp_site', 'caravan_site', 'picnic_site', 'zoo') THEN tourism ELSE NULL END)) AS tourism,\n ('highway_' || (CASE WHEN highway IN ('services', 'rest_area') THEN highway ELSE NULL END)) AS highway,\n ('railway_' || (CASE WHEN railway = 'station' THEN railway ELSE NULL END)\n CASE WHEN religion IN ('christian', 'jewish') THEN religion ELSE 'INT-generic'::text END AS religion\n FROM planet_osm_polygon\n WHERE landuse IS NOT NULL\n OR leisure IS NOT NULL\n OR aeroway IN ('apron', 'aerodrome')\n OR amenity IN ('parking', 'university', 'college', 'school', 'hospital', 'kindergarten', 'grave_yard')\n OR military IN ('barracks', 'danger_area')\n OR \"natural\" IN ('beach', 'desert', 'heath', 'mud', 'grassland', 'wood', 'sand', 'scrub')\n OR power IN ('station', 'sub_station', 'substation', 'generator')\n OR tourism IN ('attraction', 'camp_site', 'caravan_site', 'picnic_site', 'zoo')\n OR highway IN ('services', 'rest_area')\n OR railway = 'station'\n ORDER BY z_order, way_area DESC\n ) AS landcover\n) AS features",
"geometry_field": "way",
"type": "postgis",
"key_field": "",
Expand Down Expand Up @@ -354,14 +354,14 @@
"advanced": {}
},
{
"name": "buildings-lz",
"name": "buildings-major",
"srs-name": "900913",
"geometry": "polygon",
"class": "",
"srs": "+proj=merc +a=6378137 +b=6378137 +lat_ts=0.0 +lon_0=0.0 +x_0=0.0 +y_0=0.0 +k=1.0 +units=m +nadgrids=@null +wktext +no_defs +over",
"Datasource": {
"extent": "-20037508,-20037508,20037508,20037508",
"table": "(SELECT\n way, building, railway, amenity FROM planet_osm_polygon\n WHERE railway = 'station'\n OR building IN ('station', 'supermarket')\n OR amenity = 'place_of_worship'\n ORDER BY z_order, way_area DESC\n) AS buildings_lz",
"table": "(SELECT way, building, amenity\n FROM planet_osm_polygon\n WHERE building IN ('station','supermarket')\n OR (building IS NOT NULL AND building != 'no'\n AND (\n amenity IN ('place_of_worship','supermarket') OR shop = 'mall' OR tourism = 'attraction'\n )\n )\n ORDER BY z_order,way_area DESC)\nAS buildings_major",
"geometry_field": "way",
"type": "postgis",
"key_field": "",
Expand All @@ -373,7 +373,7 @@
180,
85.05112877980659
],
"id": "buildings-lz",
"id": "buildings-major",
"advanced": {}
},
{
Expand All @@ -384,7 +384,7 @@
"srs": "+proj=merc +a=6378137 +b=6378137 +lat_ts=0.0 +lon_0=0.0 +x_0=0.0 +y_0=0.0 +k=1.0 +units=m +nadgrids=@null +wktext +no_defs +over",
"Datasource": {
"extent": "-20037508,-20037508,20037508,20037508",
"table": "(SELECT \n way, aeroway,\n CASE\n WHEN building IN ('garage', 'roof', 'garages', 'service', 'shed', 'shelter', 'cabin', 'storage_tank', 'tank', 'support', 'glasshouse', 'greenhouse', 'mobile_home', 'kiosk', 'silo', 'canopy', 'tent') THEN 'INT-light'::text\n ELSE building\n END AS building\n FROM planet_osm_polygon\n WHERE (building IS NOT NULL\n AND building NOT IN ('no', 'station', 'supermarket', 'planned')\n AND (railway IS NULL OR railway != 'station')\n AND (amenity IS NULL OR amenity != 'place_of_worship'))\n OR aeroway = 'terminal'\n ORDER BY z_order, way_area DESC\n) AS buildings",
"table": "(SELECT\n way, name, building, amenity, aeroway, way_area\n FROM planet_osm_polygon\n WHERE (building IS NOT NULL OR aeroway = 'terminal')\n AND building != 'no'\n ORDER BY z_order, way_area DESC\n) AS buildings",
"geometry_field": "way",
"type": "postgis",
"key_field": "",
Expand Down
40 changes: 19 additions & 21 deletions project.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ Layer:
table: |-
(SELECT
way, name, religion,
COALESCE(aeroway, amenity, landuse, leisure, military, "natural", power, tourism, highway) AS feature
COALESCE(aeroway, amenity, landuse, leisure, military, "natural", power, tourism, highway, railway) AS feature
FROM (SELECT
way, COALESCE(name, '') AS name,
('aeroway_' || (CASE WHEN aeroway IN ('apron', 'aerodrome') THEN aeroway ELSE NULL END)) AS aeroway,
Expand All @@ -114,6 +114,7 @@ Layer:
('power_' || (CASE WHEN power IN ('station', 'sub_station', 'substation', 'generator') THEN power ELSE NULL END)) AS power,
('tourism_' || (CASE WHEN tourism IN ('attraction', 'camp_site', 'caravan_site', 'picnic_site', 'zoo') THEN tourism ELSE NULL END)) AS tourism,
('highway_' || (CASE WHEN highway IN ('services', 'rest_area') THEN highway ELSE NULL END)) AS highway,
('railway_' || (CASE WHEN railway = 'station' THEN railway ELSE NULL END)
CASE WHEN religion IN ('christian', 'jewish') THEN religion ELSE 'INT-generic'::text END AS religion
FROM planet_osm_polygon
WHERE landuse IS NOT NULL
Expand All @@ -125,6 +126,7 @@ Layer:
OR power IN ('station', 'sub_station', 'substation', 'generator')
OR tourism IN ('attraction', 'camp_site', 'caravan_site', 'picnic_site', 'zoo')
OR highway IN ('services', 'rest_area')
OR railway = 'station'
ORDER BY z_order, way_area DESC
) AS landcover
) AS features
Expand Down Expand Up @@ -293,21 +295,24 @@ Layer:
WHERE waterway = 'lock_gate'
) AS locks
advanced: {}
- id: "buildings-lz"
name: "buildings-lz"
- id: "buildings-major"
name: "buildings-major"
class: ""
geometry: "polygon"
<<: *extents
Datasource:
<<: *osm2pgsql
table: |-
(SELECT
way, building, railway, amenity FROM planet_osm_polygon
WHERE railway = 'station'
OR building IN ('station', 'supermarket')
OR amenity = 'place_of_worship'
ORDER BY z_order, way_area DESC
) AS buildings_lz
(SELECT way, building, amenity
FROM planet_osm_polygon
WHERE building IN ('station','supermarket')
OR (building IS NOT NULL AND building != 'no'
AND (
amenity IN ('place_of_worship','supermarket') OR shop = 'mall' OR tourism = 'attraction'
)
)
ORDER BY z_order,way_area DESC)
AS buildings_major
advanced: {}
- id: "buildings"
name: "buildings"
Expand All @@ -317,18 +322,11 @@ Layer:
Datasource:
<<: *osm2pgsql
table: |-
(SELECT
way, aeroway,
CASE
WHEN building IN ('garage', 'roof', 'garages', 'service', 'shed', 'shelter', 'cabin', 'storage_tank', 'tank', 'support', 'glasshouse', 'greenhouse', 'mobile_home', 'kiosk', 'silo', 'canopy', 'tent') THEN 'INT-light'::text
ELSE building
END AS building
(SELECT
way, name, building, amenity, aeroway, way_area
FROM planet_osm_polygon
WHERE (building IS NOT NULL
AND building NOT IN ('no', 'station', 'supermarket', 'planned')
AND (railway IS NULL OR railway != 'station')
AND (amenity IS NULL OR amenity != 'place_of_worship'))
OR aeroway = 'terminal'
WHERE (building IS NOT NULL OR aeroway = 'terminal')
AND building != 'no'
ORDER BY z_order, way_area DESC
) AS buildings
advanced: {}
Expand Down

0 comments on commit 7af7a31

Please sign in to comment.