Skip to content


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP


Inconsistent line label placement for polygons #608

artemp opened this Issue · 11 comments

4 participants

Artem Pavlenko novldp Hermann Kraus Dane Springmeyer
Artem Pavlenko

Placing labels on polygon boundary with ''dy'' (negative or positive) parameter, using this code:

<TextSymbolizer name="OPIS" face_name="DejaVu Sans Book" 
  size="10" fill="white" halo_fill= "black" halo_radius="1" 
  placement="line" allow_overlap="false" spacing="100" dy="-5" 
  max_char_angle_delta="20" min_distance="50"

Results in labels placed on both sides of the line as shown in attached image.

Ideally labels should be placed consistently on the same ''side'' of the line.

Artem Pavlenko

[Ldp] Force your polygon rings to always go the same way around.

Artem Pavlenko

[Ldp] Note that that is PostGIS specific. Would it make sense to have this in mapnik proper?

We would require this for boundary labeling as well, where the labels have to go on the proper side of the boundary. Also see steve8's wishlist.

Artem Pavlenko

[dodobas] Ldp, this is not affected by polygon orientation, i've just tried putting data to postgis and then updated geometry with st_forceRHR, and result is the same, some of the labels get placed on each side of the polygon boundary.

Artem Pavlenko

[Ldp] Then it would appear dy is linked to the "text right side up" algorithm?

Artem Pavlenko

[Ldp] Seems so:

When too many characters are placed upside down, it retries with the opposite orientation, and dy evaluation switches with that. That shouldn't be done, not always anyway.

Artem Pavlenko

[Ldp] This shares some properties with #614.

Artem Pavlenko



There should be a way to keep all the labels at one side of a line.


An example picture, because those things say more than a thousand words:


Wrong label on 4. This is the right list:
1. CW, dy < 0
2. CW, dy > 0
3. CCW, dy < 0
4. CCW, dy > 0

The moment a text is flipped 180 degrees due to >50% of the characters being upside down, dy is flipped as well.

Also note the inconsistent dy rendering in example 1, 2, 3.

XML snippet:

  <Filter>[highway] = 'unclassified' and ([ref]='1' or [ref]='3')</Filter>
  <TextSymbolizer size="14" fill="#000" spacing="1" placement="line" fontset-name="book-fonts" halo-radius="1" dy="-10">[name]</TextSymbolizer>
  <Filter>[highway] = 'unclassified' and ([ref]='2' or [ref]='4')</Filter>
  <TextSymbolizer size="14" fill="#000" spacing="1" placement="line" fontset-name="book-fonts" halo-radius="1" dy="10">[name]</TextSymbolizer>

Source data:

Hermann Kraus herm was assigned
Hermann Kraus herm closed this in 8b5e5fb
Hermann Kraus

Should I backport this to 2.0.x?


I wouldn't dare ask, but I'd also be very happy if it would find its way into the next release (not 2.1, but 2.0.1 ?).

Dane Springmeyer

Yes, so backporting to 2.0.x branch would ensure this would be in the 2.0.1 release. LGTM.

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.