Aug 24, 2016

Geoserver slice string values using SLD for label manipulation

I have an attribute column in my PostGIS polygon table and want to only show the first 2 characters of this text field on my label using SLD in Geoserver.  My goal is to place the label at the center of the polygon so here it goes in SLD xml syntax as usual very verbose and ugly.

              <ogc:Function name="centroid">

              <ogc:Function name="strSubstring">
                  <ogc:Function name="parseInt">
                  <ogc:Function name="parseInt">                            

My table column name is "short_name"  and the geometry column name is "geom".  This works and creates my label in the center of the polygon only drawing the first 2 characters from the field "short_name".

I hope this helps :)

No comments:

Post a Comment