Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Order placenames by population and substitute NE usage on low zoom level... #1461

Merged
merged 2 commits into from
Sep 16, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 0 additions & 14 deletions INSTALL.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,24 +28,11 @@ You can also download them manually at the following paths:
* [`land-polygon.shp`](http://data.openstreetmapdata.com/land-polygons-split-3857.zip) (updated daily)
* [`builtup_area.shp`](http://planet.openstreetmap.org/historical-shapefiles/world_boundaries-spherical.tgz)
* [`ne_110m_admin_0_boundary_lines_land.shp`](http://www.naturalearthdata.com/http//www.naturalearthdata.com/download/110m/cultural/ne_110m_admin_0_boundary_lines_land.zip)
* [`ne_10m_populated_places_fixed.shp`](http://www.naturalearthdata.com/http//www.naturalearthdata.com/download/10m/cultural/ne_10m_populated_places.zip) (and see [below](#populated-places-shapefile))

The repeated www.naturalearthdata.com in the Natural Earth shapefiles is correct.

Put these shapefiles at `path/to/openstreetmap-carto/data`.

### Populated places shapefile

The Natural Earth 2.0 populated places shapefile contains data that triggers a bug in mapnik. As
a workaround we run the shapefile through ogr2ogr to clean up the data. This is not required for
Mapnik 2.2 or later, where the shapefile can just be renamed.

```
ogr2ogr ne_10m_populated_places_fixed.shp ne_10m_populated_places.shp
```

See https://github.com/mapnik/mapnik/issues/1605 for more details.

## Fonts
The stylesheet depends on a number of openly licensed fonts for support of all the languages found on the map. The package which supplies these fonts on Ubuntu is indicated.

Expand Down Expand Up @@ -90,7 +77,6 @@ If you aren't using TileMill, you can compile the CartoCSS stylesheets into Mapn
* [osm2pgsql](http://wiki.openstreetmap.org/wiki/Osm2pgsql) to import your data into a PostGIS database
* [PostgreSQL](http://www.postgresql.org/)
* [PostGIS](http://postgis.org/)
* [ogr2ogr](http://www.gdal.org/) command line GDAL utility for processing vector data. here we use it to work around a encoding bug in the Nautral Earth data.
* curl, unzip for downloading and decompressing files
* shapeindex (a companion utility to Mapnik found in the mapnik-utils package) for indexing downloaded shapefiles

Expand Down
27 changes: 1 addition & 26 deletions get-shapefiles.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,10 @@ set -e -u
UNZIP_OPTS=-qqun

# create and populate data dir

mkdir -p data/
mkdir -p data/world_boundaries
mkdir -p data/simplified-land-polygons-complete-3857
mkdir -p data/ne_110m_admin_0_boundary_lines_land
mkdir -p data/ne_10m_populated_places
mkdir -p data/land-polygons-split-3857

# world_boundaries
Expand Down Expand Up @@ -41,18 +39,6 @@ unzip $UNZIP_OPTS data/ne_110m_admin_0_boundary_lines_land.zip \
ne_110m_admin_0_boundary_lines_land.dbf \
-d data/ne_110m_admin_0_boundary_lines_land/

# ne_10m_populated_places
echo "downloading ne_10m_populated_places..."
curl -z data/ne_10m_populated_places.zip -L -o data/ne_10m_populated_places.zip http://www.naturalearthdata.com/http//www.naturalearthdata.com/download/10m/cultural/ne_10m_populated_places.zip
echo "expanding ne_10m_populated_places..."
unzip $UNZIP_OPTS data/ne_10m_populated_places.zip \
ne_10m_populated_places.shp \
ne_10m_populated_places.shx \
ne_10m_populated_places.prj \
ne_10m_populated_places.dbf \
ne_10m_populated_places.cpg \
-d data/ne_10m_populated_places/

# land-polygons-split-3857
echo "downloading land-polygons-split-3857..."
curl -z "data/land-polygons-split-3857.zip" -L -o "data/land-polygons-split-3857.zip" "http://data.openstreetmapdata.com/land-polygons-split-3857.zip"
Expand Down Expand Up @@ -87,25 +73,14 @@ unzip $UNZIP_OPTS data/antarctica-icesheet-outlines-3857.zip \
antarctica-icesheet-outlines-3857/icesheet_outlines.dbf \
-d data/

#process populated places
echo "processing ne_10m_populated_places..."
rm -f data/ne_10m_populated_places/ne_10m_populated_places_fixed.*
ogr2ogr --config SHAPE_ENCODING UTF8 data/ne_10m_populated_places/ne_10m_populated_places_fixed.shp data/ne_10m_populated_places/ne_10m_populated_places.shp

#index
echo "indexing shapefiles"

shapeindex --shape_files \
data/simplified-land-polygons-complete-3857/simplified_land_polygons.shp \
data/land-polygons-split-3857/land_polygons.shp \
data/antarctica-icesheet-polygons-3857/icesheet_polygons.shp \
data/antarctica-icesheet-outlines-3857/icesheet_outlines.shp \
data/ne_10m_populated_places/ne_10m_populated_places_fixed.shp \
data/ne_110m_admin_0_boundary_lines_land/ne_110m_admin_0_boundary_lines_land.shp


#clean up
echo "cleaning up..."
rm data/ne_10m_populated_places/ne_10m_populated_places.*

#finish
echo "...done!"
64 changes: 39 additions & 25 deletions placenames.mss
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
@placenames: #222;
@placenames-light: #777777;

.country {
[admin_level = '2'][zoom >= 2][way_pixels > 3000][way_pixels < 196000] {
text-name: "[name]";
Expand Down Expand Up @@ -38,52 +39,65 @@
}
}

#placenames-capital {
[zoom >= 5][zoom < 15] {
text-name: "[name]";
text-size: 10;
text-fill: @placenames;
text-face-name: @book-fonts;
text-halo-radius: 1.5;
text-halo-fill: rgba(255,255,255,0.6);
text-wrap-width: 45;
text-min-distance: 10;
[zoom >= 6] {
text-size: 12;
text-wrap-width: 60;
}
[zoom >= 11] {
text-size: 15;
text-wrap-width: 75;
#placenames-medium::high-importance {
[category = 1][zoom < 14] {
[zoom >= 3][score >= 5000000],
[zoom >= 4][score >= 3000000],
[zoom >= 5][score >= 400000] {
text-name: "[name]";
text-size: 8;
text-fill: @placenames;
text-face-name: @book-fonts;
text-halo-radius: 1.5;
text-halo-fill: rgba(255,255,255,0.6);
text-wrap-width: 30;
text-min-distance: 10;
[zoom >= 5] {
text-size: 10;
text-wrap-width: 45;
}
[zoom >= 6] {
text-size: 12;
text-wrap-width: 60;
}
[zoom >= 11] {
text-size: 15;
text-wrap-width: 75;
}
}
}
}

#placenames-medium::city {
[place = 'city'] {
[zoom >= 6][zoom < 15] {
#placenames-medium::medium-importance {
[category = 1][score < 400000][zoom < 15] {
[zoom >= 6][score >= 70000],
[zoom >= 7] {
text-name: "[name]";
text-size: 9;
text-fill: @placenames;
text-face-name: @book-fonts;
text-halo-radius: 1.5;
text-halo-fill: rgba(255,255,255,0.6);
text-wrap-width: 45;
text-wrap-width: 30;
text-min-distance: 10;
[zoom >= 9] {
text-size: 12;
text-size: 11;
text-wrap-width: 60;
}
[zoom >= 11] {
text-size: 14;
text-wrap-width: 70;
}
[zoom >= 14] {
text-size: 15;
text-wrap-width: 75;
}
}
}
}

#placenames-medium::town {
[place = 'town'] {
#placenames-medium::low-importance {
[category = 2] {
[zoom >= 9][zoom < 16] {
text-name: "[name]";
text-size: 9;
Expand All @@ -103,7 +117,7 @@
}
[zoom >= 14] {
text-size: 15;
text-wrap-width: 75;
text-wrap-width: 70;
}
}
}
Expand Down
58 changes: 3 additions & 55 deletions project.mml
Original file line number Diff line number Diff line change
Expand Up @@ -1257,59 +1257,6 @@
},
"advanced": {}
},
{
"name": "nepopulated",
"srs-name": "WGS84",
"geometry": "point",
"class": "",
"id": "nepopulated",
"srs": "+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs",
"Datasource": {
"type": "shape",
"file": "data/ne_10m_populated_places/ne_10m_populated_places_fixed.shp",
"encoding": "windows-1252"
},
"extent": [
-180,
-85.05112877980659,
180,
85.05112877980659
],
"properties": {
"maxzoom": 4,
"minzoom": 3
},
"advanced": {
"encoding": "windows-1252"
}
},
{
"name": "placenames-capital",
"srs-name": "900913",
"geometry": "point",
"class": "",
"id": "placenames-capital",
"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,\n place,\n name,\n ref\n FROM planet_osm_point\n WHERE place IN ('city', 'town')\n AND capital IN ('yes', '4')\n AND name IS NOT NULL\n ORDER BY CASE\n WHEN place = 'city' THEN 1\n WHEN place = 'town' THEN 2\n END ASC\n) AS placenames_capital",
"geometry_field": "way",
"type": "postgis",
"key_field": "",
"dbname": "gis"
},
"extent": [
-180,
-85.05112877980659,
180,
85.05112877980659
],
"properties": {
"maxzoom": 14,
"minzoom": 5
},
"advanced": {}
},
{
"name": "placenames-medium",
"srs-name": "900913",
Expand All @@ -1319,7 +1266,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,\n place,\n name\n FROM planet_osm_point\n WHERE place IN ('city', 'town')\n AND (capital IS NULL OR capital NOT IN ('yes', '4'))\n AND name IS NOT NULL\n ORDER BY CASE\n WHEN place = 'city' THEN 1\n WHEN place = 'town' THEN 2\n END ASC\n) AS placenames_medium",
"table": "(SELECT\n way,\n name,\n score,\n CASE\n WHEN (place = 'city' OR (capital = 'yes' AND score >= 100000)) THEN 1\n ELSE 2\n END as category\n FROM \n (SELECT\n way,\n place,\n name,\n capital,\n (\n (CASE\n WHEN (population ~ '^[0-9]{1,8}$') THEN population::INTEGER\n WHEN (place = 'city') THEN 100000\n WHEN (place = 'town') THEN 1000\n ELSE 1\n END)\n *\n (CASE\n WHEN (capital = 'yes') THEN 3\n WHEN (capital = '4') THEN 2\n ELSE 1\n END)\n ) AS score\n FROM planet_osm_point\n WHERE place IN ('city', 'town')\n ) as p\n ORDER BY category ASC, score DESC\n) AS placenames_medium",
"geometry_field": "way",
"type": "postgis",
"key_field": "",
Expand All @@ -1332,7 +1279,8 @@
85.05112877980659
],
"properties": {
"minzoom": 6
"maxzoom": 15,
"minzoom": 3
},
"advanced": {}
},
Expand Down
83 changes: 32 additions & 51 deletions project.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1447,46 +1447,6 @@ Layer:
properties:
minzoom: 2
advanced: {}
- id: "nepopulated"
name: "nepopulated"
class: ""
geometry: "point"
<<: *extents84
Datasource:
file: "data/ne_10m_populated_places/ne_10m_populated_places_fixed.shp"
type: "shape"
encoding: "windows-1252"
properties:
minzoom: 3
maxzoom: 4
advanced:
encoding: "windows-1252"
- id: "placenames-capital"
name: "placenames-capital"
class: ""
geometry: "point"
<<: *extents
Datasource:
<<: *osm2pgsql
table: |-
(SELECT
way,
place,
name,
ref
FROM planet_osm_point
WHERE place IN ('city', 'town')
AND capital IN ('yes', '4')
AND name IS NOT NULL
ORDER BY CASE
WHEN place = 'city' THEN 1
WHEN place = 'town' THEN 2
END ASC
) AS placenames_capital
properties:
minzoom: 5
maxzoom: 14
advanced: {}
- id: "placenames-medium"
name: "placenames-medium"
class: ""
Expand All @@ -1497,19 +1457,40 @@ Layer:
table: |-
(SELECT
way,
place,
name
FROM planet_osm_point
WHERE place IN ('city', 'town')
AND (capital IS NULL OR capital NOT IN ('yes', '4'))
AND name IS NOT NULL
ORDER BY CASE
WHEN place = 'city' THEN 1
WHEN place = 'town' THEN 2
END ASC
name,
score,
CASE
WHEN (place = 'city' OR (capital = 'yes' AND score >= 100000)) THEN 1
ELSE 2
END as category
FROM
(SELECT
way,
place,
name,
capital,
(
(CASE
WHEN (population ~ '^[0-9]{1,8}$') THEN population::INTEGER
WHEN (place = 'city') THEN 100000
WHEN (place = 'town') THEN 1000
ELSE 1
END)
*
(CASE
WHEN (capital = 'yes') THEN 3
WHEN (capital = '4') THEN 2
ELSE 1
END)
) AS score
FROM planet_osm_point
WHERE place IN ('city', 'town')
) as p
ORDER BY category ASC, score DESC
) AS placenames_medium
properties:
minzoom: 6
minzoom: 3
maxzoom: 15
advanced: {}
- id: "placenames-small"
name: "placenames-small"
Expand Down
14 changes: 0 additions & 14 deletions shapefiles.mss
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,6 @@
}
}

#nepopulated {
[zoom >= 3][zoom < 5] {
[SCALERANK = 0],
[SCALERANK = 1] {
text-name: "[NAME]";
text-size: 8;
text-fill: grey;
text-face-name: @book-fonts;
text-halo-radius: 1;
text-halo-fill: rgba(255,255,255,0.6);
}
}
}

#world {
[zoom >= 0][zoom < 10] {
polygon-fill: @land-color;
Expand Down