Smrender — A New Renderer for OSM Data


About two months ago we started a completely new projected, originally just as my personal intention. It is a new rendering software for OSM data, just because currently there are just two popular renderers, these are Mapnik and Osmarender.

The project is called smrender which is a short form for seamap render and is targeted for OpenSeamap but not limited to :).

Goals and Description

The primary development goal is to create a renderer which creates sea charts intended for print-out. Secondary goals are performance and memory efficency. The image on the right shows a chart rendered with smrender showing a part of the Croatian coastline. The image is scaled for a printout on A3 paper with a density of 300 dpi.

Smrender is a software which reads an OSM file, applies rules to the objects and creates a raster image. The output is projected and scaled adequately to be used as a paper sea chart (as long as neither the printing software nor the printer itself rescales it). The rules are defined as XML (OSM) file. Each rule consist of match options and an action which is carried out if an object matches. The rules currently support direct string compare, regex matching, match inversion (NOT), exclusion of specific tags, and function calls to shared objects. The latter is intended to be a modular interface to third-party modules. The actions may be text output, lines, polygons and image overlays.

A special feature is the auto-rotation of texts and images: the software tries to rotate an image or a string such that it does not interfere with other objects (as good as possible).

Smrender also closes open polygons such as segments of the coastline. The coastline is usually not a single closed way but rather a set of concatenated open ways for two reasons. First, because different tags may be attached to different parts of a coastline, and second  because usually you obviously just select a specific region from the OSM database and not the whole world. The OSM database will just return the ways which are within the selected bounding box. Closing those polygons is vital because you can’t fill open ones 😉

With all this, smrender can render a complete chart with all features at once, without any overlays or prerendered basemaps.

In the following there’s a snippet of a ruleset to give you an idea how it looks like and how it works…and code usually explains more than 1000 words. A short description is found below.

1 <node>
2 <tag k=’seamark:type’ v=”/>
3 <tag k=’_action_’ v=’func:pchar@./’/>
4 </node>
5 <node>
6 <tag k=’/^seamark:light:.*/’ v=”/>
7 <tag k=’_action_’ v=’img-auto:icons/Light_Magenta_90.png’/>
8 </node>
9 <node>
10 <tag k=’_action_’ v=’cap:/usr/share/fonts/truetype/ttf-liberation/LiberationSans-Italic.ttf,1.4,cm,black,auto;whit
11 e,name’/>
12 <tag k=’natural’ v=’bay’/>
13 </node>
14 <way>
15 <tag k=’highway’ v=’/^(secondary|primary|residential)$/’/>
16 <tag k=’_action_’ v=’draw:black’/>
17 </way>

Lines 1 – 4 match all nodes with the tag with the key ‘seamark:type=*’ and calls the function pchar of the shared object The library is loaded dynamically on startup.

Lines 5 – 8 match all nodes which have any tag whose key starts with ‘seamark:light:’. Smrender uses POSIX regular expressions in that case. On a match the image with the given filename is placed into the chart and in this case it uses auto-rotation. That means that smrender samples the area around the position of the node and tries to find a place where as less as other objects are in place already. Of course this does just make sense for some specific types of nodes like the magenta light flares (see sample picture above).

Lines 9 – 13 places an auto-rotated caption at the matching nodes’ positions and lines 14 – 17 renders a simple black line for all highways. Of course there are more options such as line thickness, style, and border.

Software and download

Smrender is written from scratch, completely in C. We don’t have any download location yet because the code needs some cleanup and a face lifting in places. We are also discussing licensing issues but we will probably release it under GPL within the next weeks.

Feel free to contact us if you have any questions!


2 pings

    • Markus on December 30, 2011 at 7:28 pm

    Nice work!
    Hope will do SVG soon 🙂

    • MM on January 1, 2012 at 3:54 pm

    Coole Sache! Magst du dafür bitte noch eine wiki Seite anlegen, damit wir das auch wieder schnell finden?

    Danke nochmal 🙂

    1. Es gibt bereits eine Wiki-Seite:

  1. […] Smrender puedes renderizar mapas del mar basados en Mapnik y […]

  2. […] jQuery("#errors*").hide(); window.location= data.themeInternalUrl; } }); } – Today, 1:49 […]

Comments have been disabled.