Skip to content

Commit

Permalink
Fix the landcover ordering problem. Closes #15.
Browse files Browse the repository at this point in the history
For detailed thinking behind the over-complicated SQL query, see the
conversation at
#15
  • Loading branch information
gravitystorm committed Jan 6, 2013
1 parent a950ec3 commit 34b1541
Show file tree
Hide file tree
Showing 2 changed files with 67 additions and 67 deletions.
132 changes: 66 additions & 66 deletions landcover.mss
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
#landcover {
[leisure = 'swimming_pool'][zoom >= 14]::leisure {
[feature = 'leisure_swimming_pool'][zoom >= 14] {
polygon-fill: @water-color;
line-color: blue;
line-width: 0.5;
}

[leisure = 'playground'][zoom >= 13]::leisure {
[feature = 'leisure_playground'][zoom >= 13] {
polygon-fill: #ccfff1;
line-color: #666;
line-width: 0.3;
}

[tourism = 'camp_site']::tourism,
[tourism = 'caravan_site']::tourism,
[tourism = 'picnic_site']::tourism {
[feature = 'tourism_camp_site'],
[feature = 'tourism_caravan_site'],
[feature = 'tourism_picnic_site'] {
[zoom >= 13] {
polygon-fill: #ccff99;
polygon-opacity: 0.5;
Expand All @@ -22,17 +22,17 @@
}
}

[tourism = 'attraction'][zoom >= 10]::tourism {
[feature = 'tourism_attraction'][zoom >= 10] {
polygon-fill: #f2caea;
}

[landuse = 'quarry'][zoom >= 11]::landuse {
[feature = 'landuse_quarry'][zoom >= 11] {
polygon-pattern-file: url('symbols/quarry2.png');
line-width: 0.5;
line-color: grey;
}

[landuse = 'vineyard']::landuse {
[feature = 'landuse_vineyard'] {
[zoom >= 10][zoom < 13] {
polygon-fill: #abdf96;
}
Expand All @@ -41,13 +41,13 @@
}
}

[landuse = 'orchard'][zoom >= 10]::landuse {
[feature = 'landuse_orchard'][zoom >= 10] {
polygon-pattern-file: url('symbols/orchard.png');
}

[landuse = 'cemetery']::landuse,
[landuse = 'grave_yard']::landuse,
[amenity = 'grave_yard']::amenity {
[feature = 'landuse_cemetery'],
[feature = 'landuse_grave_yard'],
[feature = 'amenity_grave_yard'] {
[zoom >= 10][zoom < 14] {
polygon-fill: #aacbaf;
}
Expand All @@ -58,21 +58,21 @@
}
}

[landuse = 'residential'][zoom >= 10]::landuse {
[feature = 'landuse_residential'][zoom >= 10] {
polygon-fill: #ddd;
}

[landuse = 'garages'][zoom >= 12]::landuse {
[feature = 'landuse_garages'][zoom >= 12] {
polygon-fill: #996;
polygon-opacity: 0.2;
}

[military = 'barracks'][zoom >= 10]::military {
[feature = 'military_barracks'][zoom >= 10] {
polygon-fill: #ff8f8f;
}

[landuse = 'field']::landuse,
[natural = 'field']::natural {
[feature = 'landuse_field'],
[feature = 'natural_field'] {
[zoom >= 10] {
polygon-fill: #666600;
polygon-opacity: 0.2;
Expand All @@ -84,7 +84,7 @@
}
}

[military = 'danger_area']::military {
[feature = 'military_danger_area'] {
[zoom >= 9][zoom < 11] {
polygon-fill: pink;
polygon-opacity: 0.3;
Expand All @@ -94,38 +94,38 @@
}
}

[landuse = 'meadow']::landuse,
[landuse = 'grass']::landuse {
[feature = 'landuse_meadow'],
[feature = 'landuse_grass'] {
[zoom >= 10] {
polygon-fill: #cfeca8;
}
}

[leisure = 'park']::leisure,
[leisure = 'recreation_ground']::leisure {
[feature = 'leisure_park'],
[feature = 'leisure_recreation_ground'] {
[zoom >= 10] {
polygon-fill: #b6fdb6;
polygon-opacity: 0.6;
}
}

[tourism = 'zoo'][zoom >= 10]::tourism {
[feature = 'tourism_zoo'][zoom >= 10] {
polygon-pattern-file: url('symbols/zoo.png');
}

[leisure = 'common'][zoom >= 10]::leisure {
[feature = 'leisure_common'][zoom >= 10] {
polygon-fill: #cfeca8;
}

[leisure = 'garden'][zoom >= 10]::leisure {
[feature = 'leisure_garden'][zoom >= 10] {
polygon-fill: #cfeca8;
}

[leisure = 'golf_course'][zoom >= 10]::leisure {
[feature = 'leisure_golf_course'][zoom >= 10] {
polygon-fill: #b5e3b5;
}

[landuse = 'allotments']::landuse {
[feature = 'landuse_allotments'] {
[zoom >= 10][zoom < 14] {
polygon-fill: #e5c7ab;
}
Expand All @@ -134,7 +134,7 @@
}
}

[landuse = 'forest']::landuse {
[feature = 'landuse_forest'] {
[zoom >= 8][zoom < 14] {
polygon-fill: #8dc56c;
}
Expand All @@ -143,45 +143,45 @@
}
}

[landuse = 'farmyard'][zoom >= 9]::landuse {
[feature = 'landuse_farmyard'][zoom >= 9] {
polygon-fill: #ddbf92;
}

[landuse = 'farm']::landuse,
[landuse = 'farmland']::landuse {
[feature = 'landuse_farm'],
[feature = 'landuse_farmland'] {
[zoom >= 9] {
polygon-fill: #ead8bd;
}
}

[landuse = 'recreation_ground']::landuse,
[landuse = 'conservation']::landuse {
[feature = 'landuse_recreation_ground'],
[feature = 'landuse_conservation'] {
[zoom >= 10] {
polygon-fill: #cfeca8;
}
}

[landuse = 'village_green'][zoom >= 11]::landuse {
[feature = 'landuse_village_green'][zoom >= 11] {
polygon-fill: #cfeca8;
}

[landuse = 'retail'][zoom >= 10]::landuse {
[feature = 'landuse_retail'][zoom >= 10] {
polygon-fill: #f1dada;
[zoom >= 15] {
line-width: 0.3;
line-color: red;
}
}

[landuse = 'industrial']::landuse,
[landuse = 'railway']::landuse {
[feature = 'landuse_industrial'],
[feature = 'landuse_railway'] {
[zoom >= 10] {
polygon-fill: #dfd1d6;
}
}

[power = 'station']::power,
[power = 'generator']::power {
[feature = 'power_station'],
[feature = 'power_generator'] {
[zoom >= 10] {
polygon-fill: #bbb;
[zoom >= 12] {
Expand All @@ -191,50 +191,50 @@
}
}

[power = 'sub_station'][zoom >= 13]::power {
[feature = 'power_sub_station'][zoom >= 13] {
polygon-fill: #bbb;
line-width: 0.4;
line-color: #555;
}

[landuse = 'commercial'][zoom >= 10]::landuse {
[feature = 'landuse_commercial'][zoom >= 10] {
polygon-fill: #efc8c8;
}

[landuse = 'brownfield'],
[landuse = 'landfill'],
[landuse = 'greenfield'],
[landuse = 'construction'] {
[zoom >= 10]::landuse {
[feature = 'landuse_brownfield'],
[feature = 'landuse_landfill'],
[feature = 'landuse_greenfield'],
[feature = 'landuse_construction'] {
[zoom >= 10] {
polygon-fill: #9d9d6c;
polygon-opacity: 0.7;
}
}

[natural = 'wood']::natural,
[landuse = 'wood']::landuse {
[feature = 'natural_wood'],
[feature = 'landuse_wood'] {
[zoom >= 8] {
polygon-fill: #aed1a0;
}
}

[natural = 'desert'][zoom >= 8]::natural {
[feature = 'natural_desert'][zoom >= 8] {
polygon-fill: #e3b57a;
}

[natural = 'sand'][zoom >= 10]::natural {
[feature = 'natural_sand'][zoom >= 10] {
polygon-fill: #ffdf88;
}

[natural = 'heath'][zoom >= 10]::natural {
[feature = 'natural_heath'][zoom >= 10] {
polygon-fill: #d6d99f;
}

[natural = 'grassland'][zoom >= 10]::natural {
[feature = 'natural_grassland'][zoom >= 10] {
polygon-fill: #c6e4b4;
}

[natural = 'scrub']::natural {
[feature = 'natural_scrub'] {
[zoom >= 10][zoom < 14] {
polygon-fill: #b5e3b5;
}
Expand All @@ -243,12 +243,12 @@
}
}

[amenity = 'university'],
[amenity = 'college'],
[amenity = 'school'],
[amenity = 'hospital'],
[amenity = 'kindergarten'] {
[zoom >= 10]::amenity {
[feature = 'amenity_university'],
[feature = 'amenity_college'],
[feature = 'amenity_school'],
[feature = 'amenity_hospital'],
[feature = 'amenity_kindergarten'] {
[zoom >= 10] {
polygon-fill: #f0f0d8;
[zoom >= 12] {
line-width: 0.3;
Expand All @@ -257,32 +257,32 @@
}
}

[amenity = 'parking'][zoom >= 10]::amenity {
[feature = 'amenity_parking'][zoom >= 10] {
polygon-fill: #f7efb7;
[zoom >= 15] {
line-width: 0.3;
line-color: #eeeed1;
}
}

[aeroway = 'apron'][zoom >= 12]::aeroway {
[feature = 'aeroway_apron'][zoom >= 12] {
polygon-fill: #e9d1ff;
}

[aeroway = 'aerodrome'][zoom >= 12]::aeroway {
[feature = 'aeroway_aerodrome'][zoom >= 12] {
polygon-fill: #ccc;
polygon-opacity: 0.2;
line-width: 0.2;
line-color: #555;
}

[natural = 'beach'][zoom >= 13]::natural {
[feature = 'natural_beach'][zoom >= 13] {
polygon-pattern-file: url('symbols/beach.png');
}

[highway = 'services'],
[highway = 'rest_area'] {
[zoom >= 14]::highway {
[feature = 'highway_services'],
[feature = 'highway_rest_area'] {
[zoom >= 14] {
polygon-fill: #efc8c8;
}
}
Expand Down
2 changes: 1 addition & 1 deletion project.mml
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@
],
"Datasource": {
"type": "postgis",
"table": "(select way,aeroway,amenity,landuse,leisure,man_made,military,\"natural\",power,tourism,name,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 ('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 leisure",
"table": "(select way,name,religion,\ncoalesce (aeroway, amenity, landuse, leisure, military, \"natural\", power, tourism, highway) as feature from (\nselect way, 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', 'grave_yard', 'residential', 'garages', 'field', 'meadow', 'grass', 'allotments', 'forest', 'farmyard', 'farm', 'farmyard', 'recreation_ground', 'conservation', 'village_green', 'retail', 'industrial', 'railway', 'commercial', 'brownfield', 'landfill', 'greenfield', 'construction', 'wood') then landuse else null end)) as landuse,\n('leisure_' || (case when leisure in ('swimming_pool', 'playground', 'park', 'recreation_ground', 'common', 'garden', 'golf_course') 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','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",
"extent": "-20037508,-19929239,20037508,19929239",
"key_field": "",
"geometry_field": "",
Expand Down

0 comments on commit 34b1541

Please sign in to comment.