0

I've got hundreds of SLDs that I want to update in a geoserver instance. All good for most of them but those that reference images fail to get updated.

For example:

      <PointSymbolizer>
        <Graphic>
          <ExternalGraphic>
            <OnlineResource xlink:href="symbols/airport.svg"/>
            <Format>image/svg+xml</Format>
          </ExternalGraphic>
          <Size>20</Size>
        </Graphic>
      </PointSymbolizer>

I know that the REST api does not support uploading the images but they already exist. If I just paste the sld into web page for the style in geoserver it accepts it and all is good. The problem would appear to be the upload code trying to resolve the link relative to the upload and not the final destination.

The error is

Caused by: java.net.MalformedURLException: no protocol: symbols/airport.svg

Does anyone know a way around this. Manually updating 100s of styles is simply not an option.

0

I work round this by copying the SLD files into the styles folder and then using REST to add the style to GeoServer:

payload="<style><name>$name</name><filename>$name.sld</filename></style>" 
curl -f -s -u admin:geoserver -XPOST -H 'Content-type: text/xml' -d "$payload" http://localhost:8080/geoserver/rest/styles 
1
  • I was hoping to be able to do this remotely without access to the file system.
    – vickirk
    May 13 '15 at 20:31
0

I failed to find a way in geoserver to do this. I had to knock up an additional servlet to run under tomcat that uploads files to the www directory, my slds can then use http://localhost/geoserver/www/symbols/airport.svg as the URL.

Happy to accept a better answer though.

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.