3

I'm working with TextSymbolizer in Mapnik. I have a shapefile with a attribute which is a real. I wish to print the value of this attribute as integer and I don't find how I can do it in Mapnik.

I must not change the source shapefile. Can someone advise of the recommended way to do this?

2

Not having found a solution to do exactly what I want, I bypassed the problem using a regular expression. If the real attribute is 'VAL' and the decimal separator is '.':

<TextSymbolizer placement = "line" fontset-name = "fontset-0" size = "11" dy = "-4" halo-fill = "rgba (255, 255, 255, 0.5)" halo-radius = "1" > 
<! [CDATA [[VAL]. replace ('\. [0-9] +','')]]>
</ TextSymbolizer>
  • I did not have to use the CDATA, and changed the expression to [VAL].replace ('\.[0-9]+',''). Other than that, great solution! – Liedman Feb 25 at 15:13

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.