Ticket #2286 (closed defect: duplicate)
Possible data truncation and loss of information during Shapefile import
| Reported by: | Kosta | Owned by: | warmerdam |
|---|---|---|---|
| Priority: | normal | Milestone: | |
| Component: | OGR_SF | Version: | 1.5.0 |
| Severity: | critical | Keywords: | Shapefile, truncation |
| Cc: |
Description
I would like to apply the attached patch to the Shapefile Driver in order to avoid loss or truncation of data during shapefile import.
The problem is: if a Shapefile specifies a column of type "N" (number) with a width larger than 10 digits, the data type is promoted to "double" (since "int32" can only represent 10 digits); but "double" values can only represent up to 15 or 16 digits; so this "double" promotion will result in loss of information if the original data has a width larger than 15 digits... [note: e.g., TeleAtlas use 30-digit numbers as unique IDs for some of their features!]
The attached patch will promote "numbers":
- with at least 1 decimal to "doubles",
- with less than 11 digits to "ints", and
- everything else to "strings",
avoiding loss or truncation of information.

