- if form.getvalue("format") == "png":
- image = mapnik2.Image(map.width, map.height)
- mapnik2.render(map, image)
- png = image.tostring("png")
- output_headers("image/png", "map.png", len(png))
- sys.stdout.write(png)
- elif form.getvalue("format") == "jpeg":
- image = mapnik2.Image(map.width, map.height)
- mapnik2.render(map, image)
- jpeg = image.tostring("jpeg")
- output_headers("image/jpeg", "map.jpg", len(jpeg))
- sys.stdout.write(jpeg)
- elif form.getvalue("format") == "svg":
- file = tempfile.NamedTemporaryFile()
- surface = cairo.SVGSurface(file.name, map.width, map.height)
- mapnik2.render(map, surface)
- surface.finish()
- output_headers("image/svg+xml", "map.svg", file_size(file))
- output_file(file)
- elif form.getvalue("format") == "pdf":
- file = tempfile.NamedTemporaryFile()
- surface = cairo.PDFSurface(file.name, map.width, map.height)
- mapnik2.render(map, surface)
- surface.finish()
- output_headers("application/pdf", "map.pdf", file_size(file))
- output_file(file)
- elif form.getvalue("format") == "ps":
- file = tempfile.NamedTemporaryFile()
- surface = cairo.PSSurface(file.name, map.width, map.height)
- mapnik2.render(map, surface)
- surface.finish()
- output_headers("application/postscript", "map.ps", file_size(file))
- output_file(file)
+ if pid == 0:
+ if form.getvalue("format") == "png":
+ image = mapnik.Image(map.width, map.height)
+ mapnik.render(map, image)
+ png = image.tostring("png")
+ output_headers("image/png", "map.png", len(png))
+ sys.stdout.write(png)
+ elif form.getvalue("format") == "jpeg":
+ image = mapnik.Image(map.width, map.height)
+ mapnik.render(map, image)
+ jpeg = image.tostring("jpeg")
+ output_headers("image/jpeg", "map.jpg", len(jpeg))
+ sys.stdout.write(jpeg)
+ elif form.getvalue("format") == "svg":
+ file = tempfile.NamedTemporaryFile(prefix = "export")
+ surface = cairo.SVGSurface(file.name, map.width, map.height)
+ mapnik.render(map, surface)
+ surface.finish()
+ output_headers("image/svg+xml", "map.svg", file_size(file))
+ output_file(file)
+ elif form.getvalue("format") == "pdf":
+ file = tempfile.NamedTemporaryFile(prefix = "export")
+ surface = cairo.PDFSurface(file.name, map.width, map.height)
+ mapnik.render(map, surface)
+ surface.finish()
+ output_headers("application/pdf", "map.pdf", file_size(file))
+ output_file(file)
+ elif form.getvalue("format") == "ps":
+ file = tempfile.NamedTemporaryFile(prefix = "export")
+ surface = cairo.PSSurface(file.name, map.width, map.height)
+ mapnik.render(map, surface)
+ surface.finish()
+ output_headers("application/postscript", "map.ps", file_size(file))
+ output_file(file)
+ else:
+ output_error("Unknown format '%s'" % form.getvalue("format"))