Version 1.1 of the Symbology Encoding Implementation Specification defines SLD functions that you can use as expressions in your style definitions. SLD functions allow you to express complex but often-needed styling logic in just a few lines. For instance, you can use such an SLD function to transform continuous property values into discrete values, or to apply date and number formatting.
The LuciadLightspeed API supports these SLD functions through TLcdSLDFunction
and its subclasses:
Transformation function | Description |
---|---|
Transforms continuous values into discrete values, to assign specific colors to specific value ranges, for example |
|
Transforms continuous values into another continuous value range, to assign a continuous color range to a value range, for example |
|
Transforms discrete values into other discrete values, to assign colors to specific values, for example |
String function | Description |
---|---|
Changes the case of a string |
|
Concatenates strings |
|
Returns the length of a string |
|
Returns the position of the first occurrence of a lookup string in a string value |
|
Returns sub-strings of a given string |
|
Trims trailing and leading characters from a string value |
Formatting function | Description |
---|---|
Formats dates according to well-known date formatting patterns |
|
Formats numbers into a human-readable format |
Using the string and formatting functions, you can adjust the content of labels in style definitions, while the transformation functions can help you with thematic styling. This example illustrates how you can use the SLD recode function to determine the fill color for US states based on their FIPS codes:
<FeatureTypeStyle xmlns="http://www.opengis.net/se"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.opengis.net/se http://schemas.opengis.net/se/1.1.0/FeatureStyle.xsd"
version="1.1.0">
<Rule>
<MinScaleDenominator>0.0</MinScaleDenominator>
<MaxScaleDenominator>INF</MaxScaleDenominator>
<PolygonSymbolizer>
<Fill>
<SvgParameter name="fill">
<Recode>
<LookupValue>
<ogc:PropertyName>STATE_FIPS</ogc:PropertyName>
</LookupValue>
<MapItem>
<!-- Washington -->
<Data>53.0</Data>
<Value>#FF0000</Value>
</MapItem>
<MapItem>
<!-- New York -->
<Data>36.0</Data>
<Value>#00FF00</Value>
</MapItem>
...
</Recode>
</SvgParameter>
</Fill>
<Stroke>
<SvgParameter name="stroke-opacity">
<ogc:Literal>1.0</ogc:Literal>
</SvgParameter>
<SvgParameter name="stroke-width">
<ogc:Literal>2</ogc:Literal>
</SvgParameter>
<SvgParameter name="stroke">
<ogc:Literal>#000000</ogc:Literal>
</SvgParameter>
</Stroke>
</PolygonSymbolizer>
</Rule>
</FeatureTypeStyle>
Luciad offers equivalents for some of these functions in its OGC filter API, the string trim function and the recode function
for example. There can be small differences between the SLD and filter functions. For instance, while you can only map numbers
with the SLD recode function, you can also map strings with the OGC filter recode function. See |