Wednesday, 3 October 2018

geoserver - Using Math in SLD file - wkt


Is it possible to use math in SLD file in Geotools? I want to get Orientation for lines and calculate its sine/cosine and then multiply it with some value. But when I do this nothing shows up. Here is part polygon symbolizer that I am using.






the_geom
Buffer






wkt://LINESTRING(
0

0,

Orientation
200

33 )


#000000
1







Function for multiplication is



Orientation
200



for sine I am not sure what function is, but it doesn't work when only multiplication is used. This is needed because when adding hatches to objects, there is need to draw a hatch with angle of 45 to one side of object. Something like this, but when object is rotated by some angle.


goal



Answer



You can do math in SLD in most places, but a WellKnownMark element is not one of them.


This is what the standard says, GeoServer has a custom extension allowing to stick a CQL expression in the middle of a mark name like this:


wkt://LINESTRING(0 0, ${Orientation * 200} 33)


I could not try it out, but it should work.


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...