Pyrender

From OpenStreetMap Wiki
Jump to: navigation, search
Pyrender
Screenshot of Pyrender
Authors: user:Ojw
Source code: http://svn.openstreetmap.org/applications/rendering/pyrender/
License: GPLv3
Platforms: Windows, macOS, and Linux
Programming language: Python
Pyrender is an on-demand map rendering framework, programmed in Python, written by User:Ojw. When it receives an HTTP request for a tile, it fetches the OSM data for the tile from OJW's tile data server, and renders the data as PNG.

The Pyrender code in the SVN repository does not work. Some of the reasons include:

  • OJW's tile server no longer exists
  • Changes in OpenLayers have broken the sample slippy map

Getting started

Check out pyrender from svn:

$ svn co http://svn.openstreetmap.org/applications/rendering/pyrender/

Start the tile server. You may need to install some prerequisites such as python, py-cairo.

$ cd pyrender
$ ./server.py

Visit http://localhost:1280/ with a web browser. To view the map of somewhere other than London, you can edit the coordinates of a permalink.

Creating a custom slippy-map

Before pyrender

Method A:

  • Download the world
  • Install a database server
  • Install a webserver
  • Install mapnik
  • Create a config file to say what your map should look like

Method B:

  • Create a config file to say what your map should look like
  • Pre-render the world
  • Install a webserver

After pyrender

  • Create a config file to say what your map should look like
  • Run a python program that shows you a slippy map of your new map style without any other configuration

Technical stuff

Pyrender system.png

  • purple = concept
  • green = actual program that you can download from here

Getting tile data

We need someone to run a server for this - see tile data server

Limitations

  • Can only view zoom 15 at the moment

TODO

  • Headers to allow browser caching
  • fix breakage when someone tags with layer=not_numeric
  • The overlay layers seem to have a minimum zoom level (z13 or so) - we want to zoom out more
  • openlayers isn't showing zoom levels > 17

Screenshots

These are from renderer_default.py, which is a cairo renderer handling ways and areas:

Default layer, which is mainly roads, railways, footpaths


Water network, showing riverbanks, docks, coastlines, etc.

Pyrender docklands water.png

Borders layer (these are local borders of Camden, Westminster, etc. inside London):

Pyrender london borders.png

Zoom out a bit, and it starts merging tiles together to get enough data:

Pyrender motorway.png

Metro rail systems, showing the London Underground

Pyrender metro lines.png

Railway network layer, including railway station outlines:

Pyrender rail network.png

Features without a name (debug layer) (note: this shows all features without name tag, not just roads):

Pyrender noname.png

Building layer, being displayed on top of the default layer

Pyrender buildings.png

Rendering libraries

Base-classes are available for:

  1. Cairo (graphics)
  2. Python Imaging Library

however, each rendering module chooses which base-class to use (and in many cases, calls the graphics library functions itself), which means that in practice you have to have the right library installed for whichever renderer you want to run

Future work

  • Simplify ways when zooming out

See also

  • Kosmos -- great render with built-in tileserver. Unfortunately dependent on evil. Maybe we can reuse their config file format (which is conveniently valid wikitext). Actually Kosmos would be a nice implementation of this complete concept if it was portable, as it does the server and rendering blocks very well already.