0

I'm trying to accomplish an apparently simple task, to display some lines from a postgis table, but I don't know how to do it. The table has, say, 3 fields, one for the geometry and the other two have some value. I'd like to set the color of the line based on one of the fields, I'll call it field1, and to set the dash pattern of the line based on the second field (field2).

field1
value  color
1      black
2      red
3      green
...

field2
value  dash pattern
1      solid  (e.g. values for stroke-dasharray)
2      dot line
...

I know how to create a style to accomplish that but mixing the filters/rules for managing 2 fields is a mess. Using another language I'd use a function with 2 parameters (the values of field1 and field2) returning the values to use for stroke and stroke-dasharray. I searched the docs and the only thing I found out is the function Recode but, as I understand, it uses only one input parameter. I read the docs about Transformations but I assume that they must be created outside SLD, I think it'd be overkill for my needs. Is there a way to accomplish my task?

1 Answer 1

0

It seems as thought recode should do exactly what you want. You'll need two recode functions as you need to convert your color column into a stroke element and the line style column into a dash array. See the transforms tutorial for full syntax details.

2
  • Thank you. I had not noticed where the Recode function was used in the examples. :(
    – user32823
    Jun 26, 2014 at 12:16
  • Unfortunately Recode doen't work with stroke-dasharray: (osgeo-org.1560.x6.nabble.com/…)
    – user32823
    Jun 26, 2014 at 15:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.