FME seems to misread the width of Number fields when reading a shapefile dataset

Liz Sanderson
Liz Sanderson
  • Updated

Symptom

When I create a workspace using a Esri shapefile dataset, FME misreads the width of Number fields. For example, a number(7,2) field is read as number(10,2). Why?


Cause

According to ArcGIS's help, ArcGIS uses the terms "Precision", "Scale" and "Length".

Precision — The number of digits that can be stored in a number field. For example, the number 56.78 has a precision of 4.

Scale — The number of digits to the right of the decimal point in a number in a field of type float or double. For example, the number 56.78 has a Scale of 2. Scale is only used for Float and Double field types.

Length - The number of characters needed to represent the number. It should be equal to Precision for integers and equal to Precision+1 for Double and Float; the extra length is for the decimal point itself.

What FME gets from the dbf file is actually (Length,Scale) which is the same as FME's (Width,Decimals).

FME will not adjust Length except in the case that Scale>=Length. There is a bug with ArcGIS so the user can input invalid numbers but FME has no way to detect/prevent that. For Scale > Length, it is obviously wrong since the decimal part cannot be longer than the width; so FME will expand the length. For Scale == Length and Scale is >0, it means the decimal point has been left out. It turns out that all these cases can be handled by the following statement. (assuming that decimals and fieldLength are non negative).

if (decimals >= fieldLength)
{
   fieldLength = decimals + 1;
}

In fact this should never happen if the shapefile is produced correctly.


Was this article helpful?

Comments

0 comments

Please sign in to leave a comment.