NieuwlandGeo / SLDReader

SLD styling for online mapping libraries
https://nieuwlandgeo.github.io/SLDReader
MIT License
74 stars 21 forks source link

SLD 1.1.0 SvgParameter stroke-dasharray #140

Closed geraldo closed 1 year ago

geraldo commented 1 year ago

I noticed that some styles, like dashed lines using stroke-dasharray, do work fine using CssParameter (SLD v1.0), but not using SvgParameter (SLD v1.1). Would it be possible to make this available:

<se:SvgParameter name="stroke-dasharray">4 2</se:SvgParameter>

Seems related to this issue.

ajkopinga commented 1 year ago

I checked and SvgParameter stroke-dasharray looks like it's working (tested with v0.2.17). What might be the problem here is that the gaps between the dashes are quite small, so when dashes are rendered with a round cap, they will smear together into a bumpy line.

The default line cap style is system-dependent, so if you need a flat cap (butt), you'll have to use that style explicitly in your SLD, like the example below.

Does this solve your problem? If not, can you please add the SLD you're using?

<?xml version="1.0" encoding="UTF-8"?>
<StyledLayerDescriptor xmlns="http://www.opengis.net/se"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xmlns:xlink="http://www.w3.org/1999/xlink" xsi:schemaLocation="http://www.opengis.net/sld http://schemas.opengis.net/sld/1.1.0/StyledLayerDescriptor.xsd"
  xmlns:se="http://www.opengis.net/se" version="1.1.0"
  xmlns:ogc="http://www.opengis.net/ogc">
  <se:NamedLayer>
    <se:Name>Lines</se:Name>
    <se:UserStyle>
      <se:Name>Dashed line</se:Name>
      <se:FeatureTypeStyle>
        <se:Rule>
          <se:LineSymbolizer>
            <se:Stroke>
              <se:SvgParameter name="stroke">#4400AA</se:SvgParameter>
              <se:SvgParameter name="stroke-width">4</se:SvgParameter>
              <se:SvgParameter name="stroke-dasharray">4 2</se:SvgParameter>
              <se:SvgParameter name="stroke-linecap">butt</se:SvgParameter>
            </se:Stroke>
          </se:LineSymbolizer>
        </se:Rule>
      </se:FeatureTypeStyle>
    </se:UserStyle>
  </se:NamedLayer>
</StyledLayerDescriptor>
ajkopinga commented 1 year ago

I'm closing this issue. Please re-open if there's still a problem.