Details

    • Type: Bug
    • Status: Resolved
    • Priority: Highest
    • Resolution: Fixed
    • Affects versions: 20.0, 20.1, 21
    • Fix versions: 20.2, 21-M0
    • Components: main
    • Labels:
      None
    • Environment:

      Windows 7 Java 8

      Description

      When transforming a SLD with a BBox filter to XML an exception occurs:

      ERROR:  'Cannot encode org.locationtech.jts.geom.Envelope should be Filter or Expression'
      javax.xml.transform.TransformerException: java.lang.IllegalArgumentException: Cannot encode org.locationtech.jts.geom.Envelope should be Filter or Expression
              at com.sun.org.apache.xalan.internal.xsltc.trax.TransformerImpl.transform(TransformerImpl.java:737)
              at com.sun.org.apache.xalan.internal.xsltc.trax.TransformerImpl.transform(TransformerImpl.java:343)
              at org.geotools.xml.transform.TransformerBase$Task.run(TransformerBase.java:283)
              at org.geotools.xml.transform.TransformerBase.transform(TransformerBase.java:118)
              at org.geotools.xml.transform.TransformerBase.transform(TransformerBase.java:108)
              at org.geotools.xml.transform.TransformerBase.transform(TransformerBase.java:145)
              at com.sldeditor.test.App.main(App.java:42)
      Caused by: java.lang.IllegalArgumentException: Cannot encode org.locationtech.jts.geom.Envelope should be Filter or Expression
              at org.geotools.xml.filter.FilterTransformer$FilterTranslator.encode(FilterTransformer.java:489)
              at org.geotools.xml.filter.FilterTransformer$FilterTranslator.visit(FilterTransformer.java:330)
              at org.geotools.filter.spatial.BBOXImpl.accept(BBOXImpl.java:216)
              at org.geotools.xml.filter.FilterTransformer$FilterTranslator.encode(FilterTransformer.java:482)
              at org.geotools.xml.styling.SLDTransformer$SLDTranslator.visit(SLDTransformer.java:1174)
              at org.geotools.xml.styling.SLDTransformer$SLDTranslator.visit(SLDTransformer.java:874)
              at org.geotools.styling.RuleImpl.accept(RuleImpl.java:303)
              at org.geotools.xml.styling.SLDTransformer$SLDTranslator.visit(SLDTransformer.java:1238)
              at org.geotools.xml.styling.SLDTransformer$SLDTranslator.visit(SLDTransformer.java:1199)
              at org.geotools.xml.styling.SLDTransformer$SLDTranslator.visit(SLDTransformer.java:1019)
              at org.geotools.xml.styling.SLDTransformer$SLDTranslator.visit(SLDTransformer.java:991)
              at org.geotools.styling.StyledLayerDescriptorImpl.accept(StyledLayerDescriptorImpl.java:170)
              at org.geotools.xml.styling.SLDTransformer$SLDTranslator.encode(SLDTransformer.java:1375)
              at org.geotools.xml.styling.SLDTransformer$SLDTranslator.encode(SLDTransformer.java:1384)
              at org.geotools.xml.transform.TransformerBase$XMLReaderSupport.parse(TransformerBase.java:995)
              at com.sun.org.apache.xalan.internal.xsltc.trax.TransformerImpl.transformIdentity(TransformerImpl.java:659)
              at com.sun.org.apache.xalan.internal.xsltc.trax.TransformerImpl.transform(TransformerImpl.java:728)
              ... 6 more
      

      The issue can be demonstrated by unzipping the attached bbox-issue and typing:

      mvn clean install
      java -jar bbox-issue.jar point_bbox.sld
      

      The issue is caused in org.geotools.filter.FilterTransformer

              public Object visit(BBOX filter, Object extraData) {
                  Expression left = filter.getExpression1();
                  Expression right = filter.getExpression2();
      
                  final String type = "BBOX";
                  start(type);
                  left.accept(this, extraData);
                  if (right instanceof Literal) {
                      Literal literal = (Literal) right;
                      Envelope bbox = literal.evaluate(null, Envelope.class);
                      if (bbox != null) {
                         encode(bbox);
                      } else {
                          right.accept(this, extraData);
                      }
                  } else {
                      right.accept(this, extraData);
                  }
                  end(type);
                  return extraData;
              }
      

      The

      encode()

      method called in the middle of the method above only expects an object of type Filter or Expression hence the exception.

        Attachments

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              robward Robert Ward
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: