? pgsql2shp.diff Index: README.pgsql2shp =================================================================== RCS file: /home/cvs/postgis/postgis/loader/README.pgsql2shp,v retrieving revision 1.3 diff -r1.3 README.pgsql2shp 46a47 > -g Specify the geometry column to be exported. Index: pgsql2shp.c =================================================================== RCS file: /home/cvs/postgis/postgis/loader/pgsql2shp.c,v retrieving revision 1.7 diff -r1.7 pgsql2shp.c 32,36c32,43 < //usage: dump ["2d" || 3d"] < //database: name of the database on local host < //table_name: which table to dump < //shape_file_name: name of shape file which info is dumped into < //2d or 3d specifies what type of shape file you want, a 2d one or a 3d one. Defaults to 3d if not specifed. --- > //USAGE: pgsql2shp [] > //OPTIONS: > // -d Set the dump file to 3 dimensions, if this option is not used > // all dumping will be 2d only. > // -f Use this option to specify the name of the file > // to create. > // -h Allows you to specify connection to a database on a > // machine other than the localhost. > // -p Allows you to specify a database port other than 5432. > // -P Connect to the database with the specified password. > // -u Connect to the database as the specified user. > // -g Specify the geometry column to be exported. 62c69 < geovalue_field = 0; --- > geovalue_field = -1; 66,68c73,75 < errflg =0; < OID =0; < while ((c = getopt(ARGC, ARGV, "f:h:du:p:P:")) != EOF){ --- > errflg = 0; > OID = 0; > while ((c = getopt(ARGC, ARGV, "f:h:du:p:P:g:")) != EOF){ 87a95,97 > case 'g': > geo_col_name = optarg; > break; 120a131 > printf(" -g Specify the geometry column to be exported.\n"); 272,274c283,289 < type_ary[i]=9; //the geometry type field < geovalue_field = i; < flds++; --- > if( geovalue_field == -1){ > geovalue_field = i; > flds++; > }else if(geo_col_name != NULL && !strcasecmp(geo_col_name, field_name)){ > geovalue_field = i; > } > type_ary[i]=9; //the geometry type field 333c348 < strcpy(table_OID, (PQgetvalue(res3, 0,0)) ); --- > strncpy(table_OID, (PQgetvalue(res3, 0,0)), 15 ); 335c350 < printf("ERROR:Cannot determine name of geometry column.\n"); --- > printf("ERROR: Cannot determine relation OID.\n"); 338,340c353,354 < strcpy(table_OID, (PQgetvalue(res3, 0,0)) ); < printf("Warning: Multiple geometry columns detected, the program will only dump the first geometry"); < //JL - still need to write in some options to allow choosing a different geom col. --- > strncpy(table_OID, (PQgetvalue(res3, 0,0)), 15 ); > printf("Warning: Multiple relations detected, the program will only dump the first relation.\n"); 343,351c357,378 < //get the name of the geometry column < query= (char *)malloc(strlen("select attname from pg_attribute where < attrelid = and atttypid = ")+38); < strcpy(query, "select attname from pg_attribute where attrelid = "); < strcat(query, table_OID); < strcat(query, " and atttypid = "); < geo_OID = (char *)malloc(34); < sprintf(geo_OID,"%i",OID); < strcat(query,geo_OID ); --- > //get the geometry column > if(geo_col_name == NULL){ > query= (char *)malloc(strlen("select attname from pg_attribute where attrelid = and atttypid = ")+38); > strcpy(query, "select attname from pg_attribute where attrelid = "); > strcat(query, table_OID); > strcat(query, " and atttypid = "); > geo_OID = (char *)malloc(34); > sprintf(geo_OID, "%i", OID); > strcat(query, geo_OID ); > }else{ > query = (char *)malloc(strlen("select attname from pg_attribute where attrelid = and atttypid = ")+ > strlen("and attname = ''")+strlen(geo_col_name)+38); > strcpy(query, "select attname from pg_attribute where attrelid = "); > strcat(query, table_OID); > strcat(query, " and atttypid = "); > geo_OID = (char *)malloc(34); > sprintf(geo_OID, "%i", OID); > strcat(query, geo_OID ); > strcat(query, " and attname = '"); > strcat(query, geo_col_name); > strcat(query, "'"); > } 357c384,388 < printf("ERROR:Cannot determine name of geometry column.\n"); --- > if(geo_col_name == NULL){ > printf("ERROR: Cannot determine name of geometry column.\n"); > }else{ > printf("ERROR: Wrong geometry column name.\n"); > } 362c393 < printf("Warning: Multiple geometry columns detected, the program will only dump the first geometry"); --- > printf("Warning: Multiple geometry columns detected, the program will only dump the first geometry.\n");