Skip to content
This repository

Inconsistent line label placement for polygons #608

Closed
artemp opened this Issue · 11 comments

4 participants

Artem Pavlenko Hermann Kraus novldp Dane Springmeyer
Artem Pavlenko
Owner

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
Owner

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

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

Artem Pavlenko
Owner

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

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

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

Artem Pavlenko
Owner

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

Artem Pavlenko
Owner

[Ldp] This shares some properties with #614.

Artem Pavlenko
Owner

[Ldp]

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

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

novldp

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

Hermann Kraus herm closed this in 8b5e5fb
Hermann Kraus
Collaborator
herm commented

Should I backport this to 2.0.x?

novldp

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
Owner

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.