Sunday 1 July 2018

Removing Trailing Zeros in Geoserver SLD


I have maps from a PostGIS datastore in Geoserver. The map is styled using SLD created dynamically from my web apps. The problem is that sometimes, the map has float-type attribute data.



The label actually renders correctly using , but with a trailing zeros. e.g 0.850000000000. What I want is that it should render 0.85 instead of 0.850000000000.


Is there any way I can do that using the SLD?


I'm using Geoserver 2.6.1



Answer



This is a good question. The answer at Using simple Math in SLD file on Geoserver? may help here.


You could try something like this:




This multiplies the value of field_name by 100 (in the Mul section), rounds it to an integer (the "Round" function), then divides the result by 100 (the Div section).


You may need to experiment with the parameters but hopefully this approach will work for you.



No comments:

Post a Comment

arcpy - Changing output name when exporting data driven pages to JPG?

Is there a way to save the output JPG, changing the output file name to the page name, instead of page number? I mean changing the script fo...