Opened 12 years ago

Last modified 12 years ago

#4250 new enhancement

LABEL ALIGN AUTO and OFFSET AUTO xxx feature

Reported by: woodbri Owned by: tbonfort
Priority: normal Milestone:
Component: MapServer C Library Version: unspecified
Severity: normal Keywords:
Cc:

Description

It would be nice to have a feature LABEL ALIGN AUTO that can be used with POSITION AUTO such that when the label is positioned to the right of the label point then ALIGN LEFT (UL, CL, LL) is used and ALIGN RIGHT (UR, CR, LR) is used when positioned to the left. ALIGN CENTER would be used if it is centered on the label point (UC, CC, LC).

Likewise the OFFSET AUTO xxx, value would be used similarly to allow the label to be offset from symbol associated with the label. The value would be used to move the label more to the right/left or up/down based on the position of the label.

Attachments (2)

autoalign.jpg (174.8 KB ) - added by tbonfort 12 years ago.
auto-aligned labels output
autoalign.diff (6.0 KB ) - added by tbonfort 12 years ago.

Download all attachments as: .zip

Change History (11)

comment:1 by tbonfort, 12 years ago

I'm not sure I understand the OFFSET AUTO case. I believe this is already the behavior that is used if the label has an associated marker and you use OFFSET x x .

comment:2 by tbonfort, 12 years ago

I like the ALIGN auto functionality. Unfortunately the bounding box of the label is computed beforehand with the asked alignment method, and that bbox is then used when trying different positions around the label point. That said, the bounding box of the text does not evolve, whatever alignment method has been applied, so it would be possible with a bit of string manipulation to nudge the spaces around so the label ends up aligned to the left or to the right. This isn't a very elegant solution, but the line alignment code isn't either, so this might suffice until #3611 is addressed.

comment:3 by woodbri, 12 years ago

This is the second time we have run into this limitation of the precomputed bbox. Maybe we need to rethink this part of things. For example what if we had label case-group where we passed a list of labels and the first the fit in the list would satisfy the group. This would leave the logic of generating the cases to higher level code and the labelcache would only need to walk the list of items and try them.

comment:4 by woodbri, 12 years ago

Regarding the OFFSET AUTO, maybe I am wrongly assuming that this was not already done. I was playing around with placing a symbol and label text on a polygon feature and it seemed like I needed to use offset. I'll look at the cases and post more detail.

comment:5 by woodbri, 12 years ago

OK, it looks like the label is offset correctly from the symbol in all cases except CC where the label is placed on top of the symbol which seems to make sense to me because you need that behavior for labeling symbols. And I believe POSITION AUTO never tries the CC position.

So ignore the OFFSET AUTO part of this.

by tbonfort, 12 years ago

Attachment: autoalign.jpg added

auto-aligned labels output

by tbonfort, 12 years ago

Attachment: autoalign.diff added

comment:6 by tbonfort, 12 years ago

Here's a quick and dirty patch that adds auto-align functionality. Definitely not ready for production, and might blow up, but the idea is here.

comment:7 by woodbri, 12 years ago

Thomas, it looks like if I use POSITION AUTO the label overlaps with the symbol. It does the correct thing is I explicitly set it to any position except CC as discussed above. but not when using POSITION AUTO. This is probably a bug, let me know if you want a separate ticket for that.

comment:8 by tbonfort, 12 years ago

yeah, probably needs a new bug, with a screen capture and layer def.

comment:9 by woodbri, 12 years ago

I installed the autoalign patch and it works great! This would be an excellent addition to 6.2

Note: See TracTickets for help on using tickets.