GeoTools
  1. GeoTools
  2. GEOT-475

Shapefile truncation of number(N) fields where N>10

    Details

    • Type: Bug Bug
    • Status: Closed Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 2.1.M2
    • Fix Version/s: None
    • Component/s: shapefile plugin
    • Labels:
      None
    • Environment:
      WinXPPro, Win2000, Java 1.4.2-b28

      Description

      We have a shapefile with a field of type NUMBER(11) (Precision=11 and scale=0) which gives truncated values when read.
      We suspect that the bug lies in the method
      getFieldClass(int i)
      of class
      org\geotools\data\shapefile\dbfDbaseFileHeader
      since it does not take into account the possibility of values larger than Integer range.

      This is the part of code we modified, which as far as we are concerned, resolve the problem:

      case 'N':
      if (fields[i].decimalCount == 0) {
      if (fields[i].fieldLength<10)

      { typeClass = Integer.class; }

      else

      { typeClass = Long.class; }

      } else

      { typeClass = Double.class; }

      break;

      Since we don't have a deep knowledge of the underlying behaviour of other components, we'd like to have a feedback of the correctness of our patch.

        Activity

        Hide
        Jody Garnett added a comment -
        I think we may of already applied this patch ...
        Show
        Jody Garnett added a comment - I think we may of already applied this patch ...
        Hide
        Andrea Aime added a comment -
        Yep
        Show
        Andrea Aime added a comment - Yep
        Hide
        Andrea Aime added a comment -
        Mass closing all issues that have been in "resolved" state for 2 months or more without any feedback or update
        Show
        Andrea Aime added a comment - Mass closing all issues that have been in "resolved" state for 2 months or more without any feedback or update

          People

          • Assignee:
            Jesse Eichar
            Reporter:
            Davide Cremonesi
          • Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: