[OSM-dev] Availability of slippy map during LinuxTag 2007

Jon Burgess jburgess777 at googlemail.com
Mon May 28 18:29:09 BST 2007


On Mon, 2007-05-28 at 18:37 +0200, Joerg Ostertag (OSM Munich/Germany)
wrote:

> > Alternatively you could setup your own local tile server. It isn't too
> > hard to setup osm2pgsql/mapnik with either a rails server or tilecache.
> > I have these setup on my home PC and can give some hints if you get
> > stuck.
> 
> Sounds good. can you send me the hints on how to do it. Then I would try to 
> install it on the Notebook which we take to the Linux Tag tomorrow morning.
> 
> -

I think that using tilecache is the easiest and fastest way to render an
OSM based map on your machine. Below are the steps I used on my Fedora
machine, the file paths etc may be different in your setup.

There are dozens of steps where things can fall down. I can not give
complete details to cover every possible problem. The best thing is to
have a go and let me know if you get stuck.

You might want to start the 2 big downloads steps 13/14 first.

1) Download latest planet.bz2 file from http://planet.openstreetmap.org
(the .7z can also be used if you have 7za installed).

2) Download the 600MB shapefiles from
http://artem.dev.openstreetmap.org/files/world_boundaries.tar.bz2 
- you might already have a copy of these look for world_boundaries_m.shp
on your machine, there should be 26 files in total.

3) Install and run a web server on localhost

4) Place the attached tilecache.html file in your web root.

5) Make a /javascript directory in the web root and download the
OpenLayers.js into it:
$ wget -O OpenLayers23.js http://openlayers.org/api/2.3/OpenLayers.js

6) Download http://www.tilecache.org/tilecache-1.8.1.tar.gz 

7) mkdir  /var/www/wms-c and unpack the tilecache files into it

8) Place tilecache.conf in /etc/httpd/conf.d

9) Make sure you have mod_python installed (tilecache can run via CGI
but this is quite a bit slower).

10) Place the attached tilecache.cfg in /var/www/wms-c/tilecache.cfg

11) Check out the OSM svn tree (I use ~/osm/svn.openstreetmap.org)

Next we need mapnik, osm2pgsql, postgres & postgis setup. Details are at
http://wiki.openstreetmap.org/index.php/Mapnik . I've also listed them
separately below:

12) Compile mapnik (it should be part of the svn tree at
~/osm/svn.openstreetmap.org/applications/rendering/mapnik/mapnik.org

13) Compile osm2pgsql from
~/osm/svn.openstreetmap.org/applications/utils/export/osm2pgsql/
See the readme.txt for further help

14) copy osm2pgsql to ~/bin

15) Make sure you have postgres installed with a database called 'gis'
which has had the postgis extensions added (see the wiki page).

16) run osm2pgsql to import the planet file:
$ osm2pgsql ~/osm/planet/planet-070516.osm.bz2
or
$ 7za x -so ~/osm/planet/planet-070516.osm.7z | osm2pgsql

This should take around 10 - 30 minutes to import the planet file
depending on your hardware.

17) Update
~/osm/svn.openstreetmap.org/applications/rendering/mapnik/osm.xml with
your local file paths and Postgres connection parameters. I use the
convert script in that directory to make the changes:
$ ./convert osm.xml > osm-jb-merc.xml

18) Update the mapfile= line in /var/www/wms-c/tilecache.cfg to point to
your modified osm.xml file.

Restart web server. Cross fingers. Point web browser at
http://localhost/tilecache.html

If it fails, first check the apache error log. On Fedora I needed to
turn off the selinux protection to allow a the tilecache script to open
a socket to connect to the DB (setenforce 0).

	Jon

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openstreetmap.org/pipermail/dev/attachments/20070528/50a0a30b/attachment.html>
-------------- next part --------------
ScriptAlias /wms-c/ "/var/www/wms-c/"

<Directory /var/www/wms-c/>
     AddHandler python-program .py
     PythonHandler TileCache/Service 
     PythonOption TileCacheConfig /var/www/wms-c/tilecache.cfg
     PythonDebug On 
</Directory>

<Directory /var/www/html/pytest/> 
        AddHandler mod_python .py
        PythonHandler mptest
        PythonDebug On 
</Directory>

-------------- next part --------------
# Configuration for MC TileCache

# [cache] section (mandatory!)
# type=DiskCache    (works out of the box)
# base=<full path to cache directory>
# *or*
# type=MemoryCache  (you'll need memcache.py and memcached running!)
# servers=192.168.1.1:11211

[cache]
type=DiskCache
base=/tmp/tilecache

# [layername] -- all other sections are named layers
#
# type={MapServerLayer,WMSLayer} 
#   *** if you want to use MapServerLayer, you *must* have Python mapscript
#       installed and available ***
# 
# mapfile=<full path to map file>   *** only applies to MapServerLayer  ***
# url=<full URL of WMS>             *** only applies to WMSLayer        ***
# layers=<layer>[,<layer2>,<layer3>,...] 
#                                   *** optional iff layername if what
#                                       your data source calls the layer **
# extension={png,jpeg,gif}          *** defaults to "png"               ***
# size=256,256                      *** defaults to 256x256             ***
# bbox=-180.0,-90.0,180.0,90.0      *** defaults to world in lon/lat    ***
# srs=EPSG:4326                     *** defaults to EPSG:4326           ***
# levels=20                         *** defaults to 20 zoom levels      ***
# resolutions=0.1,0.05,0.025,...    *** defaults to global profile      ***
# metaTile=true                     *** metatiling off by default
#                                       requires python-imaging         ***
# metaSize=5,5                      *** size of metatile in tiles
#                                       defaults to 5 x 5               ***
# metaBuffer=10                     *** size of metatile buffer in px   ***

#[vmap0]
#type=MapServerLayer
#layers=vmap0
#mapfile=/var/www/vmap0.map

#[basic]
#type=WMSLayer
#url=http://labs.metacarta.com/wms/vmap0
#extension=png

#[mapnik]
#type=MapnikLayer
#mapfile=/var/www/cgi-bin/tilecache-1.2/osm-jb.xml

[osm-merc]
type=MapnikLayer
#mapfile=/var/www/cgi-bin/tilecache-1.2/osm-jb.xml
#mapfile=/home/jburgess/osm/svn.openstreetmap.org/applications/rendering/mapnik/osm-jb.xml
mapfile=/home/jburgess/osm/svn.openstreetmap.org/applications/rendering/mapnik/osm-jb-merc.xml
bbox=-20037508.34,-20037508.34,20037508.34,20037508.34
resolutions=156543.0,78271.5,39135.75,19567.875,9783.9375,4891.96875,2445.984375,1222.9921875,611.49609375,305.748046875,152.874023438,76.4370117188,38.2185058594,19.1092529297,9.55462646484,4.77731323242,2.38865661621,1.19432830811,0.597164154053,0.298582077026
srs=OSGEO:41001
metaTile=yes
metaBuffer=40


More information about the dev mailing list