]> granicus.if.org Git - postgis/commitdiff
Limited text field size to 255 (bug #84) [will eventually provide a switch to suppor...
authorSandro Santilli <strk@keybit.net>
Tue, 18 Apr 2006 14:09:28 +0000 (14:09 +0000)
committerSandro Santilli <strk@keybit.net>
Tue, 18 Apr 2006 14:09:28 +0000 (14:09 +0000)
git-svn-id: http://svn.osgeo.org/postgis/trunk@2334 b70326c6-7e19-0410-871a-916f4a2858ee

loader/pgsql2shp.c

index e0723cf6cae49f1c38b223fe0210aace9c2fa306..f9708b44ce4bdd38c2460b2d410ef1f7a4562e57 100644 (file)
@@ -58,6 +58,10 @@ static char rcsid[] =
 /* Define this to use HEX encoding instead of bytea encoding */
 #define HEXWKB 1
 
+/* Maximum DBF field width (according to ARCGIS) */
+#define MAX_DBF_FIELD_SIZE 255
+
+
 /*typedef unsigned long int uint32;*/
 typedef uint32_t uint32;
 typedef unsigned char byte;
@@ -2772,12 +2776,22 @@ initialize(void)
                                /* might 0 be a good size ? */
                        }
                }
+
+               if ( size > MAX_DBF_FIELD_SIZE )
+               {
+                       fprintf(stderr, "Warning: values of field '%s' "
+                               "exceeding maximum dbf field width (%d) "
+                               "will be truncated.\n",
+                               fname, MAX_DBF_FIELD_SIZE);
+                       size = MAX_DBF_FIELD_SIZE;
+               }
+
 /*printf( "FIELD_NAME: %s, SIZE: %d\n", field_name, size); */
-               
+
                /* generic type (use string representation) */
                if(DBFAddField(dbf, field_name, FTString, size, 0) == -1)
                {
-                       printf( "Error - String field could not "
+                       fprintf(stderr, "Error - String field could not "
                                        "be created.\n");
                        return 0;
                }
@@ -3327,6 +3341,9 @@ goodDBFValue(const char *in, char fieldType)
 
 /**********************************************************************
  * $Log$
+ * Revision 1.84  2006/04/18 14:09:28  strk
+ * Limited text field size to 255 (bug #84)  [will eventually provide a switch to support wider fields ]
+ *
  * Revision 1.83  2006/02/03 20:53:36  strk
  * Swapped stdint.h (unavailable on Solaris9) with inttypes.h
  *