[postgis-users] [PATCH] shp2pgsql without DBF

strk strk at freek.keybit.net
Thu May 15 08:41:24 PDT 2003


The following patch allows shp2pgsql to import shapes
when no DBF is available.

--strk;

----------------------------------------8<-----------------------------

--- shp2pgsql.c.000     Thu May 15 17:23:52 2003
+++ shp2pgsql.c Thu May 15 17:33:56 2003
@@ -423,4 +423,5 @@
        int i,num_fields;

+       if ( hDBFHandle == NULL ) return 1;

        num_fields = DBFGetFieldCount( hDBFHandle );
@@ -560,5 +561,5 @@
        hSHPHandle = SHPOpen( shp_file, "rb" );
        hDBFHandle = DBFOpen( shp_file, "rb" );
-       if (hSHPHandle == NULL || hDBFHandle == NULL){
+       if (hSHPHandle == NULL){
                printf ("shape is null\n");
                exit(-1);
@@ -589,4 +590,6 @@
                        printf("create table %s (gid int4 ",table);

+       if ( hDBFHandle != NULL )
+       {
                num_fields = DBFGetFieldCount( hDBFHandle );
                num_records = DBFGetRecordCount(hDBFHandle);
@@ -640,4 +643,5 @@
                        }
                }
+       } // hDBFHandle != NULL
                printf (");\n");
                //finished creating the table

----------------------------------------8<-----------------------------



More information about the postgis-users mailing list