From: Sandro Santilli <strk@keybit.net>
Date: Thu, 13 May 2004 12:13:01 +0000 (+0000)
Subject: Used DBFWriteAttributeDirectly interface for writing attributes.
X-Git-Tag: pgis_0_8_2~8
X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=a8a91aefe97fde9047cd253b9d9c3f79af7a8af7;p=postgis

Used DBFWriteAttributeDirectly interface for writing attributes.
This way we are not affected by shapelib long-integer bug.


git-svn-id: http://svn.osgeo.org/postgis/trunk@551 b70326c6-7e19-0410-871a-916f4a2858ee
---

diff --git a/loader/pgsql2shp.c b/loader/pgsql2shp.c
index 00155b135..57bdffc70 100644
--- a/loader/pgsql2shp.c
+++ b/loader/pgsql2shp.c
@@ -10,6 +10,10 @@
  * 
  **********************************************************************
  * $Log$
+ * Revision 1.50  2004/05/13 12:13:01  strk
+ * Used DBFWriteAttributeDirectly interface for writing attributes.
+ * This way we are not affected by shapelib long-integer bug.
+ *
  * Revision 1.49  2004/05/13 12:07:13  strk
  * Other fix in 3d handling - you should now be able to dump as 2d or 3d any 2d or 3d object
  *
@@ -1997,63 +2001,14 @@ addRecord(PGresult *res, int residx, int row)
 	{
 		SHPObject *obj;
 
-		/* Integer attribute */
-		if (type_ary[j] == 1)
-		{
-			int temp;
-			if ( PQgetisnull(res, residx, j) ) {
-				temp = 0;
-			} else {
-				val = (char *)PQgetvalue(res, residx, j);
-				temp = atoi(val);
-			}
-#if VERBOSE > 1
-fprintf(stdout, "i"); fflush(stdout);
-#endif
-			if (!DBFWriteIntegerAttribute(dbf, row, flds, temp))
-			{
-				fprintf(stderr, "error(int) - Record could not be created\n");
-				return 0;
-			}
-			flds++;
-			continue;
-		}
-		
-		/* Double attribute */
-		if (type_ary[j] == 2)
-		{
-			double temp;
-			if ( PQgetisnull(res, residx, j) ) {
-				temp = 0;
-			} else {
-				val = PQgetvalue(res, residx, j);
-				temp = atof(val);
-			}
-#if VERBOSE > 1
-fprintf(stdout, "d"); fflush(stdout);
-#endif
-			if (!DBFWriteDoubleAttribute(dbf, row, flds, temp))
-			{
-				fprintf(stderr, "error(double) - Record could "
-						"not be created\n");
-				return 0;
-			}
-			flds++;
-			continue;
-		}
-
 		/* Default (not geometry) attribute */
 		if (type_ary[j] != 9)
 		{
-			if ( PQgetisnull(res, residx, j) ) {
-				val = "";
-			} else {
-				val = PQgetvalue(res, residx, j);
-			}
+			val = PQgetvalue(res, residx, j);
 #if VERBOSE > 1
 fprintf(stdout, "s"); fflush(stdout);
 #endif
-			if(!DBFWriteStringAttribute(dbf, row, flds, val))
+			if(!DBFWriteAttributeDirectly(dbf, row, flds, val))
 			{
 				printf("error(string) - Record could not be "
 						"created\n");