Version 21 (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.


svn co memphis-client-library-split

Example application:

scons tile-renderer

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 17, 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_zoom_level (MemphisRenderer *r, guint zoom_level);
void memphis_renderer_set_debug_level (MemphisRenderer *r, gint8 debug_level);

guint memphis_renderer_get_resolution (MemphisRenderer *r);
guint memphis_renderer_get_zoom_level (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); // emulates the old behavior, will be removed someday
void memphis_renderer_draw_tile (MemphisRenderer *r, cairo_t *cr, guint x, guint y);

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

Class MemphisMap:

MemphisMap* memphis_map_new_from_file (gchar *filename);
MemphisMap* memphis_map_new_from_data (gchar *data); // TODO
void memphis_map_free (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 (e.g. a GStringChunk)

MemphisDataPool* memphis_data_pool_new ();


  • Relicense all code as LGPL.
  • Remove all global variables
  • Make it thread safe


  • Create a GObject based API (in progress...)
  • Create documentation and example client code


  • 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. renderInfo
  • The dynamic debug level is not well solved.