mapnik を使用してマップを PDF 形式でレンダリングしていますが、厄介な問題に遭遇しました。
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
Djangoを使用しています。上記の関数は共同開発者のコンピューターでは問題なく動作しますが、私のコンピューターではクラッシュします。問題はmapnik.render()
関数にあります。次のエラーが発生します。
python: /build/buildd/cairo-1.12.2/src/cairo.c:301: cairo_destroy: Assertion `((*&(&cr->ref_count)->ref_count) > 0)' failed.
Aborted
私がそれを切り替えると、mapnik.render(m, map_surface)
それは正常に動作します。適切なライブラリ (libcairo2-dev、python-cairo、libmapnik、mapnik-utils) をアンインストールしてから再インストールしようとしましたが、何も機能しません。
どんな助けでも大歓迎です。
編集:
意図せずにこの問題を解決しました。mapnik にバンドルされているインストール済みのタイルミル
sudo add-apt-repository ppa:developmentseed/mapbox
sudo apt-get update
sudo apt-get install tilemill libmapnik nodejs
マップニクのバージョンは現在2.2.0-pre