[postgis-tickets] r15523 - revert last change seems other things I borught over from 2.4 where are unrelated to #3800

Regina Obe lr at pcorp.us
Fri Aug 4 16:02:43 PDT 2017


Author: robe
Date: 2017-08-04 16:02:43 -0700 (Fri, 04 Aug 2017)
New Revision: 15523

Modified:
   branches/2.3/loader/shp2pgsql-core.c
Log:
revert last change seems other things I borught over from 2.4 where are unrelated to #3800

Modified: branches/2.3/loader/shp2pgsql-core.c
===================================================================
--- branches/2.3/loader/shp2pgsql-core.c	2017-08-04 22:49:07 UTC (rev 15522)
+++ branches/2.3/loader/shp2pgsql-core.c	2017-08-04 23:02:43 UTC (rev 15523)
@@ -9,7 +9,7 @@
  * This is free software; you can redistribute and/or modify it under
  * the terms of the GNU General Public Licence. See the COPYING file.
  *
- * Maintainer: Paul Ramsey <pramsey at cleverelephant.ca>
+ * Maintainer: Paul Ramsey <pramsey at opengeo.org>
  *
  **********************************************************************/
 
@@ -248,7 +248,7 @@
 	{
 		/* Create a ptarray containing a single point */
 		POINTARRAY *pa = ptarray_construct_empty(state->has_z, state->has_m, 1);
-
+		
 		/* Generate the point */
 		point4d.x = obj->padfX[u];
 		point4d.y = obj->padfY[u];
@@ -294,7 +294,7 @@
 
 	/* Free all of the allocated items */
 	lwgeom_free(lwgeom);
-
+	
 	/* Return the string - everything ok */
 	*geometry = mem;
 
@@ -639,7 +639,7 @@
 	for (pi = 0; pi < polygon_total; pi++)
 	{
 		LWPOLY *lwpoly = lwpoly_construct_empty(state->from_srid, state->has_z, state->has_m);
-
+		
 		Ring *polyring;
 		int ring_index = 0;
 
@@ -856,8 +856,8 @@
 
 		return SHPLOADERERR;
 	}
-
-
+	
+		
 	/* Open the column map if one was specified */
 	if (state->config->column_map_filename)
 	{
@@ -865,7 +865,7 @@
 		                  &state->column_map, state->message, SHPLOADERMSGLEN);
 		if (!ret) return SHPLOADERERR;
 	}
-
+	
 	/* User hasn't altered the default encoding preference... */
 	if ( strcmp(state->config->encoding, ENCODING_DEFAULT) == 0 )
 	{
@@ -1023,7 +1023,7 @@
 
 			break;
 		}
-
+		
 		/* Force Z/M-handling if configured to do so */
 		switch(state->config->force_output)
 		{
@@ -1096,7 +1096,6 @@
 		state->types[j] = type;
 		state->widths[j] = field_width;
 		state->precisions[j] = field_precision;
-/*		fprintf(stderr, "XXX %s width:%d prec:%d\n", name, field_width, field_precision); */
 
 		if (state->config->encoding)
 		{
@@ -1122,7 +1121,7 @@
 			strncpy(name, utf8str, MAXFIELDNAMELEN);
 			free(utf8str);
 		}
-
+		
 		/* If a column map file has been passed in, use this to create the postgresql field name from
 		   the dbf column name */
 		{
@@ -1193,7 +1192,7 @@
 			if (state->config->forceint4 || (state->widths[j] >=5 && state->widths[j] < 10))
 			{
 				state->pgfieldtypes[j] = malloc(strlen("int4") + 1);
-				strcpy(state->pgfieldtypes[j], "int4");
+				strcpy(state->pgfieldtypes[j], "int4");	
 			}
 			else if (state->widths[j] < 5)
 			{
@@ -1209,8 +1208,6 @@
 
 		case FTDouble:
 			/* Determine exact type based upon field width */
-			fprintf(stderr, "Field %s is an FTDouble with width %d and precision %d\n",
-					state->field_names[j], state->widths[j], state->precisions[j]);
 			if (state->widths[j] > 18)
 			{
 				state->pgfieldtypes[j] = malloc(strlen("numeric") + 1);
@@ -1232,7 +1229,7 @@
 			snprintf(state->message, SHPLOADERMSGLEN, _("Invalid type %x in DBF file"), state->types[j]);
 			return SHPLOADERERR;
 		}
-
+		
 		strcat(state->col_names, "\"");
 		strcat(state->col_names, name);
 
@@ -1270,13 +1267,13 @@
 	   for handling string resizing during append */
 	sb = stringbuffer_create();
 	stringbuffer_clear(sb);
-
+	
 	/* Set the client encoding if required */
 	if (state->config->encoding)
 	{
 		stringbuffer_aprintf(sb, "SET CLIENT_ENCODING TO UTF8;\n");
 	}
-
+	
 	/* Use SQL-standard string escaping rather than PostgreSQL standard */
 	stringbuffer_aprintf(sb, "SET STANDARD_CONFORMING_STRINGS TO ON;\n");
 
@@ -1347,7 +1344,7 @@
 
 			/* First output the raw field type string */
 			stringbuffer_aprintf(sb, "%s", state->pgfieldtypes[j]);
-
+			
 			/* Some types do have typmods though... */
 			if (!strcmp("varchar", state->pgfieldtypes[j]))
 				stringbuffer_aprintf(sb, "(%d)", state->widths[j]);
@@ -1521,8 +1518,8 @@
 	sb = stringbuffer_create();
 	stringbuffer_clear(sb);
 
-	/* Skip deleted records */
-	if (state->hDBFHandle && DBFIsRecordDeleted(state->hDBFHandle, item))
+	/* If we are reading the DBF only and the record has been marked deleted, return deleted record status */
+	if (state->config->readshape == 0 && DBFIsRecordDeleted(state->hDBFHandle, item))
 	{
 		*strrecord = NULL;
 		return SHPLOADERRECDELETED;
@@ -1682,7 +1679,7 @@
 	{
 		/* Force the locale to C */
 		char *oldlocale = setlocale(LC_NUMERIC, "C");
-
+		
 		/* Handle the case of a NULL shape */
 		if (obj->nVertices == 0)
 		{
@@ -1775,7 +1772,7 @@
 
 		/* Tidy up everything */
 		SHPDestroyObject(obj);
-
+		
 		setlocale(LC_NUMERIC, oldlocale);
 	}
 
@@ -1869,7 +1866,7 @@
 {
 	/* Destroy a state object created with ShpLoaderOpenShape */
 	int i;
-
+	
 	if (state != NULL)
 	{
 		if (state->hSHPHandle)
@@ -1887,7 +1884,7 @@
 		{
 			for (i = 0; i < state->num_fields; i++)
 				free(state->pgfieldtypes[i]);
-
+			
 			free(state->pgfieldtypes);
 		}
 		if (state->types)
@@ -1901,7 +1898,7 @@
 
 		/* Free any column map fieldnames if specified */
 		colmap_clean(&state->column_map);
-
+		
 		/* Free the state itself */
 		free(state);
 	}



More information about the postgis-tickets mailing list