[GRASS-SVN] r52571 - grass/trunk/vector/v.out.postgis

svn_grass at osgeo.org svn_grass at osgeo.org
Mon Aug 6 14:38:22 PDT 2012


Author: martinl
Date: 2012-08-06 14:38:21 -0700 (Mon, 06 Aug 2012)
New Revision: 52571

Modified:
   grass/trunk/vector/v.out.postgis/local_proto.h
   grass/trunk/vector/v.out.postgis/main.c
   grass/trunk/vector/v.out.postgis/options.c
Log:
v.out.postgis: new parameter to define output schema


Modified: grass/trunk/vector/v.out.postgis/local_proto.h
===================================================================
--- grass/trunk/vector/v.out.postgis/local_proto.h	2012-08-06 21:34:28 UTC (rev 52570)
+++ grass/trunk/vector/v.out.postgis/local_proto.h	2012-08-06 21:38:21 UTC (rev 52571)
@@ -4,7 +4,7 @@
 #include <grass/vector.h>
 
 struct params {
-    struct Option *input, *layer, *dsn, *olayer;
+    struct Option *input, *layer, *dsn, *olayer, *schema;
 };
 
 struct flags {
@@ -20,6 +20,6 @@
 
 /* options.c */
 void define_options(struct params *, struct flags *);
-char *create_pgfile(const char *, int);
+char *create_pgfile(const char *, const char *, int);
 
 #endif /* __LOCAL_PROTO_V_OUT_POSTGIS__ */

Modified: grass/trunk/vector/v.out.postgis/main.c
===================================================================
--- grass/trunk/vector/v.out.postgis/main.c	2012-08-06 21:34:28 UTC (rev 52570)
+++ grass/trunk/vector/v.out.postgis/main.c	2012-08-06 21:38:21 UTC (rev 52571)
@@ -27,7 +27,7 @@
     struct params params;
     struct flags flags;
     
-    int ret, field, do_areas;
+    int ret, field;
     struct Map_info In, Out;
     
     G_gisinit(argv[0]);
@@ -60,12 +60,13 @@
                   params.input->answer);
     
     /* create output for writing */
-    create_pgfile(params.dsn->answer, flags.topo->answer ? TRUE : FALSE);
+    create_pgfile(params.dsn->answer, params.schema->answer, flags.topo->answer ? TRUE : FALSE);
     
     if (-1 == Vect_open_new(&Out, params.olayer->answer, Vect_is_3d(&In)))
         G_fatal_error(_("Unable to create PostGIS layer <%s>"),
                       params.olayer->answer);
-    
+    Vect_set_error_handler_io(NULL, &Out); /* define error handler */
+
     /* define attributes */
     field = Vect_get_field_number(&In, params.layer->answer);
     if (!flags.table->answer)

Modified: grass/trunk/vector/v.out.postgis/options.c
===================================================================
--- grass/trunk/vector/v.out.postgis/options.c	2012-08-06 21:34:28 UTC (rev 52570)
+++ grass/trunk/vector/v.out.postgis/options.c	2012-08-06 21:38:21 UTC (rev 52571)
@@ -25,6 +25,13 @@
     params->dsn->description =
         _("Starts with 'PG' prefix, eg. 'PG:dbname=grass'");
     
+    params->schema = G_define_option();
+    params->schema->key = "schema";
+    params->schema->type = TYPE_STRING;
+    params->schema->required = NO;
+    params->schema->description = _("Database schema");
+    params->schema->answer = "public";
+    
     params->olayer = G_define_option();
     params->olayer->key = "olayer";
     params->olayer->type = TYPE_STRING;
@@ -45,7 +52,7 @@
         _("Export PostGIS topology instead of simple features");
 }
 
-char *create_pgfile(const char *dsn, int topo)
+char *create_pgfile(const char *dsn, const char *schema, int topo)
 {
     char *filename, *conninfo;
     FILE *fp;
@@ -79,6 +86,8 @@
     }
     
     G_set_key_value("conninfo", conninfo, key_val);
+    if (schema)
+        G_set_key_value("schema", schema, key_val);
     if (topo)
         G_set_key_value("topology", "on", key_val);
 



More information about the grass-commit mailing list