1

I want to make a map of traffic signs by using .svg image files of the traffic signs as point symbols. I put all the svg-files in the folder 'styles' in the data_dir of Geoserver (on my localhost). But for some reason, only grey squares appear, instead of the images. I am certain the files are placed in the correct folder. This is an excerpt of my SLD:

<?xml version="1.0" encoding="UTF-8"?> <StyledLayerDescriptor version="1.0.0" xmlns="http://www.opengis.net/sld" xmlns:ogc="http://www.opengis.net/ogc" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.opengis.net/sld http://schemas.opengis.net/sld/1.0.0/StyledLayerDescriptor.xsd"> <NamedLayer> <Name>Traffic</Name> <UserStyle> <Name>trafficsign</Name> <FeatureTypeStyle> <Rule> <Title>08970150-8c69-4c99-98d3-c2bd86035ac6</Title> <ogc:Filter> <ogc:PropertyIsEqualTo> <ogc:PropertyName>img</ogc:PropertyName> <ogc:Literal>955544_aanzicht1.svg</ogc:Literal> </ogc:PropertyIsEqualTo> </ogc:Filter> <PointSymbolizer> <Graphic> <ExternalGraphic> <OnlineResource xlink:type="simple" xlink:href="955544_aanzicht1.svg" /> <Format>image/svg+xml</Format> </ExternalGraphic> <Size> <ogc:Literal>60</ogc:Literal> </Size> </Graphic> </PointSymbolizer> </Rule>

I must also say, that it did work when I uploaded a png-file to imgbb.com to create a URL, and copy/pasted the URL in the SLD. But it really seems like a lot of work to individually upload images and copy/pasting the URL in the SLD file (especially when dealing with close to a thousand different traffic signs).

Is there any reason why geoserver won't show my svg-files when using the relative path?

2

I have a bunch of OS styles that work fine using the following syntax:

    <Rule>
      <Name>Triangulation Station - 1:1,000 to 1:5,001</Name>
      <ogc:Filter>       
        <ogc:PropertyIsEqualTo>
          <ogc:PropertyName>featurecode</ogc:PropertyName>
          <ogc:Literal>15408</ogc:Literal>
        </ogc:PropertyIsEqualTo>
      </ogc:Filter>
      <MinScaleDenominator>1000</MinScaleDenominator>
      <MaxScaleDenominator>5001</MaxScaleDenominator>
      <PointSymbolizer uom="http://www.opengeospatial.org/se/units/metre">
        <Graphic>
          <ExternalGraphic>
            <OnlineResource xlink:type="simple" xlink:href="ordnance_survey/triangulationStationSymbol-fc.svg"/>
            <Format>image/svg+xml</Format>
          </ExternalGraphic>
          <Size>20</Size>
        </Graphic>
      </PointSymbolizer>
    </Rule> 

So yours should work.

Things that can go wrong include:

  1. tomcat (or whoever is running GeoServer) can not read the file.
  2. the style is in a workspace and you have placed the SVG file in the style directory instead of workspace/style.
  3. Maybe GeoServer likes a directory ref in there - try ./955544_aanzicht1.svg
  4. your SVG is corrupt?

Note to save on the filtering you can use the file name directly in the SLD from the property:

<Graphic>
  <ExternalGraphic>
    <OnlineResource
        xmlns:xlink="http://www.w3.org/1999/xlink"
        xlink:type="simple"
        xlink:href="osmmsymbols/${os_cat}.svg"/>
     <Format>image/svg+xml</Format>
  </ExternalGraphic>
  <Size>50</Size>
  <Rotation>0</Rotation>
</Graphic>

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.