* 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@cleverelephant.ca>
+ * Maintainer: Paul Ramsey <pramsey@opengeo.org>
*
**********************************************************************/
{
/* 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];
/* Free all of the allocated items */
lwgeom_free(lwgeom);
-
+
/* Return the string - everything ok */
*geometry = mem;
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;
return SHPLOADERERR;
}
-
-
+
+
/* Open the column map if one was specified */
if (state->config->column_map_filename)
{
&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 )
{
break;
}
-
+
/* Force Z/M-handling if configured to do so */
switch(state->config->force_output)
{
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)
{
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 */
{
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)
{
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);
snprintf(state->message, SHPLOADERMSGLEN, _("Invalid type %x in DBF file"), state->types[j]);
return SHPLOADERERR;
}
-
+
strcat(state->col_names, "\"");
strcat(state->col_names, name);
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");
/* 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]);
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;
{
/* Force the locale to C */
char *oldlocale = setlocale(LC_NUMERIC, "C");
-
+
/* Handle the case of a NULL shape */
if (obj->nVertices == 0)
{
/* Tidy up everything */
SHPDestroyObject(obj);
-
+
setlocale(LC_NUMERIC, oldlocale);
}
{
/* Destroy a state object created with ShpLoaderOpenShape */
int i;
-
+
if (state != NULL)
{
if (state->hSHPHandle)
{
for (i = 0; i < state->num_fields; i++)
free(state->pgfieldtypes[i]);
-
+
free(state->pgfieldtypes);
}
if (state->types)
/* Free any column map fieldnames if specified */
colmap_clean(&state->column_map);
-
+
/* Free the state itself */
free(state);
}