How to make your own maps/tiles

This wiki here describes how to render osm based vector planet.osm files to raster images. Please note we will use china.osm (which is a cut down version of planet.osm) for this wiki, as planet.osm is too huge for everything to be done in a timely manner.

Mapnik on Ubuntu

on ubuntu 12.04 do:

sudo apt-get install -y python-software-properties
sudo add-apt-repository -y ppa:mapnik/v2.0.2
sudo apt-get update && sudo apt-get -y install libmapnik mapnik-utils python-mapnik

Postgis Installation Guide

http://wiki.openstreetmap.org/wiki/Mapnik/PostGIS

on ubuntu 12.04 do: (addc2h2as the user andchinaas the database)

sudo apt-get install -y postgresql-9.1-postgis postgresql-contrib-9.1
sudo -u postgres -i -H
createuser -SdR c2h2
createdb -E UTF8 -O c2h2 china
psql -d china -f /usr/share/postgresql/9.1/contrib/postgis-1.5/postgis.sql
psql -d china -f /usr/share/postgresql/9.1/contrib/postgis-1.5/spatial_ref_sys.sql

psql china -c "ALTER TABLE geometry_columns OWNER TO c2h2"
psql china -c "ALTER TABLE spatial_ref_sys OWNER TO c2h2"
exit  

edit postgres ACL: (changemd5->trustfor local)

sudo vim /etc/postgresql/9.1/main/pg_hba.conf 
sudo /etc/init.d/postgresql restart 

Install osm2pgsql (the osm -> postgis converting tool)

Strongly recommand to install by using this ppa repo:

sudo add-apt-repository -y ppa:kakrueger/openstreetmap
sudo apt-get update && sudo apt-get install -y osm2pgsql

native apt-get is doable but might have some problems + bugs: (not suggested using below)

fix osm2pgsql bug: (according to:http://lists.openstreetmap.org/pipermail/dev/2011-June/022995.html)

sudo  cp /usr/share/osm2pgsql/default.style /usr/share/

Load maps into postgis

on ubuntu 12.04 do: (note this gonna dl 70mb~ file and take approx 10min to import into postgis)

wget http://download.geofabrik.de/osm/asia/china.osm.pbf && osm2pgsql -d china -U c2h2 --slim -C 2000 china.osm.pbf

Render our tiles with mapnik + python

Now we generate our tiles with 4 theads:

Clone our git: (copied fromhttp://svn.openstreetmap.org/applications/rendering/mapnik/)

git clone git@piza.cc:ntmaps.git
cd ntmaps/mapnik-render
./get-coastlines-192.168.8.25.sh
python generate_xml.py osm.xml c2h2_china.xml  --password '' --host 'localhost' --user 'c2h2' --dbname 'china' --port '5432'
python gen_china_multi.py c2h2_china.xml

wait .... and done!

Other rendering map/tiles

Tile Server Guide (this is AIO package, and not very well tested by author of this wiki)

You will want this if you are building a tile server in one go.

http://switch2osm.org/serving-tiles/building-a-tile-server-from-packages/

Tilestache Guide

https://github.com/migurski/TileStache

guide to install deps:http://obroll.com/install-python-pil-python-image-library-on-ubuntu-11-10-oneiric/

git clone https://github.com/migurski/TileStache.git
sudo apt-get install libjpeg8 libjpeg62-dev libfreetype6 libfreetype6-dev python2.7-dev
sudo ln -s /usr/lib/x86_64-linux-gnu/libjpeg.so /usr/lib
sudo ln -s /usr/lib/x86_64-linux-gnu/libfreetype.so /usr/lib
sudo ln -s /usr/lib/x86_64-linux-gnu/libz.so /usr/lib
sudo pip install -U PIL modestmaps simplejson werkzeug
cd TileStashe
python scripts/tilestache-server.py

If you still have problem with PIL

wget http://effbot.org/downloads/Imaging-1.1.7.tar.gz
cd Imaging-1.1.7 && python setup.py

Other Map Sources (cut down versions)

Good Reading Sources + Refs

Other Postgress FAQ

TO-READ

你可能感兴趣的:(tiles)