generate-tiles Command

Contents

Generates map tiles which can be used by a web map server. As opposed to generate-mbtiles Command, this command generates each tile as a separate image file on the disk. The tiles are generated using the scheme compatible with OpenLayers and OpenStreetMap.

Usage

generate-tiles [parameters]

All parameters are optional:

The command records a list of generated files. This list can be automatically forwarded to subsequent file commands like ftp-upload Command and zip Command.

Performance And Storage Considerations

Be careful when specifying zoom levels. Each zoom level needs about four times as many tiles as the previous one, so you can very quickly reach pretty large numbers of tiles which can take a very long time to generate and require a lot of disk space.

Let's say we have a map that on zoom level 10 roughly covers the whole computer screen (this would approximately be the area of London and its immediate surroundings). That means about 15 tiles for the zoom level 10. What happens if we want to generate tiles for the whole map up to the zoom level 19?

NOTE: These numbers are a very rough estimate. When calculating the time needed, an average speed of 50 tiles per second was used, which may vary substantially depending on the map complexity and on the computer hardware performance.

Web Maps

generate-tiles Command uses all the map sources currently registered in the map. This includes web maps (like OSM base map or Osmarender), so if you have one of those, be warned that tiles generation will take a very long time since the generator has to download each tile from the web before it can generate a tile itself. In order not to overload OSM servers, Maperitive limits how fast web tiles can be downloaded.

Tiles Transparency

There are various ways of achieving transparency of map tiles. The most common way is to make the background transparent, while all the other rendered content opaque. This is achieved by setting the MapBackgroundOpacity (TODO) in your rules to a value other than 1 (which represents a fully opaque color), usually by setting the background to be fully transparent:

properties
	...
	map-background-opacity : 0
	...

NOTE: This works only if all of the map sources on the map support transparency. Once you have web maps, for example, map-background-opacity will not be able to keep the background transparent.

The map on the screen will be drawn using a black background (since it is completely transparent) - this is normal behavior.

Uploading Tiles And Tiles Fingerprinting

Once you have generated your tiles, you can use commands like ftp-upload Command and zip Command to upload or copy all the generated tile images to a remote server. The generate-tiles Command records a list of all generated image file names and this list can be automatically forwarded to a subsequent file command. For example:

 generate-tiles
 ftp-upload host=myftp.com user=me pwd=secret remote-dir=uploadplace

will generate tiles and then upload them to the specified FTP server.

If you are maintaining a Web map of a certain area and you want to periodically update the tiles, you probably want to avoid uploading tiles that haven't changed since the last time. In order to achieve this, you can turn on tile fingerprinting:

 generate-tiles use-fprint=true
 ftp-upload host=myftp.com user=me pwd=secret remote-dir=uploadplace

Tile fingerprint is a small file which contains a numerical "fingerprint" of a tile. If fingerprinting is turned on, each tile will have its own corresponding .finger file. When the generate-tiles Command is executed more than once, it compares the fingerprint of the existing tile on the disk with the newly created one. If the two fingerprints are the same, this tells Maperitive that the tile contents have not changed so the tile will not be added to the list of generated files. This means the tile will not be included in the subsequent calls of ftp-upload or zip commands so you will save time and your server bandwidth.

One thing to note is that fingerprint files are not included in the generated file list - they are not needed on the remote server.

Using The Tiles

For more information on how to use these tiles, please visit http://wiki.openstreetmap.org/wiki/OpenLayers_Simple_Example#Extensions.

Examples

generate-tiles

Generates tiles using the default behavior.

generate-tiles minzoom=5 maxzoom=8

Generates tiles from the zoom level 5 up to the zoom level 8.

See also: