Biểu trưng OpenStreetMap OpenStreetMap

Grouping Mapnik's labels

Do Zverik đăng vào 29 tháng 04 năm 2014 bằng English.

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.

Biểu tượng thư điện tử Biểu tượng Bluesky Biểu tượng Facebook Biểu tượng LinkedIn Biểu tượng Mastodon Biểu tượng Telegram Biểu tượng X

Thảo luận

Bình luận của Endres Pelka vào 29 tháng 4 năm 2014 lúc 12:37

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

Bình luận của Zverik vào 29 tháng 4 năm 2014 lúc 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.

Đăng nhập để nhận xét