From 99265b22ac158d59d197cc00838b2f49b6948dd3 Mon Sep 17 00:00:00 2001 From: Hermann Kraus Date: Mon, 10 Sep 2012 02:42:59 +0200 Subject: [PATCH] Add simple render script. --- demo/simple-renderer/render.py | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100755 demo/simple-renderer/render.py diff --git a/demo/simple-renderer/render.py b/demo/simple-renderer/render.py new file mode 100755 index 000000000..6ab075d25 --- /dev/null +++ b/demo/simple-renderer/render.py @@ -0,0 +1,23 @@ +#!/usr/bin/env python + +import sys +import mapnik + +def render(input_file, output_file, width=800, height=800, bbox=None): + m = mapnik.Map(width, height) + mapnik.load_map(m, input_file, False) + if bbox is not None: + m.zoom_to_box(bbox) + else: + m.zoom_all() + mapnik.render_to_file(m, output_file) + +if len(sys.argv) == 2: + render(sys.argv[1], "output.png") +elif len(sys.argv) == 3: + render(sys.argv[1], sys.argv[2]) +elif len(sys.argv) == 5: + render(sys.argv[1], sys.argv[2], int(sys.argv[3]), int(sys.argv[4])) +else: + print "usage: %s style_file [output_file] [width height]" % sys.argv[0] + sys.exit(1)