Notes and scripts used to generate vector map tiles for Ireland and to serve them. Based on OpenMapTiles, TileServer-GL
The aim was to be able to serve a map displaying all place names in Irish by default. To get started I first needed to generate a vector tileset for Ireland. I used OpenMapTiles for this. OpenMapTiles is a freely-licensed project by the folks at MapTiler and they were kind enough to guide me when I got stuck.
Clone the repo
git clone https://github.com/openmaptiles/openmaptiles.git
cd openmaptiles
Edit the env variables. The only change I made was to set the max zoom to 17. An example .env
file is included in this repo.
vi .env
Clean up if you have done any steps previously. I needed to do this as it took me several tries to get things right.
make remove-docker-images
Start the docker containers (creates the build, cache and data dirs):
make start-db
Download and import OSM data into the Posgres docker container:
make import-data
Download Ireland PBF file from geofabrik (thereby creating /tileset/data/ireland-and-northern-ireland.osm.pbf
):
make download area="ireland-and-northern-ireland"
Download the OSM data for Ireland and save into Postgres (this creates the mapping.yaml
file):
make import-osm area=ireland-and-northern-ireland
Add extra data from wiki commons:
make import-wikidata area=ireland-and-northern-ireland
Amend the mapping.yaml
file changing any name:de
fields to name:ga
. An example mapping.yaml file with these changes is included in this repo.
vi build/mapping.yaml
Then generate the tiles:
make import-sql
make build-style
make generate-bbox-file area=ireland-and-northern-ireland
make generate-tiles-pg
Generating tiles can take some time and I left this running overnight. After it has finished you should see summary of tile counts.
Examine the contents of the folder and you should find files you will need for the next step. Specifically the data folder and build/styles folder.
I created a new folder for serving the files and copied the files I needed into it. You could use the same folder though.
cd ..
mkdir tileserver
cp openmaptiles/data/* ./tileserver
cd ./tileserver
mkdir {fonts,styles}
mkdir styles/ga
cp ../openmaptiles/build/style/* ./styles/ga
The generated tiles file for Ireland is approx 390 MB in size.
The style.json
file generated by OpenMapTiles uses the English language as the default for labels on map elements such as towns and roads. To override that I amended the style.json
file changing the text-field
lines to use name:ga
as illustrated in the example below (and also shown in the style.json
file in this repo)
e.g.
from
"text-field": "{name:latin}\n{name:nonlatin}",
to
"text-field": "{name:ga}\n{name:nonlatin}",`
TileServer-GL needs a config.json
file with parameters for the location of the tiles and the styles you want to use. An example config.json
is included in this repo with the parameters I used. This could be improved. I kept the tiles file in the root directory.
Serve the files with TileServer:
docker run --rm -it -v $(pwd):/data -p 8080:8080 maptiler/tileserver-gl6
Visit the TileServer UI at: http://127.0.0.1:8080 Visit the map at: http://127.0.0.1:8080/styles/ga
## Improvements Further improvements could be made including:
- Add attributions
- Removing state borders (style.json boundary_2 visibility: none)
- Add AEDs
- Improve colouring on scrub land-use
- Add more street names in Irish
- Embed in main website