Skip to content


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP


LineSymbolizer doesn't close polygons #1339

TobWen opened this Issue · 10 comments

4 participants


When using LineSymbolizer to draw the outline of a polygon with Cairo, the lines in the polygon doesn't seem to be closed as expected:
example image

mapnik: v2.0.1
cairo: 1.10.2
cairo-wrapper: 1.8.4
python-cairo: 1.8.8
geos: v3.2.0

Tested on PDF output, viewer is latest Adobe Reader on Windows XP.

Edit: also occures on AGG

@artemp artemp was assigned

@TobWen - thanks for reporting


The problem is that you don't close the path when LineSymbolizer is used for rectangles.
Here is a small example in Python, which demonstrates the issues:

#!/usr/bin/env python

import math
import cairo

WIDTH, HEIGHT = 100, 100

surface = cairo.PDFSurface('example.pdf', WIDTH, HEIGHT)
ctx = cairo.Context(surface)

ctx.translate(25, 25)
ctx.scale(50, 50)

ctx.move_to(0, 0)
ctx.line_to(1, 0)
ctx.line_to(1, 1)
ctx.line_to(0, 0)
# ctx.close_path()    # turning on this creates a closed path (expected for polygons: houses etc.)


@TobWen - c7af665 should close polygons

@artemp artemp closed this

Problem still exists in e2b6572.

@herm herm reopened this

The fix in c7af665 is obviously not enough. The problem reported is for LineSymbolizer in Cairo and the fix only touches BuildingSymbolizer in AGG. The Cairo code seems to correctly handle closed paths (with SEG_CLOSE). However depending on the input data the path is not necessarily closed using SEG_CLOSE but instead using SEG_LINE which results in this behavior. I think it would be reasonable to implicitly close all paths where the first and the last point are the same.


@herm: This could lead into unspected behavour. Please let the user choose to close it or check the geometry type first: if polygon, then close. Please read my ideas in #1351


@TobWen - again you've not actually provided a working testcase. Closing this issue. You can re-open in a new one if you actually have a test case that uses some geodata and uses mapnik and demonstrates the problem.


A test case for this bug would be the circle in visual test "lines-4" from harfbuzz branch.


Here is a working testcase (press "download now" on the right side, download starts immediately):


thanks, re-opening.

@springmeyer springmeyer reopened this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.