This repository contains:
maps-ox/
: source files for map tiles (i.e. stylesheets)data/
: GeoJSON files containing transformed OxPoints datapuppet/
: puppet files to provision a VM exposing TileMillVagrantfile
to start a local VM using VagrantAs of August 2016, the tilemill server wasn't operational and attempts to restore it haven't been successful. Instead, the following method can be used to generate the map tiles manually on a local machine (OSX/Ubuntu).
Install tilemill: https://github.com/tilemill-project/tilemill
Copy the maps-ox folder from the root of this repository to ~/Documents/MapBox/project. Tilemill will then recognise it as a project.
Download the following .zip files:
These zip files are among several Datasources in maps-ox/project.mml, which defines the tilemill project. You will need to edit the filepaths in these datasources to point correctly to the zip files (note: somewhere the user you run tilemill as can access).
Run Docker container for postgis database from the root of this project
docker-compose up
Trigger osm import to postgis database
docker exec -it mapstiles_pg_1 /bin/bash /srv/fetch_osm.sh
Enter password 'docker' when prompted
Modify project.mml to amend connection details for each gis Datasource as follows. If "docker-default" doesn't work as a host value then use the IP address of the docker container mapstiles_pg_1 (or localhost on a Mac).
"dbname": "gis",
"host": "docker-default",
"port": "5432",
"user": "docker",
"password": "docker",
Open project in tilemill
If necessary amend pg_hba.conf to allow incoming connections from tilemill. The docker container output will show an error if this is needed.
At this point the map should show up with appropriate appearance and labels etc. The tiles can be exported according to the instructions below.
Run vagrant up
from the root of the repository. You can access TileMill at http://localhost:8088 (port forwarded).
You should run fab vm init
the first time to setup some permissions on filestystem and database for the user vagrant.
TileMill UI is served on port 80, tiles are served on port 8080.
To run Fabric commands you need to set up two environment variables:
MAPS_HOST
(hostname of the server to SSH)MAPS_USER
(your user name on the server).Use the following syntax to set an environment variable:
export NAME=VALUE
It is using HTTP Basic Auth, default username/password are: user
/ pass
.
Once logged-in to the server, you should add your .gitconfig
to the root of your user directory.
Also run the following Fabric command to "attach" your user to PostGIS:
fab server init
You need Fabric to run commands on the server (using a virtualenv, it is recommended to pip install -r requirements.txt
).
Run the following command to download the latest dump from OpenStreetMap and populate PostGIS with it:
fab server update_osm
Important note: the script will ask for your password, and it is expected that you have sudo
access to the machine. See fabfile.py
for more information.
Follow the process in the directory data/
and make sure that you commit and push
the updated GeoJSON files.
SSH into the Tilemill server and go to the git repository at /srv/tilemill/maps-tiles
,
make sure you are on the correct branch and fetch the latest changes (git pull
).
After having done some changes, you should run the following command to copy the project files from the workspace (TileMill) to the git repository:
fab server tilemill_to_git
Using SSH, navigate to /srv/tilemill/maps-tiles
to navigate to the git repository; you can now use all the git commands (i.e. commit
, branch
etc)
You will notice fairly quickly that you will need to enter your username/password quite often when doing git push
and git pull
, that is because
we are using HTTPS, various techniques exist to reduce this issue: https://stackoverflow.com/questions/5343068/is-there-a-way-to-skip-password-typing-when-using-https-github
Use the web interface to export in MBTiles
format. Default parameters are fine.
Once the export is done ("process exited"...), go to /usr/share/mapbox/export
and
scp
the most recent maps-ox.mbtiles
file (which can be suffixed with a random string
if there are multiple exports) to your machine. For example:
scp myusername@tilemill.mydomain:/usr/share/mapbox/export/maps-ox.mbtiles .
Deploying the tiles to a server is done by running the Fabric command:
fab tiles deploy_tiles:/local/path/to.mbtiles
It expects en environment variable TILES_HOST
containing host:port
, your public SSH key should have been deployed to /srv/tiles/.ssh/authorized_keys
first.
It can be easier to do this process manually now with the following steps:
scp ./local-tiles.mbtiles tiles@maps-tiles.oucs.ox.ac.uk:/srv/tiles/tiles.mbtiles
ssh mapstiles@129.67.241.175
mb-util /srv/tiles/tiles.mbtiles /srv/tiles/tiles-YYYYMMHHMM
rm -f /srv/tiles/www
ln -s /srv/tiles/tiles-YYYYMMHHMM /srv/tiles/www
Here's a list of similar projects to run TileMill on a server: