imagico / jsdotpattern

Generator for random periodic dot and symbol patterns for use in map rendering
23 stars 6 forks source link

Mapnik-compatible SVGs #3

Closed pnorman closed 7 years ago

pnorman commented 9 years ago

Mapnik cannot make use of SVGs with <use/> to my knowledge. This is annoying, but unlikely to change by 3.0 release. A mode to generate a SVG without would be useful.

This does not matter with currently released versions of Mapnik, which do not support SVGs for polygon-patterns at all, and the output of this tool is extremely unlikely to be used with a point symbolizer.

imagico commented 9 years ago

Inlining every symbols will significantly blow up the file sizes so it will only be feasible for patterns with relatively few and simple symbols. But good to know this would be a requirement for use directly in Mapnik.

I am not too sure how useful svg patterns would actually be for direct use in rendering - much more useful would be if there was support for using grayscale pattern images to generate the actual pattern from the style.

imagico commented 9 years ago

Inlining of symbols is now possible but not tested in mapnik yet.

imagico commented 7 years ago

A script is now available that converts jsdotpattern SVGs into a Mapnik compatible form using inkscape. This is fairly ugly but there is no reasonable way to directly generate Mapnik compatible SVGs from within Snap (or other JS SVG libraries).

imagico commented 7 years ago

Apparently if the SVG content does not fully fill the bounding box Mapnik performs some kind of transform to the pattern that can break periodicity - see https://github.com/gravitystorm/openstreetmap-carto/pull/2685

You can work around this by using symbol offsets so the pattern symbols cross all edges of the bounding box but it should be possible to work around this from svg_pattern.sh by adding an invisible dummy geometry.

imagico commented 7 years ago

I hope this is now finally done by adding a dummy geometry in svg_pattern.sh.