using mapnik.render(mapnik::Map, PycairoContext*) crashes unexpectedly

448 Views Asked by At

I'm using mapnik to render maps in PDF format and I've run into a messy problem.

def writeFile(m, mapId):
    response = HttpResponse(content_type='application/pdf')
    response['Content-Disposition'] = 'attachment; filename=test.pdf'

    map_surface = cairo.PDFSurface(response, 1200, 700)
    map_ctx = cairo.Context(map_surface)
    mapnik.render(m, map_ctx)
    legend = createLegend(map_ctx, mapId)

    map_surface.finish()
    return response

We're using Django. The above function work fine on my co-developer's computer but crashes on my computer. The issue is with the mapnik.render() function. I end up with the following error:

python: /build/buildd/cairo-1.12.2/src/cairo.c:301: cairo_destroy: Assertion `((*&(&cr->ref_count)->ref_count) > 0)' failed.
Aborted

When I switch it out with mapnik.render(m, map_surface) it works okay. I have tried uninstalling then reinstalling the proper libraries (libcairo2-dev, python-cairo, libmapnik, mapnik-utils) but nothing's working.

Any help will be appreciated.

EDIT:

Solved this problem unintentionally. Installed tilemill, which is bundled with mapnik

sudo add-apt-repository ppa:developmentseed/mapbox
sudo apt-get update
sudo apt-get install tilemill libmapnik nodejs

Mapnik version is now 2.2.0-pre

0

There are 0 best solutions below