0

I'm trying to create a layer style that displays point data as upward/downward triangles depending on if the property value is higher or lower than the provided variable substitution value. The examples I've seen online have compared variable substitution to literals, but not a property.

I'm not getting the expected symbology knowing which values are higher and lower. I suspect the input value is not being parsed as a float so the comparison is failing (see logs below)?

If so, how would I force it to parse the input as a float?

<?xml version="1.0" encoding="ISO-8859-1"?>
<StyledLayerDescriptor version="1.0.0" 
    xsi:schemaLocation="http://www.opengis.net/sld StyledLayerDescriptor.xsd" 
    xmlns="http://www.opengis.net/sld" 
    xmlns:ogc="http://www.opengis.net/ogc" 
    xmlns:xlink="http://www.w3.org/1999/xlink" 
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <NamedLayer>
    <Name>Test</Name>
    <UserStyle>
      <Title>Test</Title>
      <FeatureTypeStyle>

        <Rule>
          <Title>Downward Triangle</Title>
          <ogc:Filter>
              <ogc:PropertyIsLessThan>
                <ogc:PropertyName>value</ogc:PropertyName>
                <ogc:Function name="env">
                  <ogc:Literal>input</ogc:Literal>
                </ogc:Function>
              </ogc:PropertyIsLessThan>        
          </ogc:Filter>          
          <PointSymbolizer>
            <Geometry><ogc:PropertyName>geom</ogc:PropertyName></Geometry>
            <Graphic>
              <Mark>
                <WellKnownName>triangle</WellKnownName>
                <Fill>
                  <CssParameter name="fill">#1E88E5</CssParameter>
                </Fill>
                <Stroke>
                  <CssParameter name="stroke">#000000</CssParameter>
                  <CssParameter name="stroke-width">0.5</CssParameter>
                </Stroke>                
              </Mark>
              <Size>8</Size>
              <Rotation>180.0</Rotation>
            </Graphic>            
          </PointSymbolizer>
        </Rule>

        <Rule>
          <Title>Upward Triangle</Title>
          <ogc:Filter>
              <ogc:PropertyGreaterThan>
                <ogc:PropertyName>value</ogc:PropertyName>
                <ogc:Function name="env">
                  <ogc:Literal>input</ogc:Literal>
                </ogc:Function>
              </ogc:PropertyGreaterThan>                 
          </ogc:Filter>          
          <PointSymbolizer>
            <Geometry><ogc:PropertyName>geom</ogc:PropertyName></Geometry>
            <Graphic>
              <Mark>
                <WellKnownName>triangle</WellKnownName>
                <Fill>
                  <CssParameter name="fill">#1E88E5</CssParameter>
                </Fill>
                <Stroke>
                  <CssParameter name="stroke">#000000</CssParameter>
                  <CssParameter name="stroke-width">0.5</CssParameter>
                </Stroke>                
              </Mark>
              <Size>8</Size>
            </Graphic>            
          </PointSymbolizer>
        </Rule>               
                
      </FeatureTypeStyle>
    </UserStyle>
  </NamedLayer>
</StyledLayerDescriptor>

http://service.com:8080/geoserver/wms?service=WMS&version=1.1.0&request=GetMap&layers=[...]&env=input:27.355485916

(pertinent info from Geoserver developer logs)

12 008 19:08:25 TRACE  [renderer.style] - trying to render symbol triangle
12 008 19:08:25 TRACE  [renderer.style] - rendering mark @ PointRenderer triangle
12 008 19:08:25 TRACE  [renderer.style] - fetching mark of name triangle
12 008 19:08:25 TRACE  [renderer.style] - returning triangle
12 008 19:08:25 TRACE  [renderer.style] - trying to render symbol triangle
12 008 19:08:25 TRACE  [renderer.style] - rendering mark @ PointRenderer triangle
12 008 19:08:25 TRACE  [renderer.style] - fetching mark of name triangle
12 008 19:08:25 TRACE  [renderer.style] - returning triangle
...
12 036 20:36:29 TRACE  [geoserver.ows] - Could not find kvp parser for: 'input'. Storing as raw string.

2 Answers 2

0

Your PropertyName etc tags are in the wrong namespace. Try something like:

     <ogc:Filter>
          <ogc:PropertyIsLessThan>
            <ogc:PropertyName>property</ogcPropertyName>
            <ogc:Function name="env">
              <ogc:Literal>input</ogc:Literal>
            </ogc:Function>
          </ogc:PropertyIsLessThan>        
      </ogc:Filter>
3
  • ah, ya I had still left that off from previous experimenting, thanks. That got rid of the validation errors, but it still doesn't seem to be comparing the values correctly. I'm getting some with upward and downward symbology and some that shouldn't be upward. Is it parsing the input to a float value or is it comparing a string to a float perhaps? Jul 12, 2023 at 14:48
  • hard to tell, edit your question with the new log file
    – Ian Turton
    Jul 12, 2023 at 16:03
  • ok I edited the post and included logs that seemed pertinent Jul 12, 2023 at 20:49
0

It looks like the parser is trying to understand a raw value of input rather than your environment variable. I find it best to add a TextSymbolizer that includes both input and value in the label to help check what is actually being passed into the renderer.

1
  • I did as you suggested, the labels were showing the correct value, then I realized there's a typo... PropertyGreaterThan not PropertyIsGreaterThan. It works now, I'd be open to deleting this post since it doesn't offer much, but thank you for you help. Jul 13, 2023 at 17:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.