Question

Using multi-line labels with MapnikRasterizer


Badge

Hi,

I am trying to create a multi-line label as a part of mapnik rendering. I use a string concatenator to for a a label (e.g. "top label" + newline + "bottom label" and then I render it along a line/segment. What happens is that label is rendered on the top of line/segment as ONE long label. Somehow, Mapnik doesn't honor my multi-line label representation. I tried it with FME Desktop 2015/2016.

What I would like to have:

text top

---------------------

text bottom

instead I have, 'text top [square symbol] text bottom' over a segment/line.

I appreciate any advice on this issue.

Thank you,

Alexander


10 replies

Userlevel 2
Badge +16

Have you tried using the TextStroker before the MapnikRasterizer?

Badge

Thank you for your prompt response. I am not sure if TextStroker can be helpful. I added a figure below to clarify my issue with the multi-line label - it looks that Mapnik doesn't process the new line character within the label.

Userlevel 2
Badge +16

Thank you for your prompt response. I am not sure if TextStroker can be helpful. I added a figure below to clarify my issue with the multi-line label - it looks that Mapnik doesn't process the new line character within the label.

By using the TextStroker you convert the text to a (line or polygon) geometry. I tried it and the newline is handled correctly by the TextStroker.

Userlevel 4
Badge +25

@alexandervstepa

If you use the StringConcatenator then click the Newline special character instead of typing \\n

That gives you a special character "LF" that works OK (at least it does for me in FME 2016.1)

Make sure Show Spaces/Tabs is turned on in the options of the StringConcatenator editor

The result is this:

Badge +3

A newline is actually \\r\\n

It is a carriage return followed by a linefeed.

Remember the physical type writer?

You can even choose them in the texteditor in most transformers.

A newline can indeed by picked in a stringconcatenator. (wich i don't use mouch as mostly one can acces a texteditor)

Badge

@alexandervstepa

If you use the StringConcatenator then click the Newline special character instead of typing \\n

That gives you a special character "LF" that works OK (at least it does for me in FME 2016.1)

Make sure Show Spaces/Tabs is turned on in the options of the StringConcatenator editor

The result is this:

Mark, thank you for your answer. I did exactly that in the beginning. The problem happens with multi-line labels oriented along the lines. As soon as I select a labeling around a point - everything works fine. I am not able to do multi-level labels with orientation along a line.

Badge

A newline is actually \\r\\n

It is a carriage return followed by a linefeed.

Remember the physical type writer?

You can even choose them in the texteditor in most transformers.

A newline can indeed by picked in a stringconcatenator. (wich i don't use mouch as mostly one can acces a texteditor)

Gio, thank you for your comment. I tried that as well - it looks the problem happens if the label is oriented along an edige/line - in such case Mapnik doesn't take a new line into account during label placement.

Badge

By using the TextStroker you convert the text to a (line or polygon) geometry. I tried it and the newline is handled correctly by the TextStroker.

Hi Eric,

I will try to experiment with TextStroker.

Thank you.

Userlevel 4
Badge +25

@alexandervstepa

If you use the StringConcatenator then click the Newline special character instead of typing \\n

That gives you a special character "LF" that works OK (at least it does for me in FME 2016.1)

Make sure Show Spaces/Tabs is turned on in the options of the StringConcatenator editor

The result is this:

Ah, OK. I'll test that when I'm in the office next and file a bug report with the developers.

Badge +3

@alexandervstepa

hmm... at an old post again..

use an attribute splitter, explode the list.

index= 0 and index 1 seperate inputs on MNR (same geometry of course)

Ofset 1 above the line and other below.

(but thats 2 years too late...lol)

Reply