polylinie.de / tilecacheindex / Manual

Tilecacheindex tutorial

Steffen Macke

$Date: 2008-11-07 11:55:53 +0200 (Sun, 12 Oct 2008) $


Table of Contents

1. Introduction
2. Prerequisites
2.1. Tilecacheindex folder
2.2. UMN Mapserver
2.3. Perl
2.4. Map Tile Cacher
2.5. wget
2.6. Tilecacheindex
3. Download the tiles
3.1. Verify tile download
4. Create the tile index
5. Test the WMS server

1. Introduction

This document describes (step by step) how to use Map Tile Cacher, tilecacheindex and mapserver to create a Web Map Service (WMS) using tiles from various mapping services like OpenStreetMap or OpenAerialMap.

The tutorial assumes that you are using Windows. If you would like this tutorial to be extended with instructions for Linux, please contact the author.

OpenStreetMap data can be used freely under the terms of the Creative Commons Attribution-ShareAlike 2.0 license.

2. Prerequisites

Installation of required software.

2.1. Tilecacheindex folder

Create a folder c:\tilecacheindex folder to hold tilecacheindex installation and the tile cache.

2.2. UMN Mapserver

MS4W provides a conveniant way to install UMN Mapserver on Windows.

The installer can be downloaded from: http://www.maptools.org/ms4w/

Install to the default location.

2.3. Perl

The ActivePerl distribution is available on Windows:

http://activestate.com/Products/activeperl/

Install to the default location.

2.4. Map Tile Cacher

Map Tile Cacher is a Perl script that allows to download tiles from various mapping services like OpenStreetMap or OpenAerialMap. It is available from the Mobile GMaps project:

http://www.mgmaps.com/cache/MapTileCacher.perl

Save the script as c:\tilecacheindex\MapTileCacher.pl.

2.5. wget

Map Tile Cacher uses wget to download the tiles. The GnuWin32 provides a wget version for windows:

http://gnuwin32.sourceforge.net/packages/wget.htm

Download the complete package and install to c:\program files\gnuwin32.

2.6. Tilecacheindex

Tilecacheindex is available from polylinie.de:

http://polylinie.de/tilecacheindex/

Download the zip file and extract it to c:\tilecacheindex.

The zip file also contains a simple mapfile template, tilecacheindex.map.

3. Download the tiles

Open a commandline (cmd.exe).

Add the wget location to the PATH:

PATH=%PATH%;c:\program files\gnuwin32\bin

Change the working directory to c:\tilecacheindex.

cd \tilecacheindex

Start Map Tile Cacher:

MapTileCacher.pl

Being asked for the number of map tiles per file, enter 1:

1

Choose 1 as the hash size:

1

This example assumes that you are using OpenStreetMap. If you choose a different map type, you'll have to adjust the following commands accordingly.

OpenStreetMap

Choose a zoom level:

1

Enter the coordinates for which the tiles should be downloaded. This example downloads tiles for the whole world. Top left:

90,-180

Bottom right:

-90,180

Press enter.

3.1. Verify tile download

If everything went right, the following tiles should have been downloaded to c:\tilecacheindex\MGMapsCache\OpenStreetMap_1:

0_0.mgm
0_1.mgm
1_0.mgm
1_1.mgm
[Note]Note

These files are acutally PNG files. As mapserver has no problems to process these files, no effort is taken to rename them.

[Note]Note

The 1 at the end of the folder name is the zoom level.

4. Create the tile index

Run tilecacheindex:

cd \tilecacheindex
tilecacheindex MGMapsCache\OpenStreetMap_1 MGMapsCache\OpenStreetMap_1\tilecacheindex.shp

5. Test the WMS server

uDig can be used to test the WMS server: Start uDig, create a new map, add a new Web Map Server datasource to the map. Use the following URL:

http://localhost/cgi-bin/mapserv.exe?map=c:/tilecacheindex/tilecacheindex.map&

polylinie.de / tilecacheindex / Manual

Copyright 2007, 2008 Steffen Macke | Imprint