Solved

Unexpected result with the Mapnik rasterizer using symbolizer SVG's

  • 16 August 2019
  • 8 replies
  • 7 views

Badge +7

I'm building a flow that uses the MapnikRasterizer for building a legend but getting some unexpected results. The flow below creates a object in creator 4 and the AC adds a URL/path of the SVG to this object. The MapnikRasterizer replaces this point with the SVG using the symbolizer marker and the URL created with the AC in the file parameter under the marker parameters. See the fmwt file below for the flow and the files.

0684Q00000ArCHSQA3.png

0684Q00000ArCehQAF.png

The hello.svg and hello2.svg works fine with this but getting some weird results when using the hatch.svg.

<?xml version="1.0"?>
<svg xmlns="http://www.w3.org/2000/svg" version="1.1" baseProfile="full" width="122" height="122">  <g transform="translate(0 0)">
</g>  <g transform="translate(0 0)">    <rect x="0.5" y="0.5" width="21" height="21" fill="#ffff40" fill-opacity="1" stroke="#000000" stroke-width="1" stroke-dasharray=""/>    <pattern id="D3B19CBA-2005-7FB3-52A547FFC3CD3D34" patternUnits="userSpaceOnUse" width="115" height="18">      <path style="stroke:black; stroke-width:1" fill-opacity="0" d="M2,0 l1,1 M1,9 l1,1 M1,17 l1,1 M11,0 l2,0 0,1 -3,0 M8,6 l1,1 M9,9 l1,1 M12,8 l1,1 M21,6 l2,0 0,3 M20,7 l4,0 M18,14 l1,1 M22,16 l2,0 M26,17 l1,1 M29,15 l1,1 M30,5 l1,1 M31,1 l2,0 0,3 M30,2 l2,0 M37,4 l1,1 M38,5 l1,1 M38,8 l1,1 M34,2 l1,1 M37,14 l1,1 M40,14 l1,1 M38,17 l2,0 M48,3 l1,1 M52,3 l0,2 -2,0 M53,8 l1,1 M51,9 l1,1 M51,12 l1,1 M58,12 l1,1 M57,15 l1,1 M61,9 l1,1 M62,10 l1,1 M62,8 l2,0 0,2 M65,1 l2,0 M67,6 l1,1 M68,9 l1,1 M66,10 l1,1 M65,11 l1,1 M72,0 l1,1 M72,4 l0,3 -2,0 M76,9 l1,1 M74,12 l1,1 M83,3 l1,1 M81,8 l1,1 M83,9 l1,1 M84,0 l3,0 0,2 M90,9 l1,1 M93,7 l0,2 -3,0 M92,6 l0,2 M94,16 l1,1 M93,17 l1,1 M95,6 l1,1 M100,0 l1,1 M100,6 l1,1 M98,10 l1,1 M102,10 l2,0 0,3 M101,11 l2,0 M104,16 l1,1 M106,6 l1,1 M109,4 l1,1 M109,14 l1,1 M111,5 l1,1 M110,0 l4,0 0,2 -4,0 M112,8 l1,1 M111,9 l3,0 0,3"/>    </pattern>    <rect x="0.5" y="0.5" width="21" height="21" fill="url(#D3B19CBA-2005-7FB3-52A547FFC3CD3D34)"/>  </g>
</svg>

Expecting this:

0684Q00000ArCw1QAF.png

but getting this:

0684Q00000ArD2NQAV.png

icon

Best answer by gio 22 August 2019, 12:50

View original

8 replies

Userlevel 1
Badge +21
Are you able to attach the svg files, they point to a location on your machine in the template file
Badge +7
Are you able to attach the svg files, they point to a location on your machine in the template file

I had them attachted in the fmwt but it looks like they are not really shown when opening. (You could always rename the .fmwt to zip and then extract it but i get that this is nor really an option :p )

I will try to add them in a zip. Uploaduing a single SVG file was not allowed.

Badge +7

Here is a zip with the seperate SVG's inside. The helloo files are correct and the hatch.svg is not working correctly.

 

temp.zip

Badge +3

@jdh009

 

Hi.

 

That effect is caused by using a Marker symboliser without any Width and Height setting.

 

Try out values like 50;50. Then your svg will show up inside the polygon.

(i think fiddling with size will be needed to get it right. 80;80 seems a good setting)

For Mapnik site says:

Symbolizer that specifies rendering of a tiff, png or svg image as a directional marker.

Note the "directional"

Badge +7

@jdh009

 

Hi.

 

That effect is caused by using a Marker symboliser without any Width and Height setting.

 

Try out values like 50;50. Then your svg will show up inside the polygon.

(i think fiddling with size will be needed to get it right. 80;80 seems a good setting)

For Mapnik site says:

Symbolizer that specifies rendering of a tiff, png or svg image as a directional marker.

Note the "directional"

What kind of settings do you use besides the 80,80? I'm adding sizes to the properties but getting only unexplainable shapes back. Would you mind posting an image?

Badge +3

@jdh009

 

Hi,

The svg "hatch" is a a 2 layer goup.

1 layer is a rectangle with a 1px width.

The other layer is a pattern layer. It has a pattern that will be repeated (like tiles) depening on size and scale.

 

You can see this in Inkscape (for instsance, open source).

So, the big black feature you see, is the border of the rectangle layer.

The seemingly wild fill is the pattern; repeated, strechted etc. depending on the feature you are aplying it to and the settings in Mapnik.

 

Svg layers split:

 

And the pattern rescaled and stretched:

 

 

Badge +3

@jdh009

You can prevent this issue by turning the svg marker's pattern to "objects" using (for instance) Inkscape.

(object=>pattern=>pattern2object)

Save it svg with new filename and use.

You still need to use width and height settings, but result will be more like

Here is a pattern2 object marker with width and height setting equal to raster cell and column count (make the entire object fit):

 

only a bit of the black border fits

 

remember: it is a directional marker, it will warp things as is vissible in the picture.

The actual used converted pattern i used looks like:

 

Using a directional marker on a polygon kind a forces you to fiddle with the values.

I would use a raster and apply it to the polygon.

Check https://github.com/mapnik/mapnik/wiki/MarkersSymbolizer

 

Succes!

 

 

 

Badge +7

@jdh009

You can prevent this issue by turning the svg marker's pattern to "objects" using (for instance) Inkscape.

(object=>pattern=>pattern2object)

Save it svg with new filename and use.

You still need to use width and height settings, but result will be more like

Here is a pattern2 object marker with width and height setting equal to raster cell and column count (make the entire  object fit):

0684Q00000ArJtLQAV.png

 

only a bit of the black border fits

 

remember: it is a directional marker, it will warp things as is vissible in the picture.

The actual used converted pattern i used looks like:

0684Q00000ArKePQAV.png

 

Using a directional marker on a polygon kind a forces you to fiddle with the values.

I would use a raster and apply it to the polygon.

Check https://github.com/mapnik/mapnik/wiki/MarkersSymbolizer

 

Succes!

 

 

 

Thanks, this seems to work like charm. Hope that i can automate this somehow but that is the next step.

I still needed to remove the pattern after i altered the svg in inkscape:

 <pattern
       id="D3B19CBA-2005-7FB3-52A547FFC3CD3D34"
       patternUnits="userSpaceOnUse"
       width="115"
       height="18">
      <path
         style="stroke:black; stroke-width:1"
         fill-opacity="0"
         d="M2,0 l1,1 M1,9 l1,1 M1,17 l1,1 M11,0 l2,0 0,1 -3,0 M8,6 l1,1 M9,9 l1,1 M12,8 l1,1 M21,6 l2,0 0,3 M20,7 l4,0 M18,14 l1,1 M22,16 l2,0 M26,17 l1,1 M29,15 l1,1 M30,5 l1,1 M31,1 l2,0 0,3 M30,2 l2,0 M37,4 l1,1 M38,5 l1,1 M38,8 l1,1 M34,2 l1,1 M37,14 l1,1 M40,14 l1,1 M38,17 l2,0 M48,3 l1,1 M52,3 l0,2 -2,0 M53,8 l1,1 M51,9 l1,1 M51,12 l1,1 M58,12 l1,1 M57,15 l1,1 M61,9 l1,1 M62,10 l1,1 M62,8 l2,0 0,2 M65,1 l2,0 M67,6 l1,1 M68,9 l1,1 M66,10 l1,1 M65,11 l1,1 M72,0 l1,1 M72,4 l0,3 -2,0 M76,9 l1,1 M74,12 l1,1 M83,3 l1,1 M81,8 l1,1 M83,9 l1,1 M84,0 l3,0 0,2 M90,9 l1,1 M93,7 l0,2 -3,0 M92,6 l0,2 M94,16 l1,1 M93,17 l1,1 M95,6 l1,1 M100,0 l1,1 M100,6 l1,1 M98,10 l1,1 M102,10 l2,0 0,3 M101,11 l2,0 M104,16 l1,1 M106,6 l1,1 M109,4 l1,1 M109,14 l1,1 M111,5 l1,1 M110,0 l4,0 0,2 -4,0 M112,8 l1,1 M111,9 l3,0 0,3"
         id="path6" />
    </pattern>

 

Getting this as result:

0684Q00000ArMCsQAN.png

 

Reply