• Stars
    star
    287
  • Rank 143,521 (Top 3 %)
  • Language
    C++
  • License
    GNU General Publi...
  • Created over 14 years ago
  • Updated about 1 month ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Renders map tiles with mapnik and serves them using apache

mod_tile and renderd

This software contains two main pieces:

  1. mod_tile: An Apache 2 module to deliver map tiles.
  2. renderd: A daemon that renders map tiles using mapnik.
Image shoing example slippy map and OSM layer

Together they efficiently render and serve raster map tiles for example to use within a slippy map. The two consist of the classic raster tile stack from OpenStreetMap.org.

As an alternative to renderd its drop-in replacement Tirex can be used in combination with mod_tile.

Dependencies

Installation

Starting from the following operation systems and their versions:

  • Debian 11 (Bullseye)
  • Ubuntu 21.04 (Hirsute Hippo)

the software and all dependencies can be installed simply with:

$ apt install libapache2-mod-tile renderd

These packages for Debian and Ubuntu are being maintained by the Debian GIS Team in the respective repository.

Compilation

You may want to compile this software yourself. Either for developing on it or when using it on an operating system this is not being packaged for.

We prepared instructions for you on how to build the software on the following distributions:

Configuration

After you either installed the software packages or compiled the software yourself, you can continue with the configuration. For your convenience example configuration files are distributed with the software packages and located in the etc directory of this repository.

A very basic example-map and data can be found in the utils/example-map directory. For a simple test copy it over to /var/www/example-map.

Copy the configuration files to their place, too:

$ cp etc/renderd/renderd.conf /etc/renderd.conf
$ cp etc/apache2/renderd.conf /etc/apache2/conf-available/renderd.conf
$ cp etc/apache2/renderd-example-map.conf /etc/apache2/conf-available/renderd-example-map.conf

Enable the configuration:

$ sudo a2enmod tile
$ sudo a2enconf renderd
$ sudo a2enconf renderd-example-map

Restart apache2:

$ sudo a2enmod tile
$ sudo a2enconf renderd

And run the rendering daemon

$ renderd -f

Make sure the /var/cache/renderd/tiles directory is writable by the user running the renderd process.

Try loading a tile in your browser, e.g.

http://localhost/renderd-example/tiles/0/0/0.png

You may edit /etc/renderd.conf to indicate the location of different mapnik style sheets (up to ten) and the endpoints you wish to use to access it.

It is recommended to checkout switch2osm for nice tutorials on how to set up a full tile server like on OpenStreetMap.org, using this software together with a PostgreSQL database and data from OpenStreetMap.

Details about renderd: Tile rendering

The rendering is implemented in a multithreaded process called renderd which opens either a unix or tcp socket and listens for requests to render tiles. It uses Mapnik to render tiles using the rendering rules defined in the configuration file /etc/renderd.conf. Its configuration also allows to specify the number of rendering threads.

The render daemon implements a queuing mechanism with multiple priority levels to provide an as up-to-date viewing experience given the available rendering resources. The highest priority is for on the fly rendering of tiles not yet in the tile cache, two priority levels for re-rendering out of date tiles on the fly and two background batch rendering queues. The on the fly rendering queues are limited to a short 32 metatile size to minimize latency. The size of the main background queue is determined at compile time, see: render_config.h

Details about mod_tile: Tile serving

An Apache module called mod_tile enhances the regular Apache file serving mechanisms to provide:

  1. When tiles have expired it requests the rendering daemon to render (or re-render) the tile.
  2. Remapping of the file path to the hashed layout.
  3. Prioritizes rendering requests depending on the available resources on the server and how out of date they are.
  4. Use tile storage other than a plain posix file system. e.g it can store tiles in a ceph object store, or proxy them from another tile server.
  5. Tile expiry. It estimates when the tile is next likely to be rendered and adds the appropriate HTTP cache expiry headers. This is a configurable heuristic.

To avoid problems with directories becoming too large and to avoid too many tiny files. They store the rendered tiles in "meta tiles" in a special hashed directory structure. These combine 8x8 actual tiles into a single metatile file. This is a more efficient use of disk space and inodes.

The metatiles are then stored in the following directory structure: /[base_dir]/[TileSetName]/[Z]/[xxxxyyyy]/[xxxxyyyy]/[xxxxyyyy]/[xxxxyyyy]/[xxxxyyyy].meta

Where base_dir is a configurable base path for all tiles. TileSetName is the name of the style sheet rendered. Z is the zoom level. [xxxxyyyy] is an 8 bit number, with the first 4 bits taken from the x coordinate and the second 4 bits taken from the y coordinate. This attempts to cluster 16x16 square of tiles together into a single sub directory for more efficient access patterns.

Apache serves the files as if they were present under /[TileSetName]/Z/X/Y.png with the path being converted automatically.

Notes about performance

mod_tile is designed for high performance tile serving. If the underlying disk system allows it, it can easily provide > 10k tiles/s on a single serve.

Rendering performance is mostly dependent on mapnik and postgis performance, however renderd tries to make sure it uses underlying hardware as efficiently as possible and scales well on multi core systems. renderd also provides built-in features to scale to multi server rendering set-ups.

Copyright and copyleft

Copyright (c) 2007 - 2022 by mod_tile contributors (see AUTHORS)

This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 2 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/.

See the COPYING for the full license text.

More Repositories

1

iD

πŸ†” The easy-to-use OpenStreetMap editor in JavaScript.
JavaScript
3,336
star
2

openstreetmap-website

The Rails application that powers OpenStreetMap
Ruby
2,146
star
3

osm2pgsql

OpenStreetMap data to PostgreSQL converter
C++
1,390
star
4

osmosis

Osmosis is a command line Java application for processing OSM data.
Java
648
star
5

merkaartor

Home of Merkaartor, an openstreetmap mapping program.
C++
280
star
6

OSM-binary

Java
193
star
7

mapnik-stylesheets

Mirror of the mapnik stylesheets formerly used on OpenStreetMap.org
Python
153
star
8

id-tagging-schema

πŸ†”πŸ· The presets and other tagging data used by the iD editor
JavaScript
148
star
9

leaflet-osm

OpenStreetMap plugin for Leaflet
JavaScript
109
star
10

operations

OSMF Operations Working Group issue tracking
98
star
11

chef

Chef configuration management repo for configuring & maintaining the OpenStreetMap servers.
Ruby
95
star
12

tirex

Tirex tile queue manager. A drop-in replacement for renderd.
Perl
65
star
13

openstreetmap-mirror

Scripts to mirror remote repositories to http://github.com/openstreetmap
Shell
60
star
14

potlatch2

Potlatch 2 OpenStreetMap Editor
ActionScript
50
star
15

owg-website

The website for the OSMF Operations Working Group (OWG)
CSS
49
star
16

osmembrane

OSMembrane is a GUI front-end for β€œOsmosis” used by the OpenStreetMap project.
Java
42
star
17

map-icons

Mirror of the map icons used on OpenStreetMap.org
HTML
40
star
18

mkgmap

Mirror of mkgmap's Subversion repository
Java
32
star
19

tile-attribution

This repository is used for reporting and tracking sites which are using tile.openstreetmap.org tiles but without attributing OpenStreetMap. The sites are tracked in the issue tracker.
Ruby
32
star
20

osmdbt

OSM Database Replication Tools
C++
21
star
21

cgimap

Mirror of CGImap, the optimized implementation of the OpenStreetMap "/map" API call. PRs via: https://github.com/zerebubuth/openstreetmap-cgimap
C++
19
star
22

dns

OpenStreetMap DNS
JavaScript
15
star
23

gosmore

Mirror of Gosmore's Subversion repository
C++
13
star
24

stateofthemap-2019

State of the Map 2019 website
HTML
11
star
25

stateofthemap-2022

CSS
11
star
26

lane-icons

⬆️ SVG icons for common lane markings
11
star
27

svn-archive

Archived git conversion of svn.openstreetmap.org
Java
9
star
28

stateofthemap-2020

State of the Map 2020 website
CSS
9
star
29

shp2osm

Mirror of the shp2osm Subversion repository
Python
9
star
30

osm2pgsql-website

Website for the osm2pgsql project
SCSS
8
star
31

potlatch

Mirror of Potlatch's subversion repository
ActionScript
7
star
32

gpx-updater

Retrieve new OSM GPS tracks as they are uploaded, and invalidate cached tiles
Perl
7
star
33

planetdump

Obsolete OpenStreetMap Planet Dump Generator - Replaced by https://github.com/zerebubuth/planet-dump-ng
C
6
star
34

splitter

Mirror of splitter's Subversion repository
Java
6
star
35

stateofthemap-2018

State of the Map 2018 website
HTML
6
star
36

beboj

Online OpenStreetMap editor (pre-alpha, discontinued)
Java
5
star
37

stateofthemap-website

State of the Map website resources
HTML
5
star
38

gpx-import

GPX Importer
C
4
star
39

stateofthemap-2016

State of the Map 2016
CSS
4
star
40

openstreetmap-license-change

Algorithm for OpenStreetMap ODbL transition.
Ruby
3
star
41

stateofthemap-2017

State of the Map 2017 website
HTML
3
star
42

stateofthemap-2024

State of the Map 2024 website
CSS
3
star
43

quad_tile

Native C implementation of quad_tile functions from OpenStreetMap bundled as a gem
Ruby
2
star
44

tilelog

Python
2
star
45

prometheus-exporters

Ruby
2
star
46

mediawiki-skins-osmf

OSMF Skin for MediaWiki
CSS
2
star
47

osmtaginfo

Mediawiki extension for taginfo.openstreetmap.org
PHP
2
star
48

irc-website

irc.openstreetmap.org website
HTML
2
star
49

svn-website

Minimal redirector for the svn.openstreetmap.org to the archive
Dockerfile
1
star
50

opengeodata-static

Historical OpenGeoData static content
1
star
51

hot.openstreetmap.org-website

container and builder for hot.openstreetmap.org website
Dockerfile
1
star
52

trac-website

Minimal redirector for the trac.openstreetmap.org to the archived tickets
Dockerfile
1
star
53

dmca-website

OpenStreetMap's DMCA notice website
PHP
1
star
54

stateofthemap-2021

State of the Map 2021 website
CSS
1
star