uDIG
  1. uDIG
  2. UDIG-1715

Glyph NPE when fill defined by Function(Regression from GeoTools 2.2)

    Details

      Description

      One of the joys of getting uDig 1.2 near completion is people updating code from GeoTools 2.2 all the way to GeoTools 2.6.

      From email here is a regression in the styling system

      <sld:LineSymbolizer>
         <sld:Stroke>
            <sld:CssParameter name="stroke">
            <ogc:Function name="if_then_else">
              <ogc:Function name="lessThan">
                <ogc:PropertyName>VOLTAGE_ID</ogc:PropertyName>
                <ogc:Literal>3</ogc:Literal>
              </ogc:Function>
              <ogc:Literal>#FFBB55</ogc:Literal>
              <ogc:Function name="if_then_else">
                <ogc:Function name="lessThan">
                   <ogc:PropertyName>VOLTAGE_ID</ogc:PropertyName>
                   <ogc:Literal>7</ogc:Literal>
                </ogc:Function>
                <ogc:Literal>#F78484</ogc:Literal>
                <ogc:Literal>#5C993C</ogc:Literal>
            </ogc:Function>
           </ogc:Function>
      

      Producing:

      java.lang.IllegalArgumentException: Filter Function problem for function if_then_else argument #0 - expected type boolean
      at org.geotools.filter.function.FilterFunction_if_then_else.evaluate(FilterFunction_if_then_else.java:45)
      at org.geotools.filter.expression.ExpressionAbstract.evaluate(ExpressionAbstract.java:63)
      at org.geotools.styling.SLD.color(SLD.java:1312)
      at org.geotools.styling.SLD.color(SLD.java:96)
      at org.geotools.styling.SLD.lineColor(SLD.java:84)
      at org.geotools.styling.SLD.color(SLD.java:188)
      at net.refractions.udig.ui.Drawing.paint(Drawing.java:308)
      at net.refractions.udig.ui.Drawing.drawFeature(Drawing.java:246)
      at net.refractions.udig.ui.Drawing.drawFeature(Drawing.java:223)
      at net.refractions.udig.ui.Drawing.drawDirect(Drawing.java:150)
      at net.refractions.udig.ui.graphics.Glyph$6.getImageData(Glyph.java:363)

      Thanks to Lukasz for the report.

      Here is a style that can be used with countries.shp

      <?xml version="1.0" encoding="UTF-8"?>
      <sld:StyledLayerDescriptor xmlns="http://www.opengis.net/sld" xmlns:sld="http://www.opengis.net/sld" xmlns:ogc="http://www.opengis.net/ogc" xmlns:gml="http://www.opengis.net/gml" version="1.0.0">
          <sld:UserLayer>
              <sld:LayerFeatureConstraints>
                  <sld:FeatureTypeConstraint/>
              </sld:LayerFeatureConstraints>
              <sld:UserStyle>
                  <sld:Name>Default Styler</sld:Name>
                  <sld:Title/>
                  <sld:IsDefault>1</sld:IsDefault>
                  <sld:FeatureTypeStyle>
                      <sld:Name>simple</sld:Name>
                      <sld:FeatureTypeName>Feature</sld:FeatureTypeName>
                      <sld:SemanticTypeIdentifier>generic:geometry</sld:SemanticTypeIdentifier>
                      <sld:SemanticTypeIdentifier>simple</sld:SemanticTypeIdentifier>
                      <sld:Rule>
                          <sld:PolygonSymbolizer>
                              <sld:Fill>
                                  <sld:CssParameter name="fill">
                                      <ogc:Function name="if_then_else">
                                          <ogc:Function name="equalTo">
                                              <ogc:PropertyName>LANDLOCKED</ogc:PropertyName>
                                              <ogc:Literal>Y</ogc:Literal>
                                          </ogc:Function>
                                          <ogc:Literal>#FFFF00</ogc:Literal>
                                          <ogc:Literal>#0000FF</ogc:Literal>
                                      </ogc:Function>
                                  </sld:CssParameter>
                                  <sld:CssParameter name="fill-opacity">0.5</sld:CssParameter>
                              </sld:Fill>
                          </sld:PolygonSymbolizer>
                      </sld:Rule>
                  </sld:FeatureTypeStyle>
              </sld:UserStyle>
          </sld:UserLayer>
      </sld:StyledLayerDescriptor>
      

        Activity

        Hide
        Andrea Aime added a comment -
        Looking at the sld I cannot see how you get a non boolean out of "lessThan"...
        Show
        Andrea Aime added a comment - Looking at the sld I cannot see how you get a non boolean out of "lessThan"...
        Hide
        Jody Garnett added a comment -
        Does not make sense to me yet either.

        public Object evaluate(Object object, Class context) {
           return Converters.convert(evaluate( object ), context);
        }

        So evaulate( object ) must of returned null?
        Show
        Jody Garnett added a comment - Does not make sense to me yet either. public Object evaluate(Object object, Class context) {    return Converters.convert(evaluate( object ), context); } So evaulate( object ) must of returned null?
        Hide
        Jody Garnett added a comment -
        So I sorted this out a bit; the code that calls this wonderful SLD is a feature of nothing; literally. It is used by the layers view to make a small icon; to do so it uses the layer's FeatureType and then creates a feature (using the schema's default values), sets the default geometry to the correct shape - and asks for an image back.

        So obviously some of the values there are null; and the function is having a sad time of it. Still with that in mind we should be able to test.
        Show
        Jody Garnett added a comment - So I sorted this out a bit; the code that calls this wonderful SLD is a feature of nothing; literally. It is used by the layers view to make a small icon; to do so it uses the layer's FeatureType and then creates a feature (using the schema's default values), sets the default geometry to the correct shape - and asks for an image back. So obviously some of the values there are null; and the function is having a sad time of it. Still with that in mind we should be able to test.
        Hide
        Jody Garnett added a comment -
        Used a filter visitor to grab the first color from a function expression; also added a try/cat to the glyph code so we would not get errors in the event thready.

        -r 31930
        Show
        Jody Garnett added a comment - Used a filter visitor to grab the first color from a function expression; also added a try/cat to the glyph code so we would not get errors in the event thready. -r 31930

          People

          • Assignee:
            Jody Garnett
            Reporter:
            Jody Garnett
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: