*
**********************************************************************
* $Log$
+ * Revision 1.66 2004/10/06 09:40:27 strk
+ * Handled 0-DBF-attributes corner case.
+ *
* Revision 1.65 2004/09/20 17:13:31 strk
* changed comments to better show shape type handling
*
}
}
- if (dump_format) printf("\tSRID=%s ;MULTIPOLYGON(",sr_id );
- else printf(",GeometryFromText('MULTIPOLYGON(");
+ if (dump_format) printf("SRID=%s ;MULTIPOLYGON(",sr_id );
+ else printf("GeometryFromText('MULTIPOLYGON(");
for(u=0; u < out_index; u++){
Poly = Outer[u];
}
if (dump_format) {
- if ( i ) printf("\t");
printf("%s",make_good_string(val));
+ if ( i ) printf("\t");
} else {
- if ( i ) printf(",");
printf("'%s'",protect_quotes_string(val));
+ if ( i ) printf(",");
}
}
}
types = (DBFFieldType *)malloc(num_fields*sizeof(int));
widths = malloc(num_fields*sizeof(int));
precisions = malloc(num_fields*sizeof(int));
- col_names = malloc(num_fields * sizeof(char) * 32);
+ col_names = malloc((num_fields+2) * sizeof(char) * 32);
if(opt != 'a'){
strcpy(col_names, "(gid," );
}else{
strcpy(col_names, "(" );
}
+ //fprintf(stderr, "Number of fields from DBF: %d\n", num_fields);
for(j=0;j<num_fields;j++)
{
type = DBFGetFieldInfo(hDBFHandle, j, name, &field_width, &field_precision);
field_names[j] = malloc ( strlen(name)+3 );
strcpy(field_names[j], name);
+ sprintf(col_names, "%s\"%s\",", col_names, name);
if (j) strcat(col_names, ",");
- sprintf(col_names, "%s\"%s\"", col_names, name);
}
- sprintf(col_names, "%s, \"%s\")", col_names, geom);
+ sprintf(col_names, "%s\"%s\")", col_names, geom);
SHPGetInfo( hSHPHandle, &num_entities, &phnshapetype, &padminbound[0], &padmaxbound[0]);
// ---------- NULL SHAPE -----------------
if (obj->nVertices == 0)
{
- if (dump_format) printf("\t\\N\n\\.\n");
- else printf(", NULL);\n");
+ if (dump_format) printf("\\N\n\\.\n");
+ else printf("NULL);\n");
}
// --------- POLYGON / POLYGONM / POLYGONZ ------
else if( obj->nSHPType == 1 || obj->nSHPType == 21 )
{
- if (dump_format) printf("\tSRID=%s;POINT(",sr_id);
- else printf(",GeometryFromText('POINT (");
+ if (dump_format) printf("SRID=%s;POINT(",sr_id);
+ else printf("GeometryFromText('POINT (");
for (u=0;u<obj->nVertices; u++){
if (u>0) printf(",");
fprintf(stderr,
"MULTILINESTRING %d as %d vertices, set to NULL\n",
j, obj->nVertices);
- if (dump_format) printf("\t\\N\n");
- else printf(",NULL);\n");
+ if (dump_format) printf("\\N\n");
+ else printf("NULL);\n");
SHPDestroyObject(obj);
continue;
}
- if (dump_format) printf("\tSRID=%s;MULTILINESTRING(",sr_id);
- else printf(",GeometryFromText('MULTILINESTRING (");
+ if (dump_format) printf("SRID=%s;MULTILINESTRING(",sr_id);
+ else printf("GeometryFromText('MULTILINESTRING (");
//for each vertice write out the coordinates in the insert statement, when there is a new line
//you must end the brackets and start new ones etc.
//-------- MULTIPOINT / MULTIPOINTM ------------
else if( obj->nSHPType == 8 || obj->nSHPType == 28 )
{
- if (dump_format) printf("\tSRID=%s;MULTIPOINT(",sr_id);
- else printf(",GeometryFromText('MULTIPOINT (");
+ if (dump_format) printf("SRID=%s;MULTIPOINT(",sr_id);
+ else printf("GeometryFromText('MULTIPOINT (");
for (u=0;u<obj->nVertices; u++){
if (u>0) printf(",");
//---------- POINTZ ----------
else if( obj->nSHPType == 11 )
{
- if (dump_format) printf("\tSRID=%s;POINT(",sr_id);
- else printf(",GeometryFromText('POINT (");
+ if (dump_format) printf("SRID=%s;POINT(",sr_id);
+ else printf("GeometryFromText('POINT (");
for (u=0;u<obj->nVertices; u++){
if (u>0) printf(",");
fprintf(stderr,
"MULTILINESTRING %d as %d vertices, set to NULL\n",
j, obj->nVertices);
- if (dump_format) printf("\t\\N\n");
- else printf(",NULL);\n");
+ if (dump_format) printf("\\N\n");
+ else printf("NULL);\n");
SHPDestroyObject(obj);
continue;
else next_ring = -99;
if (dump_format)
- printf("\tSRID=%s;MULTILINESTRING(",sr_id);
- else printf(",GeometryFromText('MULTILINESTRING (");
+ printf("SRID=%s;MULTILINESTRING(",sr_id);
+ else printf("GeometryFromText('MULTILINESTRING (");
//for each vertice write out the coordinates in the insert statement, when there is a new line
//you must end the brackets and start new ones etc.
else if( obj->nSHPType == 18 )
{
- if (dump_format) printf("\tSRID=%s;MULTIPOINT(",sr_id);
- else printf(",GeometryFromText('MULTIPOINT (");
+ if (dump_format) printf("SRID=%s;MULTIPOINT(",sr_id);
+ else printf("GeometryFromText('MULTIPOINT (");
for (u=0;u<obj->nVertices; u++){
if (u>0){