Getting a customized tileset built: hcmc-plain
We started work with a standard checkout of OSM Bright, and we worked against the model of openstreemap-carto-common/style.xml, which we have already successfully used to build tiles. OSM Bright itself cannot be compiled with the carto tool, because it's missing key information.
The sample project is in /home/mholmes/WorkData/maps/osm-bright/hcmc-plain/
on my machine.
First of all, we edited two of the four .mss files, base.mss and palette.mss, renaming them. In this process, we simply commented out a lot of the content, since we're aiming for a land/water/nothing else view. The other two mss files were ignored.
Next, we copied osm-bright.osm2pgsql.mml to hcmc-plain.osm2pgsql.mml, and began editing it. This is the file which is compiled using carto to create the XML styles file which is used by the tile builder. There was a lot to learn:
- The osm-bright version we were starting from was broken because it was missing a style attribute required on the two Datasource objects:
"type": "shape",
. Without this, carto fails to process the resulting XML. In this example file, it's on the two initial Datasource elements, which are based on shape files which are downloaded (see previous post). - The files in osm-bright/res and osm-bright/img need to be in the same place relative to the .xml styles file you create, so the simplest thing is to place those folders alongside the .xml file when building the tiles.
- The shape file data needs to be accessible and linked from the .xml file. Since that data is in /usr/share/openstreetmap-carto-common/data on the maptiler server, we simply created a symlink from "data" in the tile-generation location to that folder, and made the link a local one in the mml file ("file": "data/simplified-land-polygons-complete-3857/simplified_land_polygons.shp").
- The default name for the database in the mml file is "osm"; on my maptiler server, it's "gis", so that needed to be changed:
"dbname": "gis"
in 28 places. - Most layers in the mml file have "status": "on" by default; we turned most of them off, sometimes adding the status attribute when it was missing.
Then we compiled the mml file using carto:
carto hcmc-plain.osm2pgsql.mml > hcmc-plain.xml
Then we copied that file (along with img and res folders) up to the maptiler server, configured generate_tiles.py, and ran it.
