[GIS] Geoserver SLD Line styling with external graphic instead of WellKnownName

geoserverlinesldstylesvg

I have problem with styling in geoserver.
Using tutorial from https://docs.geoserver.org/stable/en/user/styling/sld/cookbook/lines.html#id7
everything is ok but when I want to use ExternalGraphic instead of WKN symbol nothing happend.

My sld file look like:

<?xml version="1.0" encoding="UTF-8"?>
<sld:UserStyle xmlns:sld="http://www.opengis.net/sld" xmlns="http://www.opengis.net/sld" xmlns:gml="http://www.opengis.net/gml" xmlns:ogc="http://www.opengis.net/ogc">
    <sld:Name>Default Styler</sld:Name>
    <sld:FeatureTypeStyle>
        <sld:Name>name</sld:Name>
        <sld:Rule>
            <sld:LineSymbolizer>
                <sld:Stroke>
                    <sld:GraphicStroke>
                        <sld:Graphic>
                            <sld:ExternalGraphic>
                                <sld:OnlineResource xmlns:xlink="http://www.w3.org/1999/xlink" xlink:type="simple" xlink:href="http://127.0.0.1/svg2.svg" />
                                <sld:Format>image/svg</sld:Format>
                            </sld:ExternalGraphic>
                            <sld:Size>16</sld:Size>
                        </sld:Graphic>
                    </sld:GraphicStroke>
                </sld:Stroke>
            </sld:LineSymbolizer>
        </sld:Rule>
    </sld:FeatureTypeStyle>
</sld:UserStyle>

Someone of you know why it happens?

BTW I try make it work because I need line on my wms looking like
http://wms.e-mapa.net/cgi-bin/mapserv?map=/home/www/egmina/implementation/czerwonak/pln/wms/mpzp.map&VERSION=1.1.1&SERVICE=WMS&REQUEST=GetMap&LAYERS=lzb&SRS=EPSG:2180&BBOX=364177.88820526295,519023.6162198745,364271.63820526295,519054.7197354995&WIDTH=1920&HEIGHT=637&TRANSPARENT=TRUE&FORMAT=image/png&styles=,,,,,&unique=3971

Thanks for any help.

Best Answer

The first thing to check is that you can open http://127.0.0.1/svg2.svg in your browser. I suspect that is the problem.

The easy way to use an external graphic is to put it in the styles directory and refer to it using a relative path - I use something like:

<Graphic>
   <ExternalGraphic>
       <OnlineResource
              xmlns:xlink="http://www.w3.org/1999/xlink"
              xlink:type="simple"
              xlink:href="osmmsymbols/foreshorePattern.svg"/>
        <Format>image/svg+xml</Format>
     </ExternalGraphic>
     <Size>3</Size>
     <Rotation>0</Rotation>
  </Graphic>
Related Question