Version 35 (modified by simon, 5 years ago) (diff)



This page documents the progress of all changes in branches/client-library-split. The goal of this branch is the creation of a generic glib/cairo based OSM renderer library. The image tile renderer 'memphis' will be its first client. The second client will be libchamplain. And many more will follow.

Code: source:branches/client-library-split/

svn co memphis-client-library-split

Example application:

scons tile-renderer
./tile-renderer <zoom level> <map file>

Renders the file map.osm to png tiles. (demos/tile-renderer.c)

Proposed API


#include <memphis/memphis.h>

Class MemphisRenderer:

The tile renderer implements the 'Slippy Map Tilename' specification, like Mapnik and Osmarender. It supports zoom level 12 to 18, projected with the Mercator projection. Every level has 2zoom level images in x and y direction (enumarated from 0 to 2zoom level-1). Tiles without data are rendered filled with the background color of the map.

Debug Levels: 0: Be quiet, 1: Normal Output (Default), 2: Be verbose

MemphisRenderer* memphis_renderer_new ();
MemphisRenderer* memphis_renderer_new_full (MemphisRuleSet *rules, MemphisMap *map);
void memphis_renderer_free (MemphisRenderer *r);

void memphis_renderer_set_rule_set (MemphisRenderer *r, MemphisRuleSet *rules);
void memphis_renderer_set_map (MemphisRenderer *r, MemphisMap *map);
void memphis_renderer_set_resolution (MemphisRenderer *r, guint resolution);
void memphis_renderer_set_debug_level (MemphisRenderer *r, gint8 debug_level);

guint memphis_renderer_get_resolution (MemphisRenderer *r);
gint8 memphis_renderer_get_debug_level (MemphisRenderer *r);
MemphisMap* memphis_renderer_get_map (MemphisRenderer *r):
MemphisRuleSet* memphis_renderer_get_rule_set (MemphisRenderer *r);

void memphis_renderer_draw_png (MemphisRenderer *r, gchar *filename, guint zoom_level); // emulates the old behavior, will be removed someday
void memphis_renderer_draw_tile (MemphisRenderer *r, cairo_t *cr, guint x, guint y, guint zoom_level);

gint memphis_renderer_get_row_count (MemphisRenderer *renderer, guint zoom_level);
gint memphis_renderer_get_column_count (MemphisRenderer *renderer, guint zoom_level);
gint memphis_renderer_get_min_x_tile (MemphisRenderer *renderer, guint zoom_level);
gint memphis_renderer_get_max_x_tile (MemphisRenderer *renderer, guint zoom_level);
gint memphis_renderer_get_min_y_tile (MemphisRenderer *renderer, guint zoom_level);
gint memphis_renderer_get_max_y_tile (MemphisRenderer *renderer, guint zoom_level);
gboolean memphis_renderer_tile_has_data (MemphisRenderer *renderer, gint x, gint y, guint zoom_level);

Class MemphisMap:

MemphisMap* memphis_map_new ();
void memphis_map_free (MemphisMap *map);

void memphis_map_load_from_file (MemphisMap *map, gchar *filename);
void memphis_map_load_from_data (MemphisMap *map, gchar *data); // TODO

void memphis_map_set_debug_level (MemphisMap *map, gint8 debug_level);
gint8 memphis_map_get_debug_level (MemphisMap *map);

Class MemphisRuleSet:

MemphisRuleSet* memphis_rule_set_new ();
void memphis_rule_set_free (MemphisRuleSet *rules);

void memphis_rule_set_load_from_file (MemphisRuleSet *rules, gchar *filename);
void memphis_rule_set_load_from_data (MemphisRuleSet *rules, gchar *data); // TODO

void memphis_rule_set_set_debug_level (MemphisRuleSet *rules, gint8 debug_level);
gint8 memphis_rule_set_get_debug_level (MemphisRuleSet *rules);

Class MemphisRule:


Class MemphisDataPool:

A singleton that provides a shared pool of efficient memory (i.e. a GStringChunk and a GTree for strings).

MemphisDataPool* memphis_data_pool_new ();


  • Relicense all code as LGPL.
  • Remove all global variables.
  • Make it more thread safe.
  • Create a GObject based API.
  • Add zoom level 18 support


  • Add the capability to edit rules.
  • Create documentation and example client code.
  • Create a build system (probably after the GSoC).


  • Parsing maps and rules is not thread safe because of the shared MemphisDataPool.
  • Code is scatterd between new and old files. In my opinion, all code should be moved into the class files one day.
  • Some data structures should be merged with the classes. e.g. osmFile, cfgRules.
  • The dynamic debug level is not well solved.