GeoTools
  1. GeoTools
  2. GEOT-186

ArrayIndexOutOfBounds exception on GeometryFilter BBOX

    Details

    • Type: Bug Bug
    • Status: Closed Closed
    • Priority: Minor Minor
    • Resolution: Fixed
    • Affects Version/s: 2.1.M0
    • Fix Version/s: 2.1.M0
    • Component/s: main
    • Labels:
      None

      Description

      So I don't have time to provide a good test case, as the shapefile where I'm getting this error is 170 megs. But I have a fix for it, I'm just assigning this to you Andrea as I think you wrote the original code and I want some one to look over it to make sure it's right.

      The problem is on the bbox optimization in org.geotools.filter.GeometryFilterImpl. I'm working with multilinestrings, a huge set of them. The bbox checks the dimension to see if there are coordinates to examine, using left.getDimension(). It then looks at the Coordinate arrays of the envelopes of the Geometries. And this is where I get an array out of bounds exception, as it checks cl[2]. I dug into the jts code a bit, and it looks like it's possible that a multilinestring could be constructed with just one point, (or maybe even zero points?). The javadocs for getEnvelope() (which is how the coordinates to compare) say:

      'Returns this Geometrys bounding box. If this Geometry is the empty geometry, returns an empty Point. If the Geometry is a point, returns a non-empty Point. Otherwise, returns a Polygon whose points are (minx, miny), (maxx, miny), (maxx, maxy), (minx, maxy), (minx, miny).'

      So I believe what happens is that getDimension returns 1, since the geometry type is a multiLineString. But the actual array is only one point, as getEnvelope would just return a point, and the getCoordinates of that would only be of length one.

      So I replaced left.getDimension() with cl.length > 1 && cr.length > 1

      I'm committing the code, just go ahead and close this if you agree with the changes, or let me know and I can change it or you can change it to a better way, and then close this.

        Activity

        Hide
        Chris Holmes added a comment -
        Committed. Andrea, review if you get a chance and reopen if anything's wrong.
        Show
        Chris Holmes added a comment - Committed. Andrea, review if you get a chance and reopen if anything's wrong.

          People

          • Assignee:
            Andrea Aime
            Reporter:
            Chris Holmes
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: