0

I'm trying to get dynamic icon loading based on an attribute in GeoServer 2.9

My SLD:

<sld:ExternalGraphic>
    <sld:OnlineResource xmlns:xlink="http://www.w3.org/1999/xlink" xlink:type="simple" xlink:href="icons/$(strReplace(strReplace(iconPath,'.','/',true),'/vsd','.bmp', false)"/>
    <sld:Format>image/bmp</sld:Format>
</ExternalGraphic>

iconpath attribute example:

Spot.Undefiend Spot.vsd

wanted url path:

icons/Spot/Undefiend Spot.bmp

I can't seem to get this working, the log isn't helpful either.

2

If you read the strReplace documentation you will see that it is a thin wrapper around the Java replace method and provides a link to the Pattern Rules. This means that your function:

strReplace(iconPath,'.','/',true)

will replace every character (a . matches any character) in iconPath with a / - clearly not what you want. I would try something like:

$(strReplace(strReplace(iconPath,'\.','/',false),'\.vsd$','.bmp$', false)

I'm fairly sure turning the logging level up to Developer will show you what is being searched for. One other trick for debugging this sort of issue is to use a TextSymboliser to print the result in a label.

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.