Tile Server (2014)
The Planimate Map object enables the use of tiled map data in models. These notes describe the setup of a map tile web server which can be used with Planimate or other open Street Maps projects.
This is an update to the 2012 Tile Server Guide, which is now obsolete. The references section contains sources from which this content was derived.
Setting up the VM
Start with Ubuntu 12.04 Server (AMD 64). I used the server ISO image. My initial VM settings: 3GB of RAM, 32GB HDD and bridged networking. I did the most basic install.
For the Australia region only, you can probably get by with 20GB HDD. For the world, you'd need over 1TB.
I gave the VM plenty of RAM for the osm2pgsl import stage (see below). Since then I've shrunk the VM's RAM configuration to 1GB which is more than plenty for a small scale test server.
Login at the console to finish initial setup, you want to lock down its IP address. ('ifconfig' gives you current). Edit /etc/network/interfaces, substituting your network details.
sudo apt-get install vim openssh-server sudo vim /etc/network/interfaces iface eth0 inet static address 192.168.0.18 netmask 255.255.255.0 gateway 192.168.0.100
After this execute
sudo ifdown eth0; ifup eth0
Install some basic tools
sudo apt-get install ssh vim
You can now use a terminal like PuTTY to log in.
At this time you might like to edit /etc/hostname and /etc/hosts to give your tile server a name. I called mine 'maps'. From other machines, I referred to it by ip-address.
You will need to fully update the server
sudo apt-get update sudo apt-get dist-upgrade
Setting Up The Environment
Install the required tools to support the OSM and web services.
sudo apt-get install python-software-properties sudo add-apt-repository ppa:kakrueger/openstreetmap sudo apt-get update sudo apt-get install libapache2-mod-tile
NOTE: During this you will be prompted for some information. Keep the default values unless you know what you are doing.
NOTE: One of the prompts will be to provide access to the postgresql database. Add your user account name when prompted.
Download and import the OSM data
You will need to download an OSM dataset. A list of options can be found here http://download.geofabrik.de/
The instructions below are for the Australia/Oceania region
wget http://download.geofabrik.de/australia-oceania-latest.osm.pbf osm2pgsql --slim -C 1500 --number-processes 4 australia-oceania-latest.osm.pbf
This will take some time to complete. After it has completed run the following command to restart the tile rendering service.
sudo /etc/init.d/renderd restart
Edit the default website
By default the included HTML file defaults to the localhost. You will need to edit this so that the images can be loaded using relative references.
sudo vim /var/www/osm/slippymap.html
Remove the text http://localhost
You can also edit the default co-ordinates used so the by default map centers on a location relevant to you.
Edit the lat, long & zoom values appropriately. The values below will center the map on the middle of Australia.
var lat=-26.30; var lon=134.30; var zoom=5;
You can now point your browser to the map server.
Adding Custom Shape Files
WARNING This bit is currently untested WARNING
Export the shape files to somewhere accessible by mapnik (/etc/mapnik-osmdata/inc) ??
no idea where this is in the new setup.
Add appropriate style rules and layers to the map xml data file (/etc/mapnik-osmdata/inc/my_osm.xml.inc)
?? this path is best guess estimate
<Style name="BerthStyle"> <Rule> <LineSymbolizer> <CssParameter name="stroke">#000000</CssParameter> <CssParameter name="stroke-width">0.4</CssParameter> </LineSymbolizer> </Rule> <Rule> <TextSymbolizer name="name" fontset_name="book-fonts" size="10" fill="rgb(0,0,51)" halo_radius="1" wrap_width="20"></TextSymbolizer> </Rule> <Rule> <PolygonSymbolizer> <CssParameter name="fill">#404040</CssParameter> <CssParameter name="fill-opacity">0.6</CssParameter> </PolygonSymbolizer> </Rule> </Style> <Layer name="geelong-berths-line" srs="+proj=latlong +datum=WGS84"> <StyleName>BerthStyle</StyleName> <Datasource> <Parameter name="file">/home/username/bin/mapnik/geelong/BERTHS/BERTHS_line</Parameter> <Parameter name="type">shape</Parameter> </Datasource> </Layer>
Restart renderd and view the map.
There is some useful information available here which relates to different geo spatial reference systems. To ensure everything will work correctly with OSM then it is best to have the data referenced using the WGS84 datum.
This guide was originally based on material from here.
Thanks to the author of this guide and to kakrueger for maintaining the repository.