Smrender — State of Development Report

murter_sampleSmrender is a powerful, flexible, and modular rule-based rendering engine for OpenStreetmap data. Its primary development goal was and still is to develop a renderer for paper nautical charts. Because of its very generic and modular software design it can be used for charts of any map style and it is also perfectly suitable for data processing and manipulation tasks such as filtering, modification, and statistical analysis.

Smrender is unique. There is no other free tool available to create such high quality nautical charts suitable for print.1

State of Development

Smrender is a yet mature piece of software. It is stable and reliably produces high-quality PDFs of any page size suitable for print. It supports most features used in nautical charts and can thus be used in production environments. The development started in 2010 and it is enhanced and improved continuously since then.

Distinguishing Features

It’s in the nature of things that all renderers share a common set of features, such as producing colored lines and polygons. In the following I’d like to point out some distinct features of Smrender, beside the fact that it is specifically designed to produce nautical charts.

  • It is written in C with just a few dependencies.2 Thus, it is very easy to install and use, it is very fast and efficient and is that type of Swiss-Army-Knife-Working-Out-Of-The-Box tool ­čśë
  • auto_rotIt can auto-detect the placement and rotation of captions for various chart features, such as islands or bays. E.g. Smrender can place island captions along the “major axis” of the island and in a font size which depends on the area of the island (see picture on the right: caption of the island of ┼Żirje, and the captions of the bays on its northern and southern coast) .
  • There is also auto-rotation for icons (see the magenta colored light flares at the picture on the right).
  • Smrender supports various non-trivial match operations, such as regular expressions and decimal interpretation and comparison of tag values.
  • Smrender comes with a sophisticated polygon filling algorithm for incomplete datasets as well as so-called multi-polygons. The first one typically is e.g. the coastline which exceeds the page border. The latter is the island-within-the-lake case where many renderers depend on the multi-polygon relation, but not Smrender.3
  • Smrender is much more than “just” a tool to produce graphic output. It is capable of doing rule-based OSM data modification. Most functions are modifying/adding OSM data (to its internal database) on the fly to which in further steps are rendering primitives (drawing/filling) applied. It comes with a set of functions far beyond rendering (see list of functions below).
  • Smrender can easily be extended with 3rd-party functions because of a well-defined library call interface.

Workflow

The input to Smrender is the OSM data of the desired area, a ruleset, typically a set of icons (which have been specified by the ruleset), and some rendering parameters, such as e.g. the page size and the scale.

Smrender then produces an output file. This could be PDF (which is vectorized data suitable for high-quality print), PNG, BSB/KAP,4 or OSM again. The latter could be used to pass the OSM data to another renderer. As was previously explained, Smrender generates OSM data on the fly. E.g. light sectors are not directly rendered onto the surface (see sectored light Otocic Raparasnjak on the upper left corner of the picture from above). It is a 2-step procedure. First, Smrender generates the light sectors as OSM nodes and ways and stores it into its internal database. Second, rendering primitives (drawing lines) are applied to those OSM ways.

The Smrender package contains some rulesets. The most important one, as well as the best maintained ruleset is the traditional yellow-map sea chart style. The package also contains all necessary sea chart icons (buoys, beacons, topmarks, … Thanks to Malcolm Herring, author of the OpenSeamap online renderer who also created the icons.).

To create a chart yourself, there are the following steps:

  1. Download and install Smrender (simply, as usual do ./configure ; make ; sudo make install).
  2. Download the OSM data of your desired area into a working directory. You can do this with e.g. JOSM, or on the command line with curl or wget, or whatever tool you like.
  3. Copy (or symlink) the sea chart icon directory (/usr/local/share/smrender/SeaMapSymbols) into your working directory.
  4. Run Smrender on the command line like this: `smrender -i your_osm_file.osm -r /usr/local/share/smrender/r100k_ye -o output.pdf LAT:LON:SCALE`. Replace LAT:LON:SCALE with the center point of your area, e.g. 43N46:15E35:100000.

Documentation

The primary site of Smrender currently is found at http://www.abenteuerland.at/smrender/.

Smrender comes with a very complete documentation found here as HTML or here as PDF. There is a set of examples found online in the samples directory and a complete set of Croatian sea charts.

There is no specific mailing list at the moment but don’t hesitate to contact me at the OpenSeamap dev mailinglist or personally at bf@abenteuerland.at.

List of Functions

add() Add specific OSM node to the input data.
cap() Place a caption (rendering primitive).
cat_poly() Concatenate polygons (e.g. the coastline which consists of a set of OSM ways).
compass() Create magnetic variation compass (as a set of OSM nodes and ways.)
diff() Compares OSM files based on the existence of objects (based on their IDs).
disable() Disable OSM object, i.e. set its visibility to “false”.
disable_rule() Disable specific rule.
dist_median() Calculate the median of the length of the edges of a way and add an OSM tag.
draw() Draw lines/borders and/or fill polygons (rendering primitive).
enable() Enable OSM object, i.e. set its visibility to “true”.
enable_rule() Enable specific rule.
exec() Execute external program/script and pass OSM data on stdin/stdout.
exit() Stop rendering and quit Smrender.
grid() Generate chart grid and axis borders (as OSM nodes/ways).
img() Place icons or brush-fill areas (rendering primitive).
incomplete() Create OSM file which contains object IDs of incomplete relations.
inherit_tags() Copy tags from nodes to ways/relations where they are members of or vice versa.
ins_eqdist() Insert nodes along a way at specific equal distances.
mask() Mark nodes within dense clusters of nodes as not to be rendered.
neighbortile() Find the tile numbers of all tiles through which a way passes.
out() Output data to an OSM file.
pchar() Create string of light characteristic as used in nautical charts and add tag.
poly_area() Calculate area of polygon and add tag.
poly_centroid() Calculate the centroid of a polygon and add OSM node.
poly_len() Calculate the length of a polygon/way and add a tag.
refine_poly() Add nodes to a way to smoothen its edges (DEPRECATED).
reverse_way() Reverse way (reverse the order of its nodes).
ruler() Generate a scale ruler (as OSM nodes/ways).
set_ccw() Order the nodes of a polygon counterclockwise.
set_cw() Order the nodes of a polygon clockwise.
set_tags() Add tag to OSM object.
shape() Generate a shape (circle/square/…) and add corresponding nodes/ways.
sounding() Generate a sounding circle as usual on nautical charts (will be deprecated).
split() Split a way into parts at specific nodes.
strfmt() Create formatted string from a set of tags.
sub() Call subset of rules (EXPERIMENTAL).
sync_threads() Synchronisation point for multi-threading.5
translate() Translate tag values based on a translation table.
vsector() Create light sectors and add nodes/ways.
zeroway()  Create artificial way of zero length.6

Have phun using Smrender!

  1. Of course, there are other paper chart tools available but none for nautical charts. Have a look at OSM-On-Paper in the OpenStreetmap Wiki,
  2. It depends on Cairographics, and optionally on Fontconfig, and Librsvg. All three are installed by default on most Unix-like systems.
  3. IMO multi-polygons in OSM are a bad workaround for a problem that was discovered by the first developer of a rendering software who was not able to solve the problem mathematically…
  4. Unfortunately, there is no real standard format for charts. There are as many formats as tools, and everybody seems to reinvent a new format for his software. BSB/KAP is a raster format which is supported by a lot of mapping tools.
  5. Multi-threading is highly experimental and should not be used in the moment.
  6. This was a requirement for the OpenSeamap Router which is based on Routino and Smrender as an OSM data pre-processor.

Comments

Smrender — State of Development Report — 6 Comments

  1. Heya! Nice work, this looks really epic!
    Do you have a bugtracker somewhere? Because, uuh, I get this error when trying to run the above example:
    18:10:25.029 (+ 0.000) [ err] cannot open file SeaMapSymbols/Anchorage.svg: out of memory

    I called “smrender -i helgoland.osm -o output.pdf 54N5:7E:100000 -r /usr/local/share/smrender/r100k_ye” – the osm file only contains Helgoland, the zoom is specified for the area

    Cheers!

    • No, there’s no bugtracker yet, just email. Probably it’s compiled without SVG support. Run ./configure again. At some point it should say “checking for RSVG … yes/no”. If it says no, install the package librsvg2-dev and ./configure ; make ; make install again.

  2. Hi,

    I have had quiet a lot of fun playing with smrender and made some nice looking charts. I am looking forward to depth rendering, because for navigation it is rather reasuring to know how deep it is.

    Keep up the good work.

  3. Great tool
    runs under win8 with cygwin2.2.1

    1) librsvg2-dev has to be installed
    2) smrules_cairo.c has to be modified

    Thanks

    • Great news! What exactly did you modify? If you send me a patch I can include it directly into the code.

      • An patch is NOT required! It was a failure by my site.
        A missing cygwin package was the reason for the problem.

        Thank again