1

I have been developing a dot density map using certain attributes and have been successful in doing so. But there has been a problem while getting the legend from geoserver wms using a getlegendgraphic request. What I get is shown below:

sld from geoserver

What I want is like the ones for <5 and not specified not with the diagonal line in between. A snippet of my sld is below:

 <sld:Rule>
      <sld:Title>Not Specified</sld:Title>
      <sld:LineSymbolizer>
        <sld:Stroke>
          <sld:CssParameter name="stroke">#1A8C8C</sld:CssParameter>
          <sld:CssParameter name="stroke-dasharray">2.0 4.0</sld:CssParameter>
        </sld:Stroke>
      </sld:LineSymbolizer>
      <sld:PolygonSymbolizer>
        <sld:Fill>
          <sld:CssParameter name="fill">#F1EBEB</sld:CssParameter>
        </sld:Fill>
        <sld:Stroke/>
      </sld:PolygonSymbolizer>
    </sld:Rule>
    <sld:Rule>
      <sld:Title>&lt; 5</sld:Title>
      <ogc:Filter>
        <ogc:PropertyIsLessThan>
          <ogc:PropertyName>total</ogc:PropertyName>
          <ogc:Literal>5</ogc:Literal>
        </ogc:PropertyIsLessThan>
      </ogc:Filter>
      <sld:PolygonSymbolizer>
        <sld:Fill>
           <sld:GraphicFill>
                            <sld:Graphic>
                                <sld:Mark>
                                    <sld:WellKnownName>shape://dot</sld:WellKnownName>
                                    <sld:Fill/>
                                    <sld:Stroke>
                                        <sld:CssParameter name="stroke">#fd849c</sld:CssParameter>
                                        <sld:CssParameter name="stroke-width">3.0</sld:CssParameter>
                                    </sld:Stroke>
                                </sld:Mark>
                                <sld:Size>10.0</sld:Size>
                            </sld:Graphic>
                        </sld:GraphicFill>
        </sld:Fill>
        <sld:Stroke/>
      </sld:PolygonSymbolizer>

    </sld:Rule>
    <sld:Rule>
      <sld:Title>5 - 10</sld:Title>
      <ogc:Filter>
        <ogc:And>
          <ogc:PropertyIsGreaterThanOrEqualTo>
            <ogc:PropertyName>total</ogc:PropertyName>
            <ogc:Literal>5</ogc:Literal>
          </ogc:PropertyIsGreaterThanOrEqualTo>
          <ogc:PropertyIsLessThan>
            <ogc:PropertyName>total</ogc:PropertyName>
            <ogc:Literal>10</ogc:Literal>
          </ogc:PropertyIsLessThan>
        </ogc:And>
      </ogc:Filter>
      <sld:PolygonSymbolizer>
        <sld:Fill>
           <sld:GraphicFill>
                            <sld:Graphic>
                                <sld:Mark>
                                    <sld:WellKnownName>shape://dot</sld:WellKnownName>
                                    <sld:Fill/>
                                    <sld:Stroke>
                                        <sld:CssParameter name="stroke">#fd849c</sld:CssParameter>
                                        <sld:CssParameter name="stroke-width">3.0</sld:CssParameter>
                                    </sld:Stroke>
                                </sld:Mark>
                                <sld:Size>8</sld:Size>
                            </sld:Graphic>
                        </sld:GraphicFill>
        </sld:Fill>
      </sld:PolygonSymbolizer>
      <sld:LineSymbolizer>
        <sld:Stroke/>
      </sld:LineSymbolizer>

    </sld:Rule>
    <sld:Rule>
      <sld:Title>10 - 20</sld:Title>
      <ogc:Filter>
        <ogc:And>
          <ogc:PropertyIsGreaterThanOrEqualTo>
            <ogc:PropertyName>total</ogc:PropertyName>
            <ogc:Literal>10</ogc:Literal>
          </ogc:PropertyIsGreaterThanOrEqualTo>
          <ogc:PropertyIsLessThan>
            <ogc:PropertyName>total</ogc:PropertyName>
            <ogc:Literal>20</ogc:Literal>
          </ogc:PropertyIsLessThan>
        </ogc:And>
      </ogc:Filter>
      <sld:PolygonSymbolizer>
        <sld:Fill>
           <sld:GraphicFill>
                            <sld:Graphic>
                                <sld:Mark>
                                    <sld:WellKnownName>shape://dot</sld:WellKnownName>
                                    <sld:Fill/>
                                    <sld:Stroke>
                                        <sld:CssParameter name="stroke">#fd849c</sld:CssParameter>
                                        <sld:CssParameter name="stroke-width">3.0</sld:CssParameter>
                                    </sld:Stroke>
                                </sld:Mark>
                                <sld:Size>6</sld:Size>
                            </sld:Graphic>
                        </sld:GraphicFill>
        </sld:Fill>
      </sld:PolygonSymbolizer>
      <sld:LineSymbolizer>
        <sld:Stroke/>
      </sld:LineSymbolizer>

    </sld:Rule>

Thanks in advance.

2

In the two styles that work you have a simple polygon symboliser with a fill and stroke while the ones that don't have a polygon symboliser with a fill and a line symboliser with the stroke. So the legend that is drawn is different because that's what you asked for.

If you move the stroke into the polygon for the other ones all will be well.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.