w8r / geojson2svg

Render geojson into SVG using inline or external stylesheet
https://w8r.github.io/geojson2svg/demo/
MIT License
66 stars 10 forks source link

Unable to change fill-rule for MultiPolygons #14

Closed dajoha closed 3 years ago

dajoha commented 3 years ago

There seems to be an operator precedence issue here:

https://github.com/w8r/geojson2svg/blob/f079c10ad3facf9f65aa6bacbd36e125433dafd5/src/renderer.js#L875-L876

Because of precedence, this code is interpreted like this:

currentStyle['fill-rule'] = (styles.fillRule || 
   (feature.geometry.type === 'MultiPolygon')) ? 'nonzero' : 'evenodd'; 

Because of this, it's not possible to set fill-rule to evenodd for MultiPolygons. In order to fix it, parentheses should be moved like this:

currentStyle['fill-rule'] = styles.fillRule || 
   (feature.geometry.type === 'MultiPolygon' ? 'nonzero' : 'evenodd');