-
-
Save craigds/961b3340aa46afc6c1ec to your computer and use it in GitHub Desktop.
test cairo errors in mapnik
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
import mapnik | |
import mapnik.printing | |
import cairo | |
m = mapnik.Map(600,300) | |
m.background = mapnik.Color('steelblue') | |
ds = mapnik.MemoryDatasource() | |
f = mapnik.Feature(mapnik.Context(), 1) | |
f.add_geometries_from_wkt("POINT(0 0)") | |
f.add_geometries_from_wkt("POINT(1 1)") | |
f.add_geometries_from_wkt("POINT(2 2)") | |
ds.add_feature(f) | |
s = mapnik.Style() | |
r = mapnik.Rule() | |
sym = mapnik.PointSymbolizer() | |
r.symbols.append(sym) | |
s.rules.append(r) | |
m.append_style('My Style',s) | |
layer = mapnik.Layer('points') | |
layer.datasource = ds | |
layer.styles.append('My Style') | |
m.layers.append(layer) | |
m.zoom_all() | |
page = mapnik.printing.PDFPrinter( | |
pagesize=mapnik.printing.pagesizes['a4'], | |
is_latlon=True, | |
resolution=300, | |
scale=mapnik.printing.any_scale, | |
box=mapnik.Box2d(-1, -1, 3, 3), | |
centering=mapnik.printing.centering.both | |
) | |
page.render_map(m, "output.pdf") | |
# Traceback (most recent call last): | |
# File "./mapnik_pdf_test.py", line 39, in <module> | |
# page.render_map(m, "output.pdf") | |
# File "/usr/lib/pymodules/python2.6/mapnik/printing.py", line 613, in render_map | |
# render_map() | |
# File "/usr/lib/pymodules/python2.6/mapnik/printing.py", line 610, in render_map | |
# ctx.restore() | |
# cairo.Error: Context.restore without matching Context.save | |
# python: /build/buildd/cairo-1.8.10/src/cairo.c:218: cairo_destroy: Assertion `((*&(&cr->ref_count)->ref_count) > 0)' failed. | |
# Aborted |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment