1

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.

4

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>
  • In case that your file is not accepted and GeoServer throws a Can't parse yourFile.svg as a java resource present in the classpath in the logs, try to specify the absolute file path in the SLD file instead of a relative one, e.g. file:///geoserver_data/styles/yourFile.svg. This helped me when I encountered this issue. – Dirk Sep 14 '15 at 16:14
  • 1
    Don't forget if your style is owned by a workspace you need to add the folder under the styles directory. – Magno C Jun 13 '16 at 12:40

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.