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"
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.
[Ldp] Force your polygon rings to always go the same way around.
[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.
[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.
[Ldp] Then it would appear dy is linked to the "text right side up" algorithm?
[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.
[Ldp] This shares some properties with #614.
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.
<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: http://pastebin.com/hEkThvh6
Always place text at the same side of a line.
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 ?).
Yes, so backporting to 2.0.x branch would ensure this would be in the 2.0.1 release. LGTM.