Question

Change label position to labelpoint

  • 24 August 2018
  • 7 replies
  • 30 views

Badge

When creating a label with the Labeller or LabelPointReplacer, a labelpoint is made at the asked position. However, the label itself is always placed on the right above position from the labelpoint.

I need the label to be placed on the left above position from the labelpoint (thus having the point at the end of the labeltext instead of the beginning), in order to garentee a good label fit in the end result. How would this be possible?


7 replies

Userlevel 4
Badge +26

Have you tried the Labeller instead? It gives a little more control over placement

Badge

Have you tried the Labeller instead? It gives a little more control over placement

Yes, it places a labelpoint at the specified place and rotation. However, the text will still be right above the labelpoint, cfr. the rotation.

 

 

Badge

After a some more research I found this: https://knowledge.safe.com/articles/16546/text-justification.html

However, I am writing to PDF2D, which is not in the table. Any other options?

Userlevel 4
Badge +26

After a some more research I found this: https://knowledge.safe.com/articles/16546/text-justification.html

However, I am writing to PDF2D, which is not in the table. Any other options?

You could always offset the text with an Offsetter. The text has a defined bounding box. You can extract the xmin and xmax with a BoundsExtractor, get the difference and then offset by the negative difference. The issue that I see with this method is that the 'bounds' might not be an accurate reflection of how the text will look in the PDF. It's worth giving it a go just to see.

 

Perhaps @DaveAtSafe has a better idea?

 

There is always the MapTextLabeller plugin....handy tool but not free. Perhaps you can get a trial of it to see if it's worth the investment?

 

 

Badge
You could always offset the text with an Offsetter. The text has a defined bounding box. You can extract the xmin and xmax with a BoundsExtractor, get the difference and then offset by the negative difference. The issue that I see with this method is that the 'bounds' might not be an accurate reflection of how the text will look in the PDF. It's worth giving it a go just to see.

 

Perhaps @DaveAtSafe has a better idea?

 

There is always the MapTextLabeller plugin....handy tool but not free. Perhaps you can get a trial of it to see if it's worth the investment?

 

 

I have spent already a lot of time experimenting with bounding boxes and offsetters. The result however is just not correct enough to be used as a generic solution, because of these inaccurate bounds.

 

 

Userlevel 2
Badge +17
I have spent already a lot of time experimenting with bounding boxes and offsetters. The result however is just not correct enough to be used as a generic solution, because of these inaccurate bounds.

 

 

Hi @bakkermans,

 

The most accurate way to get the bounds of a text feature is to use the TextStroker to convert it to an aggregate polygon, using the appropriate font, then get the bounds of the aggregate.

 

If the label is rotated, use the Rotator to rotate it to horizontal before stroking.

 

Badge
Hi @bakkermans,

 

The most accurate way to get the bounds of a text feature is to use the TextStroker to convert it to an aggregate polygon, using the appropriate font, then get the bounds of the aggregate.

 

If the label is rotated, use the Rotator to rotate it to horizontal before stroking.

 

I already tried that earlier on as a possible solution, however still without the right accuracy as a result. I suppose then there is nothing else to do about this?

Reply