開放街圖標誌 OpenStreetMap 開放街圖

Grouping Mapnik's labels

於 2014年四月29日 由 ZverikEnglish發表。

If you tried rendering quality maps with Mapnik, you know its label placement is awful. Just a bit better than throwing labels on map at random. So for printing, postprocessing in a vector editor is mandatory.

If you tried editing Mapnik-generated SVG, you know it is completely unstructured. Which means, if you need to move a label, first you have to select all of its letters one by one, and then its casing, also letter by letter. And there will be a lot of frustration when you select roads underneath the label, or lose selection.

Yesterday I’ve made a small script that takes Mapnik SVG, finds labels and wraps them in groups. So when you open that SVG in Inkscape, you will move labels not by letter, but as a whole.

https://github.com/Zverik/mapnik-group-text

The only parameter, -d, controls the maximum width of a letter, including spacing between letters. The default works for me, but if your labels are tightly packed, or are printed in a very large font, you may need to use that parameter.

電子郵件圖示 藍天圖示 Facebook 圖示 LinkedIn 圖示 乳齒象圖示 Telegram 圖示 X 圖示

討論

Endres Pelka2014年04月29日 12時37分 發表的評論

It would be better if Mapnik did it on its own when generating SVG.

Zverik2014年04月29日 13時33分 發表的評論

Of course, hard to argue with that. Sadly I don’t see even tickets in github tracker on that: closest thing is layered svg (which tilemill still does not produce). I’ve opened issue 2229.

登入 來留下評論