[postgis-users] shp2pgsql - dbf attribute size
Mark Cave-Ayland
mark.cave-ayland at ilande.co.uk
Fri Nov 23 02:44:38 PST 2007
On Mon, 2007-09-24 at 16:45 -0500, Tom Glancy wrote:
> We are seeing ERROR: value "6906401929" is out of range
> for type integer from Postgres when using shp2pgsql to load
> shapefiles. Here is what ArcView reports for field properties:
>
> Alias Type Width Decimal
> -------------------------------------------------------
> Shape FIELD_SHAPEPOLY 8 0
> [snip]
> Geosect FIELD_DECIMAL 10 0
> Georang FIELD_DECIMAL 8 0
> [snip]
>
> Values for Geosect:
> ERROR: value "6906401929" is out of range for type integer
> ERROR: value "6905901328" is out of range for type integer
> ERROR: value "4515704005" is out of range for type integer
>
> shp2pgsql defined geosect as "int4", and the insert failed.
>
> We saw similar errors for fields of type FIELD_DECIMAL defined
> with Width=5, Decimal=0 when values exceeded about 68000 (we
> didn't try to find the exact value where it failed...)
>
> In shp2pgsql.c, the CreateTable function, field widths are
> mapped to data types. It appears that int2, int4 and int8
> are off by a length of one. We made these changes to
> shp2pgsql.c and are no longer seeing the errors:
>
> $ diff ./shp2pgsql.c ../../postgis-1.3.1-original/loader/shp2pgsql.c
> 539c539
> < else if ( field_width < 5 )
> ---
> > else if ( field_width <= 5 )
> 543c543
> < else if ( field_width < 10 )
> ---
> > else if ( field_width <= 10 )
> 547c547
> < else if ( field_width < 19 )
> ---
> > else if ( field_width <= 19 )
Thanks Tom.
Apologies for the delay - I've applied this to SVN and so it should
appear in the next PostGIS release.
Kind regards,
Mark.
--
ILande - Open Source Consultancy
http://www.ilande.co.uk
More information about the postgis-users
mailing list