From: Sandro Santilli Date: Thu, 14 Oct 2004 09:59:51 +0000 (+0000) Subject: Added support for user query (replacing schema.table) X-Git-Tag: pgis_1_0_0RC1~284 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=eaa44677748274e1d59586ee7a52836f08cd17b8;p=postgis Added support for user query (replacing schema.table) git-svn-id: http://svn.osgeo.org/postgis/trunk@999 b70326c6-7e19-0410-871a-916f4a2858ee --- diff --git a/loader/pgsql2shp.c b/loader/pgsql2shp.c index 54bc03e31..6d5cf4b20 100644 --- a/loader/pgsql2shp.c +++ b/loader/pgsql2shp.c @@ -56,7 +56,7 @@ typedef unsigned char byte; /* Global data */ PGconn *conn; int rowbuflen; -char *geo_col_name, *table, *shp_file, *schema; +char *geo_col_name, *table, *shp_file, *schema, *usrquery; int type_ary[256]; char *main_scan_query; DBFHandle dbf; @@ -95,6 +95,8 @@ int is_clockwise(int num_points,double *x,double *y,double *z); int is_bigendian(void); SHPObject * shape_creator_wrapper_WKB(byte *str, int idx); int get_postgis_major_version(void); +static void parse_table(char *spec); +static int create_usrquerytable(); /* WKB functions */ SHPObject * create_polygon2D_WKB(byte *wkb); @@ -148,6 +150,7 @@ main(int ARGC, char **ARGV) shape_creator = NULL; table = NULL; schema = NULL; + usrquery = NULL; geo_col_name = NULL; shp_file = NULL; main_scan_query = NULL; @@ -173,7 +176,6 @@ main(int ARGC, char **ARGV) usage(2); } - /* Use table name as shapefile name */ if(shp_file == NULL) shp_file = table; @@ -184,6 +186,13 @@ main(int ARGC, char **ARGV) exit_nicely(conn); } + /* Create temporary table for user query */ + if ( usrquery ) { + if ( ! create_usrquerytable() ) { + exit(2); + } + } + #ifdef DEBUG debug = fopen("/tmp/trace.out", "w"); PQtrace(conn, debug); @@ -2165,6 +2174,7 @@ usage(status) { printf("RCSID: %s\n", rcsid); printf("USAGE: pgsql2shp [] [.]\n"); + printf(" pgsql2shp [] \n"); printf("\n"); printf("OPTIONS:\n"); printf(" -f Use this option to specify the name of the file\n"); @@ -2184,12 +2194,13 @@ usage(status) } /* Parse command line parameters */ -int parse_commandline(int ARGC, char **ARGV) +int +parse_commandline(int ARGC, char **ARGV) { int c, curindex; - char buf[256], *ptr; + char buf[1024]; - buf[255] = '\0'; // just in case... + buf[1023] = '\0'; // just in case... /* Parse command line */ while ((c = getopt(ARGC, ARGV, "bf:h:du:p:P:g:r")) != EOF){ @@ -2239,23 +2250,18 @@ int parse_commandline(int ARGC, char **ARGV) } curindex=0; - for ( ; optind < ARGC; optind++){ - if(curindex ==0){ + for (; optind