minimum-distance works across features/layers for shields, but not for text placed along lines.
Fixing this properly will require a deep dive, but a brute force workaround appears to be:
diff --git a/src/placement_finder.cpp b/src/placement_finder.cpp
index b055a93..f4c20ec 100644
@@ -910,7 +910,8 @@ bool placement_finder<DetectorT>::test_placement(std::auto_ptr<text_path> const&
if (!detector_.extent().intersects(e) ||
- !detector_.has_placement(e, info_.get_string(), pi.get_actual_minimum_distance())
+ !detector_.has_point_placement(e, pi.get_actual_minimum_distance())
+ //!detector_.has_placement(e, info_.get_string(), pi.get_actual_minimum_distance())
See also: http://support.mapbox.com/discussions/tilemill/299-how-to-stop-labels-repeating-so-close-to-each-other
/cc @ajashton - fyi on that workaround. Tomorrow I'll take a look at a more proper fix.
also need to take a look at how this is handled or not handled for markers. Basically the task is to ensure that the functionality added for find_point_placement in 3f47de0#L2R486 works for text placement along lines
@springmeyer @herm - ok, testing..
line placement for Text seems to work, but Markers are not using minimum-distance. Should we add minimum-distance to MarkersSymbolizer ?
@springmeyer - ok, on my TODO list
@springmeyer - this all boils down to :
if (itr->box.intersects(box) || (text == itr->text && itr->box.intersects(bigger_box)))
The first one (currently used) looks ok to me.
okay, I will look into this more, assigning back to me.
Is there something new on this ?
Spacing only is really hard to handle.
Minimum distance gives homogeneous text and having it working on shield would be a real benefit!
@noirbizarre - can you say more about what you are struggling with? At this point I actually think the behavior is correct, but this ticket is open until I can write several tests to enforce it does not regress.
I just tested it: it's working in fact.
I have some questions, but I will ask on IRC.
when i look at the code, it seems to me that :
It seems that minimum-distance along a line doesn't have the same meaning for shields and for texts. I am right ?
This issue seems to be addressed by the diff you provided at the top of the ticket. Are you still willing to commit it ?
@abonnasseau - do you have a test case? I think the tricky bit here when testing expected/consistent behavior is whether placement="line" or not. Both text and shield symbolizers default to placement="point", but very often existing stylesheets actually keep that default for shields, because it still "looks right" since the shield is supposed to be upright (vs. text which requires placement="line" to look right when a linear geometry is being used).
Here's a functional case : I'd like to be able to set a parameter to avoid the text from the street names to be too close to the points of interest, like in this screenshot :
According to what minimun-distance does in the case placement="point", I thought it would be the same with placement="line".
The question is more semantic than technical, I understand that.
Cool, thanks. I will try to create a small testcase to isolate. I'm not comfortable making modifications without better regression tests.
what I understand is that the expected behavious is the one described in the doc : "minimum-distance = Minimum distance between repeated labels such as street names or shield symbols (works across features)". That is not what is illustrated by the screenshot I sent on friday. What got me wrong in the first place was that I can't find a use case for this specific feature. Do you recall some ?
And considering text and shields on a point, what minimum-distance implements is rather a margin. It is not what is described in the doc, but might be widely used.
This leaves an uncoverd fonctionality : what if we want a margin on texts along a line ? Which is what I would want between "Rue Montmarte" and the metro shield "Grands Boulevards (Rue Montmarte)", on the screenshot.
Do you think we can find a functionnal issue without breaking existing templates ?
Or would we have to consider minimum-distance as a deprecated feature ad implement "margin" (on lines and points) and "same-text-margin" (only along lines ?) instead ?
We now have action happen on this in Mapnik 3.x with the new repeat-distance option (#2331) which deals only with identical repeated labels in order to allow minimum-distance actually behave like you'd want - to avoid any labels from being placed too close to others. But, back-compatibility is tricky, so I don't think any change should be made in 2.3.x. Rather let's focus on master and discuss at #2362.