GeoTools
  1. GeoTools
  2. GEOT-3407

org.geotools.data.oracle.sdo.SDO.createPoint/createMultiPoint throws IllegalArgumentException

    Details

    • Type: Bug Bug
    • Status: Resolved Resolved
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 2.6.5
    • Fix Version/s: 10.2
    • Component/s: jdbc-oracle plugin
    • Labels:
      None

      Description

      I have a GeometryCollection containg a point and line which fails to be correctly parsed with SDO class. Throws exception:

      java.lang.IllegalArgumentException: ELEM_INFO STARTING_OFFSET 899 inconsistent with ORDINATES length 466
      at org.geotools.data.oracle.sdo.SDO.createPoint(SDO.java:2365)
      at org.geotools.data.oracle.sdo.SDO.createCollection(SDO.java:2911)
      at org.geotools.data.oracle.sdo.SDO.create(SDO.java:2335)
      at org.geotools.data.oracle.sdo.SDO.create(SDO.java:2289)

      Offending line in SDO class is:

      if (!(STARTING_OFFSET >= 1) || !(STARTING_OFFSET <= coords.size()))
      throw new IllegalArgumentException("ELEM_INFO STARTING_OFFSET "STARTING_OFFSET" inconsistent with ORDINATES length "+coords.size());

      This is wrong as it fails to take into account the dimensions. STARTING_OFFSET should be compared against ordinateSize( coords, GTYPE ) as it is in other parts of the code. See comments on ordinateSize() method

        Issue Links

          Activity

          Hide
          Andrea Aime added a comment -
          Thanks for the report. Can you also work out a patch to fix this one? Otherwise attach enough sql to setup the data on someone elses machine and wait for a developer to have enough spare time to look into this one.
          Show
          Andrea Aime added a comment - Thanks for the report. Can you also work out a patch to fix this one? Otherwise attach enough sql to setup the data on someone elses machine and wait for a developer to have enough spare time to look into this one.
          Hide
          David Kowol added a comment -
          Hi all,

          I've got the same Exception [ELEM_INFO STARTING_OFFSET 361 inconsistent with ORDINATES length 181].

          As Joel wrote createPoint(...) and createMultiPoint(...) don't take the dimension into account.

          createCollection(...) for example does take the dimension into account with

                  final int LENGTH = coords.size()*D(GTYPE);
                  
                  if (!(STARTING_OFFSET >= 1) || !(STARTING_OFFSET <= LENGTH))

          In my opinion the only thing to do ist to replace

                  if (!(STARTING_OFFSET >= 1) || !(STARTING_OFFSET <= coords.size()))

          in both methodes with the code from createCollection.

          Best regards,

          David
          Show
          David Kowol added a comment - Hi all, I've got the same Exception [ELEM_INFO STARTING_OFFSET 361 inconsistent with ORDINATES length 181]. As Joel wrote createPoint(...) and createMultiPoint(...) don't take the dimension into account. createCollection(...) for example does take the dimension into account with         final int LENGTH = coords.size()*D(GTYPE);                  if (!(STARTING_OFFSET >= 1) || !(STARTING_OFFSET <= LENGTH)) In my opinion the only thing to do ist to replace         if (!(STARTING_OFFSET >= 1) || !(STARTING_OFFSET <= coords.size())) in both methodes with the code from createCollection. Best regards, David
          Hide
          Matthijs Laan added a comment -
          Show
          Matthijs Laan added a comment - Commit 0fea19847116f5b797b7ef53d27caf73b8711afe has the change for createPoint() but not for createMultiPoint(): https://github.com/geotools/geotools/blob/0fea19847116f5b797b7ef53d27caf73b8711afe/modules/plugin/jdbc/jdbc-oracle/src/main/java/org/geotools/data/oracle/sdo/SDO.java#L2768
          Hide
          Andrea Aime added a comment -
          Good catch
          Show
          Andrea Aime added a comment - Good catch
          Hide
          Andrea Aime added a comment -
          Fixed multipoint as well
          Show
          Andrea Aime added a comment - Fixed multipoint as well

            People

            • Assignee:
              Andrea Aime
              Reporter:
              Joel Carranza
            • Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: