Question

Reposition overlaping labels

  • 20 March 2020
  • 5 replies
  • 21 views

Badge +14
  • Contributor
  • 117 replies

I have an existing dataset with labels where I want to increase the font sizes of all features. This of course results in overlaps in places, and I am trying to figure out if parts of the repositioning could be automated with FME.

 

What I have is the original placement and sizes of the labels. I would like to use these placements as starting points, increase the font sizes and then move anything that starts to "entangle".

I have read up on the MapTextLabeler, as best I could. It should do what I need. But it comes at a price, I don't know how steep, and I only need parts of what it offers.

Has anyone had any success building a workspace that spaces stuff out?

My thoughts are:

1. Create bounding boxes from the label, sized in ground units.

2. Check if any of these are "to" close

3. Move those in need further apart.

4. Check to see that no new overlaps have occurred.

 

No 3 above would be the trickiest one me thinks. The repositioning distance would need to be calculated from bounding box height as well as amount of overlap. Something only touching would need to move a shorter distance than a total overlap. Also the direction would need to be calculated, sometimes the text blocks are set a a slight offset. And then we have rotated labels... they would probably be pretty difficult to get right.

Has anyone pulled of anything similar to the above without loosing their marbles in the process? How did you do it? Any clever tricks that would help me along the way? What transformers jump to mind?

 


5 replies

Hi

 

Wondering if you ever solved this? Had the exact same problem and eventually discovered 'CoincidentPointOffsetter'. Seems to solve the problem for me (am still testing) although was hard to find.

 

 

Badge +14

Interersting! I will take a look at CoincidentPointOffsetter.

 

I ended up with a solution using the following steps:

 

Buffer -› SpatialRealator grouped by a shared id in the original data -› StatisticsCalculator to sort out those labels that are actually in a group -› Sort by _y value to arrange them within the group (from top to bottom) -› AttributeFilter to send them of depending on position 1-2-3 -› Aggregator and BoundsExtractor to calculate the distance between points -› FeatureMerger (suplier) to insert the new attribute to the original feature -› AttributeCreator followed by a VertexCreator to set a new _x and _y (I use a multiplier for this).

 

There are two parallel processes from the AttributeFilter an onwards, one to rearrange positon 1, another to rearrange position 3. Position 2 keeps its original placement.

 

Hope this is of some use to you.

Badge +2

Interersting! I will take a look at CoincidentPointOffsetter.

 

I ended up with a solution using the following steps:

 

Buffer -› SpatialRealator grouped by a shared id in the original data -› StatisticsCalculator to sort out those labels that are actually in a group -› Sort by _y value to arrange them within the group (from top to bottom) -› AttributeFilter to send them of depending on position 1-2-3 -› Aggregator and BoundsExtractor to calculate the distance between points -› FeatureMerger (suplier) to insert the new attribute to the original feature -› AttributeCreator followed by a VertexCreator to set a new _x and _y (I use a multiplier for this).

 

There are two parallel processes from the AttributeFilter an onwards, one to rearrange positon 1, another to rearrange position 3. Position 2 keeps its original placement.

 

Hope this is of some use to you.

Sounds like a viable solution - would you show the flow?

I am making a similar solution, but I have trouble getting control over the labels.

Badge +14

Sounds like a viable solution - would you show the flow?

I am making a similar solution, but I have trouble getting control over the labels.

Hi @mathiku​ 

 

Unfortunately I can't find this workspace. But I will try to help if you have any specific questions.

Badge +2

Sounds like a viable solution - would you show the flow?

I am making a similar solution, but I have trouble getting control over the labels.

It was more out of curiosity, I'll figure it out.

Reply