Skip to content

Inconsistent line label placement for polygons #608

Closed
artemp opened this Issue Oct 11, 2011 · 11 comments

4 participants

@artemp
Mapnik member
artemp commented Oct 11, 2011

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.

@artemp
Mapnik member
artemp commented Oct 11, 2011

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

http://postgis.refractions.net/documentation/manual-1.5/ST_ForceRHR.html

@artemp
Mapnik member
artemp commented Oct 11, 2011

[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.

@artemp
Mapnik member
artemp commented Oct 11, 2011

[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.

@artemp
Mapnik member
artemp commented Oct 11, 2011

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

@artemp
Mapnik member
artemp commented Oct 11, 2011

[Ldp] Seems so: http://trac.mapnik.org/browser/trunk/src/placement_finder.cpp#L768

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.

@artemp
Mapnik member
artemp commented Oct 11, 2011

[Ldp] This shares some properties with #614.

@artemp
Mapnik member
artemp commented Oct 11, 2011

[Ldp]

[[Image(608-offset-labeling.png)]]

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

@novldp
novldp commented Mar 10, 2012

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

screenshot

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:

<Rule>
  <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>
</Rule>
<Rule>
  <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>
</Rule>

Source data: http://pastebin.com/hEkThvh6

@herm herm was assigned Mar 20, 2012
@herm herm added a commit that closed this issue Mar 20, 2012
@herm herm Always place text at the same side of a line.
Fixes #608.
8b5e5fb
@herm herm closed this in 8b5e5fb Mar 20, 2012
@herm
Mapnik member
herm commented Mar 21, 2012

Should I backport this to 2.0.x?

@novldp
novldp commented Mar 21, 2012

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 ?).

@springmeyer
Mapnik member

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.