Skip to content

Commit

Permalink
Use pixel area as a rendering decision for various areas.
Browse files Browse the repository at this point in the history
  • Loading branch information
asciipip committed Sep 10, 2015
1 parent 009bd3e commit ef0dea0
Show file tree
Hide file tree
Showing 5 changed files with 50 additions and 56 deletions.
39 changes: 13 additions & 26 deletions carto/features_borders.mss
Original file line number Diff line number Diff line change
@@ -1,37 +1,24 @@
#nature-borders {
[zoom >= 7][zoom < 10][way_area > 50000000] {
polygon-fill: @naturecolorlight;
polygon-opacity: 0.05;
#protected-land {
polygon-fill: @naturecolorlight;
polygon-opacity: 0.05;
[zoom >= 7] {
line-color: @naturecolorlight;
line-opacity: 0.7;
}
[zoom >= 7][zoom < 10] {
line-width: 1;
line-offset: -0.5;
line-dasharray: 5,2;
line-opacity: 0.7;
}
[zoom >= 10][zoom < 12][way_area > 10000000] {
polygon-fill: @naturecolorlight;
polygon-opacity: 0.05;
line-color: @naturecolorlight;
[zoom >= 10][zoom < 12] {
line-width: 1.8;
line-offset: -0.9;
line-dasharray: 7,3;
line-opacity: 0.7;
}

/*
* High zoom: Outline large areas, shade small areas.
* This is a workaround for the fact that some large areas,
* like some national parks, are just tagged as 'park'.
*/
[zoom >= 12] {
[way_area > 5000000] {
line-color: @naturecolorlight;
line-width: 3;
line-dasharray: 8,3;
line-opacity: 0.7;
}
[way_area <= 5000000] {
polygon-fill: @naturecolorlight;
polygon-opacity: 0.1;
}
line-width: 3;
line-offset: -1.5;
line-dasharray: 8,3;
}
}

Expand Down
16 changes: 8 additions & 8 deletions carto/features_labels.mml
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
"Datasource": {
"type": "postgis",
"dbname": "osm",
"table": "(SELECT way, name, coalesce('natural_' || \"natural\", 'aeroway_' || aeroway, 'railway_' || railway, 'landuse_' || landuse, 'leisure_' || leisure, 'amenity_' || amenity, 'boundary_' || boundary) AS feature, way_area, 0 AS ele_w_unit FROM planet_osm_polygon WHERE name IS NOT NULL ORDER BY z_order, way_area DESC) AS featurenames",
"table": "(SELECT way, name, coalesce('natural_' || \"natural\", 'aeroway_' || aeroway, 'railway_' || railway, 'landuse_' || landuse, 'leisure_' || leisure, 'amenity_' || amenity, 'boundary_' || boundary) AS feature, way_area, way_area / (!pixel_width!*!pixel_height!) AS way_area_pixels, 0 AS ele_w_unit FROM planet_osm_polygon WHERE name IS NOT NULL ORDER BY z_order, way_area DESC) AS featurenames",
"extent": "-20037508,-19929239,20037508,19929239"
}
},
Expand All @@ -63,7 +63,7 @@
"Datasource": {
"type": "postgis",
"dbname": "osm",
"table": "(SELECT way, name, coalesce('natural_' || \"natural\", 'aeroway_' || aeroway, 'railway_' || railway, 'landuse_' || landuse, 'leisure_' || leisure, 'amenity_' || amenity, 'boundary_' || boundary) AS feature, 0 AS way_area, (CASE WHEN ele LIKE '%m' THEN substr(ele, 0, length(ele)-1) ELSE ele END) || ' m' as ele_w_unit FROM planet_osm_point WHERE name IS NOT NULL OR ele IS NOT NULL ORDER BY z_order, way_area DESC) AS featurenames",
"table": "(SELECT way, name, coalesce('natural_' || \"natural\", 'aeroway_' || aeroway, 'railway_' || railway, 'landuse_' || landuse, 'leisure_' || leisure, 'amenity_' || amenity, 'boundary_' || boundary) AS feature, 0 AS way_area, 0 AS way_area_pixels, (CASE WHEN ele LIKE '%m' THEN substr(ele, 0, length(ele)-1) ELSE ele END) || ' m' as ele_w_unit FROM planet_osm_point WHERE name IS NOT NULL OR ele IS NOT NULL ORDER BY z_order, way_area DESC) AS featurenames",
"extent": "-20037508,-19929239,20037508,19929239"
}
},
Expand Down Expand Up @@ -124,24 +124,24 @@
}
},
{
"id": "water-line-names",
"name": "water-line-names",
"id": "water-area-names",
"name": "water-area-names",
"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": {
"type": "postgis",
"dbname": "osm",
"table": "(SELECT way, waterway, disused, name, ST_Length(way) length FROM planet_osm_line WHERE waterway IS NOT NULL AND name IS NOT NULL ORDER BY z_order, length DESC) AS water_lines",
"table": "(SELECT way, waterway, landuse, \"natural\", name, way_area, way_area / (!pixel_width!*!pixel_height!) AS way_area_pixels FROM planet_osm_polygon WHERE (landuse IN ('reservoir', 'basin') OR \"natural\" IN ('water', 'wetland', 'glacier')) AND name IS NOT NULL ORDER BY way_area DESC) AS water_areas",
"extent": "-20037508,-19929239,20037508,19929239"
}
},
{
"id": "water-area-names",
"name": "water-area-names",
"id": "water-line-names",
"name": "water-line-names",
"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": {
"type": "postgis",
"dbname": "osm",
"table": "(SELECT way, waterway, landuse, \"natural\", name, way_area FROM planet_osm_polygon WHERE (landuse IN ('reservoir', 'basin') OR \"natural\" IN ('water', 'wetland', 'glacier')) AND name IS NOT NULL ORDER BY way_area DESC) AS water_areas",
"table": "(SELECT way, waterway, disused, name, ST_Length(way) length FROM planet_osm_line WHERE waterway IS NOT NULL AND name IS NOT NULL ORDER BY z_order, length DESC) AS water_lines",
"extent": "-20037508,-19929239,20037508,19929239"
}
},
Expand Down
30 changes: 18 additions & 12 deletions carto/features_labels.mss
Original file line number Diff line number Diff line change
Expand Up @@ -225,16 +225,21 @@ Map {
#water-area-names {
[natural = 'water'][waterway != 'riverbank'],
[landuse = 'reservoir'][waterway != 'riverbank'] {
[zoom >= 10][zoom < 12][way_area > 4000000],
[zoom >= 12][zoom < 14][way_area > 1000000],
[zoom >= 8][way_area_pixels >= 128],
[zoom >= 14] {
text-name: [name];
text-face-name: @oblique-fonts;
text-fill: @waterlinecolor;
text-halo-radius: @haloradius;
text-halo-fill: @halocolor;
text-size: 10;
[zoom >= 14] { text-size: 11; }
text-placement: interior;
text-wrap-width: 128;
text-size: 9;
[zoom >= 14],
[way_area_pixels > 256] { text-size: 10; }
[way_area_pixels > 4096] { text-size: 12; }
[way_area_pixels > 65536] { text-size: 14; }
[way_area_pixels > 1048576] { text-size: 16; }
}
}
}
Expand Down Expand Up @@ -296,20 +301,21 @@ Map {
[feature = 'leisure_recreation_ground'],
[feature = 'landuse_village_green'],
[feature = 'landuse_allotments'] {
[zoom >= 8][zoom < 10][way_area > 50000000],
[zoom >= 10][zoom < 12][way_area > 5000000],
[zoom >= 12][zoom < 14][way_area > 200000],
[zoom >= 8][way_area_pixels >= 128],
[zoom >= 14] {
text-name: [name];
text-face-name: @oblique-fonts;
text-wrap-width: 20;
text-placement: interior;
text-wrap-width: 64;
text-ratio: 50%;
text-fill: @naturecolortext;
text-halo-fill: @halocolor;
text-halo-radius: @haloradius;
text-size: 12;
[zoom >= 8][zoom < 10] { text-size: 9; }
[zoom >= 10][zoom < 12] { text-size: 10; }
[zoom >= 12][zoom < 14] { text-size: 11; }
text-size: 9;
[way_area_pixels > 256] { text-size: 10; }
[way_area_pixels > 4096] { text-size: 12; }
[way_area_pixels > 65536] { text-size: 14; }
[way_area_pixels > 1048576] { text-size: 16; }
}
}

Expand Down
6 changes: 3 additions & 3 deletions carto/features_mask.mml
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
"Datasource": {
"type": "postgis",
"dbname": "osm",
"table": "(SELECT way, name, coalesce('natural_' || \"natural\", 'aeroway_' || aeroway, 'railway_' || railway, 'landuse_' || landuse, 'leisure_' || leisure, 'amenity_' || amenity, 'boundary_' || boundary) AS feature, way_area, 0 AS ele_w_unit FROM planet_osm_polygon WHERE name IS NOT NULL ORDER BY z_order, way_area DESC) AS featurenames",
"table": "(SELECT way, name, coalesce('natural_' || \"natural\", 'aeroway_' || aeroway, 'railway_' || railway, 'landuse_' || landuse, 'leisure_' || leisure, 'amenity_' || amenity, 'boundary_' || boundary) AS feature, way_area, way_area / (!pixel_width!*!pixel_height!) AS way_area_pixels, 0 AS ele_w_unit FROM planet_osm_polygon WHERE name IS NOT NULL ORDER BY z_order, way_area DESC) AS featurenames",
"extent": "-20037508,-19929239,20037508,19929239"
}
},
Expand All @@ -63,7 +63,7 @@
"Datasource": {
"type": "postgis",
"dbname": "osm",
"table": "(SELECT way, name, coalesce('natural_' || \"natural\", 'aeroway_' || aeroway, 'railway_' || railway, 'landuse_' || landuse, 'leisure_' || leisure, 'amenity_' || amenity, 'boundary_' || boundary) AS feature, 0 AS way_area, (CASE WHEN ele LIKE '%m' THEN substr(ele, 0, length(ele)-1) ELSE ele END) || ' m' as ele_w_unit FROM planet_osm_point WHERE name IS NOT NULL OR ele IS NOT NULL ORDER BY z_order, way_area DESC) AS featurenames",
"table": "(SELECT way, name, coalesce('natural_' || \"natural\", 'aeroway_' || aeroway, 'railway_' || railway, 'landuse_' || landuse, 'leisure_' || leisure, 'amenity_' || amenity, 'boundary_' || boundary) AS feature, 0 AS way_area, 0 AS way_area_pixels, (CASE WHEN ele LIKE '%m' THEN substr(ele, 0, length(ele)-1) ELSE ele END) || ' m' as ele_w_unit FROM planet_osm_point WHERE name IS NOT NULL OR ele IS NOT NULL ORDER BY z_order, way_area DESC) AS featurenames",
"extent": "-20037508,-19929239,20037508,19929239"
}
},
Expand Down Expand Up @@ -141,7 +141,7 @@
"Datasource": {
"type": "postgis",
"dbname": "osm",
"table": "(SELECT way, waterway, landuse, \"natural\", name, way_area FROM planet_osm_polygon WHERE (landuse IN ('reservoir', 'basin') OR \"natural\" IN ('water', 'wetland', 'glacier')) AND name IS NOT NULL ORDER BY way_area DESC) AS water_areas",
"table": "(SELECT way, waterway, landuse, \"natural\", name, way_area, way_area / (!pixel_width!*!pixel_height!) AS way_area_pixels FROM planet_osm_polygon WHERE (landuse IN ('reservoir', 'basin') OR \"natural\" IN ('water', 'wetland', 'glacier')) AND name IS NOT NULL ORDER BY way_area DESC) AS water_areas",
"extent": "-20037508,-19929239,20037508,19929239"
}
}
Expand Down
15 changes: 8 additions & 7 deletions carto/features_outlines.mml
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
85.05112877980659
],
"center": [
0,
0,
4
-76.62,
39.34,
12
],
"format": "png",
"interactivity": false,
Expand Down Expand Up @@ -115,6 +115,7 @@
"id": "ocean",
"name": "ocean",
"Datasource": {
"type": "shape",
"file": "/home/mapnik/world_boundaries/water-polygons-split-3857/water_polygons.shp"
},
"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"
Expand Down Expand Up @@ -273,13 +274,13 @@
}
},
{
"id": "nature-borders",
"name": "nature-borders",
"id": "protected-land",
"name": "protected-land",
"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": {
"type": "postgis",
"dbname": "osm",
"table": "(SELECT way, way_area, name, boundary, \"natural\" FROM planet_osm_polygon WHERE boundary='national_park' OR leisure IN ('park', 'nature_reserve', 'common', 'playground', 'garden', 'golf_course', 'recreation_ground') OR landuse IN ('forest', 'vineyard', 'conservation', 'recreation_ground', 'village_green', 'allotments') OR \"natural\" IN ('wood')) AS areas",
"table": "(SELECT way, way_area / (!pixel_width!*!pixel_height!) AS way_area_pixels FROM planet_osm_polygon WHERE (boundary='national_park' OR leisure IN ('park', 'nature_reserve', 'golf_course', 'recreation_ground') OR landuse IN ('conservation', 'recreation_ground')) AND way_area / (!pixel_width!*!pixel_height!) > 64) AS areas",
"extent": "-20037508,-19929239,20037508,19929239"
}
},
Expand Down Expand Up @@ -397,7 +398,7 @@
}
],
"scale": 1,
"metatile": 2,
"metatile": 4,
"name": "TopOSM Feature Outlines",
"description": "Feature outline layer for TopOSM."
}

0 comments on commit ef0dea0

Please sign in to comment.