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 committed May 25, 2014
1 parent 34bc2f2 commit d420795
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 45 deletions.
63 changes: 23 additions & 40 deletions buildings.mss
Original file line number Diff line number Diff line change
@@ -1,52 +1,35 @@
#buildings-lz {
[zoom >= 10] {
[railway = 'station']::railway,
[building = 'station'] {
polygon-fill: #d4aaaa;
polygon-clip: false;
}
@building-fill: #e0d9cc;
@building-line: darken(@building-fill, 15%);

[building = 'supermarket'] {
polygon-fill: pink;
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: #777;
polygon-clip: false;
[zoom >= 15] {
polygon-opacity: 0.9;
polygon-fill: #aaa;
line-width: 0.3;
line-color: #111;
}
}

#buildings-major {
[zoom >= 10][zoom < 12] {
polygon-fill: @building-fill;
polygon-clip: false;
}
}

#buildings {
[building = 'INT-light'][zoom >= 12] {
polygon-fill: #bca9a9;
polygon-opacity: 0.7;
polygon-clip: false;
}
[building != 'INT-light'][building != ''][zoom >= 12] {
polygon-fill: #bca9a9;
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: #330066;
line-width: 0.2;
line-color: @building-line;
line-width: .75;
line-clip: false;
}
}
[aeroway = 'terminal'][zoom >= 12]::aeroway {
polygon-fill: #cc99ff;
polygon-clip: false;
[zoom >= 14] {
line-color: #330066;
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 @@ -34,13 +34,16 @@
@farmyard: #ddbf92;
@farm: #ead8bd; // also farmland
@parking: #f7efb7;
@place_of_worship: #cdccc9;
@place_of_worship_outline: #111;
@playground: #ccfff1;
@power: #bbb;
@rest_area: #efc8c8; // also services
@retail: #f1dada;
@residential: #ddd;
@sand: #ffdf88;
@school: #f0f0d8; // also university, college, hospital, kindergarten
@station: #d4aaaa;

#landcover {
[feature = 'leisure_swimming_pool'][zoom >= 14] {
Expand Down Expand Up @@ -102,6 +105,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;
}
Expand Down Expand Up @@ -332,6 +345,12 @@
polygon-fill: @rest_area;
}
}

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

/* man_made=cutline */
Expand Down
10 changes: 5 additions & 5 deletions project.mml
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@
],
"Datasource": {
"type": "postgis",
"table": "(select way, religion,\ncoalesce (aeroway, amenity, landuse, leisure, military, \"natural\", power, tourism, highway) as feature from (\nselect way,\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', 'grave_yard', 'residential', 'garages', 'field', 'meadow', 'grass', 'allotments', 'forest', 'farmyard', 'farm', 'farmland', 'recreation_ground', 'conservation', 'village_green', 'retail', 'industrial', 'railway', 'commercial', 'brownfield', 'landfill', 'greenfield', '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') 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 ('field','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,\ncase 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 ('field','beach','desert','heath','mud','grassland','wood','sand','scrub')\n or power in ('station','sub_station','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 way, religion,\ncoalesce (aeroway, amenity, landuse, leisure, military, \"natural\", power, tourism, highway, railway) as feature from (\nselect way,\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', 'grave_yard', 'residential', 'garages', 'field', 'meadow', 'grass', 'allotments', 'forest', 'farmyard', 'farm', 'farmland', 'recreation_ground', 'conservation', 'village_green', 'retail', 'industrial', 'railway', 'commercial', 'brownfield', 'landfill', 'greenfield', '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') 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 ('field','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,\ncase 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 ('field','beach','desert','heath','mud','grassland','wood','sand','scrub')\n or power in ('station','sub_station','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",
"extent": "-20037508,-19929239,20037508,19929239",
"key_field": "",
"geometry_field": "",
Expand Down Expand Up @@ -721,18 +721,18 @@
],
"Datasource": {
"type": "postgis",
"table": " (select 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) 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')\n OR shop = 'mall'\n OR tourism = 'attraction'\n )\n )\n ORDER BY z_order,way_area DESC)\nAS buildings_major",
"extent": "-20037508,-19929239,20037508,19929239",
"key_field": "",
"geometry_field": "way",
"dbname": "gis"
},
"id": "buildings-lz",
"id": "buildings-major",
"class": "",
"srs-name": "900913",
"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",
"advanced": {},
"name": "buildings-lz"
"name": "buildings-major"
},
{
"geometry": "polygon",
Expand All @@ -744,7 +744,7 @@
],
"Datasource": {
"type": "postgis",
"table": " (select 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) as buildings",
"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) AS buildings",
"extent": "-20037508,-19929239,20037508,19929239",
"key_field": "",
"geometry_field": "way",
Expand Down

0 comments on commit d420795

Please sign in to comment.