Skip to content

Commit

Permalink
Refactor buildings code
Browse files Browse the repository at this point in the history
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 gravitystorm#520. Superceeds gravitystorm#550.

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

Removes outline differences based on a distinction that no one fully understands. Superceeds gravitystorm#533. Fixes gravitystorm#68
  • Loading branch information
pnorman authored and matthijsmelissen committed Oct 1, 2014
1 parent 555c868 commit dd77ba1
Show file tree
Hide file tree
Showing 4 changed files with 123 additions and 48 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: #e0d9cc;
@building-line: darken(@building-fill, 15%);

#buildings-lz {
[zoom >= 10] {
[railway = 'station']::railway,
[building = 'station'] {
polygon-fill: @station;
polygon-clip: false;
}

[building = 'supermarket'] {
polygon-fill: @supermarket;
polygon-opacity: 0.5;
polygon-clip: false;
}
@building-aeroway-fill: #cc99ff;
@building-aeroway-line: darken(@building-aeroway-fill,15%);

[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;
polygon-clip: false;
}
[building != 'INT-light'][building != ''][zoom >= 12] {
polygon-fill: @building;
polygon-opacity: 0.9;
[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;
[zoom >= 16] {
line-color: saturate(darken(@building, 50%), 10%);
line-width: 0.2;
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 >= 16] {
line-color: @building-aeroway-line;
}
}
}
}
19 changes: 19 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 @@ -394,6 +407,12 @@
line-color: saturate(darken(@pitch, 40%), 20%);
}
}

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

/* man_made=cutline */
Expand Down
48 changes: 47 additions & 1 deletion project.mml
100644 → 100755
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)) AS railway,\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 IN ('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 @@ -609,6 +609,52 @@
"id": "tree-row",
"advanced": {}
},
{
"name": "buildings-major",
"srs-name": "900913",
"geometry": "linestring",
"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 way, building, amenity\n FROM planet_osm_polygon\n WHERE building IN ('station','supermarket')\n OR (building IS NOT NULL AND building != 'no' AND (\n amenity IN ('place_of_worship','supermarket') OR shop = 'mall' OR tourism = 'attraction'))\n ORDER BY z_order,way_area DESC\n) AS buildings_major",
"geometry_field": "way",
"type": "postgis",
"key_field": "",
"dbname": "gis"
},
"extent": [
-180,
-85.05112877980659,
180,
85.05112877980659
],
"id": "buildings-major",
"advanced": {}
},
{
"name": "buildings",
"srs-name": "900913",
"geometry": "linestring",
"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 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": "",
"dbname": "gis"
},
"extent": [
-180,
-85.05112877980659,
180,
85.05112877980659
],
"id": "buildings",
"advanced": {}
},
{
"name": "ferry-routes",
"srs-name": "900913",
Expand Down
35 changes: 34 additions & 1 deletion 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)) AS railway,
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 IN ('station')
ORDER BY z_order, way_area DESC
) AS landcover
) AS features
Expand Down Expand Up @@ -545,6 +547,37 @@ Layer:
WHERE "natural" = 'tree_row'
) AS tree_row
advanced: {}
- id: "buildings-major"
name: "buildings-major"
class: ""
geometry: "linestring"
<<: *extents
Datasource:
<<: *osm2pgsql
table: |-
(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"
class: ""
geometry: "linestring"
<<: *extents
Datasource:
<<: *osm2pgsql
table: |-
(SELECT way, name, building, amenity, aeroway, way_area
FROM planet_osm_polygon
WHERE (building IS NOT NULL OR aeroway = 'terminal')
AND building != 'no'
ORDER BY z_order, way_area DESC
) AS buildings
advanced: {}
- id: "ferry-routes"
name: "ferry-routes"
class: ""
Expand Down

0 comments on commit dd77ba1

Please sign in to comment.