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

svn_grass at osgeo.org svn_grass at osgeo.org
Wed Apr 17 05:22:21 PDT 2013


Author: martinl
Date: 2013-04-17 05:22:21 -0700 (Wed, 17 Apr 2013)
New Revision: 55853

Added:
   grass/trunk/vector/v.out.postgis/args.c
Removed:
   grass/trunk/vector/v.out.postgis/options.c
Modified:
   grass/trunk/vector/v.out.postgis/create.c
   grass/trunk/vector/v.out.postgis/local_proto.h
   grass/trunk/vector/v.out.postgis/main.c
Log:
v.out.postgis: rename file (follow naming conventions)
               remove create_table() - table is created automatically when writing new feature to the output


Copied: grass/trunk/vector/v.out.postgis/args.c (from rev 55852, grass/trunk/vector/v.out.postgis/options.c)
===================================================================
--- grass/trunk/vector/v.out.postgis/args.c	                        (rev 0)
+++ grass/trunk/vector/v.out.postgis/args.c	2013-04-17 12:22:21 UTC (rev 55853)
@@ -0,0 +1,67 @@
+#include <grass/gis.h>
+#include <grass/glocale.h>
+
+#include "local_proto.h"
+
+void define_options(struct params *params, struct flags *flags)
+{
+    params->input = G_define_standard_option(G_OPT_V_INPUT);
+    params->input->description = NULL;
+    
+    params->layer = G_define_standard_option(G_OPT_V_FIELD);
+    params->layer->description = NULL;
+    
+    params->dsn = G_define_option();
+    params->dsn->key = "dsn";
+    params->dsn->type = TYPE_STRING;
+    params->dsn->required = YES;
+    params->dsn->label = _("Name for output PostGIS datasource");
+    params->dsn->description =
+        _("Starts with 'PG' prefix, eg. 'PG:dbname=grass'");
+    
+    params->olayer = G_define_option();
+    params->olayer->key = "olayer";
+    params->olayer->type = TYPE_STRING;
+    params->olayer->required = NO;
+    params->olayer->key_desc = "name";
+    params->olayer->label =
+        _("Name for output PostGIS layer");
+    params->olayer->description = 
+        _("If not specified, input name is used");
+    params->olayer->guisection = _("Output settings");
+
+    params->olink = G_define_standard_option(G_OPT_V_OUTPUT);
+    params->olink->key = "olink";
+    params->olink->required = NO;
+    params->olink->label = 
+        _("Name for output vector map defined as a link to the PostGIS feature table");
+    params->olink->description = 
+        _("If not specified, the vector link is not created. "
+          "The link can be also manually created by 'v.external' module.");
+
+    params->opts = G_define_option();
+    params->opts->key = "options";
+    params->opts->label = _("Creation options");
+    params->opts->description = _("Examples:\n"
+                                  "\t\t'FID=cat': define feature id column 'cat'\n"
+                                  "\t\t'GEOMETRY_NAME=wkb_geometry': define geometry column 'wkb_geometry'\n"
+                                  "\t\t'SPATIAL_INDEX=NO': do not create spatial index on geometry column");
+    params->opts->required = NO;
+    params->opts->multiple = YES;
+    params->opts->type = TYPE_STRING;
+    params->opts->key_desc = "key=value";
+    params->opts->guisection = _("Output settings");
+
+    flags->table = G_define_flag();
+    flags->table->key = 't';
+    flags->table->description =
+        _("Don't export attribute table");
+    flags->table->guisection = _("Output settings");
+
+    flags->topo = G_define_flag();
+    flags->topo->key = 'l';
+    flags->topo->description =
+        _("Export PostGIS topology instead of simple features");
+    flags->topo->guisection = _("Output settings");
+}
+

Modified: grass/trunk/vector/v.out.postgis/create.c
===================================================================
--- grass/trunk/vector/v.out.postgis/create.c	2013-04-17 10:50:14 UTC (rev 55852)
+++ grass/trunk/vector/v.out.postgis/create.c	2013-04-17 12:22:21 UTC (rev 55853)
@@ -7,27 +7,6 @@
 
 static void file_handler(void *);
 
-void create_table(struct Map_info *In, struct Map_info *Out)
-{
-    int type;
-    struct Format_info_pg *pg_info;
-
-    pg_info = &(Out->fInfo.pg);
-    if (pg_info->feature_type != SF_UNKNOWN)
-        return;
-    
-    /* create PostGIS table if doesn't exist
-       determine feature type from the first feature */
-    Vect_rewind(In);
-    Vect_set_constraint_type(In, GV_POINT | GV_LINES);
-    type = Vect_read_next_line(In, NULL, NULL);
-    Vect_rewind(In);
-    
-    if (Vect_write_line(Out, type, NULL, NULL) < 0)
-        G_fatal_error(_("Unable to create PostGIS layer <%s>"),
-                      Vect_get_finfo_layer_name(Out));
-}
-
 char *create_pgfile(const char *dsn, const char *schema, const char *olink,
                     char **options, int topo,
 		    char **fid_column, char **geom_column)

Modified: grass/trunk/vector/v.out.postgis/local_proto.h
===================================================================
--- grass/trunk/vector/v.out.postgis/local_proto.h	2013-04-17 10:50:14 UTC (rev 55852)
+++ grass/trunk/vector/v.out.postgis/local_proto.h	2013-04-17 12:22:21 UTC (rev 55853)
@@ -11,14 +11,13 @@
     struct Flag *table, *topo;
 };
 
+/* args.c */
+void define_options(struct params *, struct flags *);
+
 /* create.c */
-void create_table(struct Map_info *, struct Map_info *);
 char *create_pgfile(const char *, const char *, const char *, char **, int,
 		    char **, char **);
 
-/* options.c */
-void define_options(struct params *, struct flags *);
-
 /* table.c */
 void check_columns(const struct Map_info *, const char *, const char *, const char *);
 

Modified: grass/trunk/vector/v.out.postgis/main.c
===================================================================
--- grass/trunk/vector/v.out.postgis/main.c	2013-04-17 10:50:14 UTC (rev 55852)
+++ grass/trunk/vector/v.out.postgis/main.c	2013-04-17 12:22:21 UTC (rev 55853)
@@ -6,7 +6,7 @@
  *
  * PURPOSE:      Converts GRASS vector map layer to PostGIS
  *
- * COPYRIGHT:    (C) 2012 by Martin Landa, and the GRASS Development Team
+ * COPYRIGHT:    (C) 2012-2013 by Martin Landa, and the GRASS Development Team
  *
  *               This program is free software under the GNU General
  *               Public License (>=v2). Read the file COPYING that
@@ -135,13 +135,7 @@
     if (!flags.table->answer)
         Vect_copy_map_dblinks(&In, &Out, TRUE);
 
-    /* create PostGIS layer */
-    create_table(&In, &Out);
-    
-    if (flags.topo->answer) 
-        Vect_build_partial(&Out, GV_BUILD_NONE); /* upgrade level to 2 */
-    
-    /* copy vector features */
+    /* copy vector features & create PostGIS table*/
     if (Vect_copy_map_lines_field(&In, field, &Out) != 0)
         G_fatal_error(_("Copying features failed"));
     

Deleted: grass/trunk/vector/v.out.postgis/options.c
===================================================================
--- grass/trunk/vector/v.out.postgis/options.c	2013-04-17 10:50:14 UTC (rev 55852)
+++ grass/trunk/vector/v.out.postgis/options.c	2013-04-17 12:22:21 UTC (rev 55853)
@@ -1,67 +0,0 @@
-#include <grass/gis.h>
-#include <grass/glocale.h>
-
-#include "local_proto.h"
-
-void define_options(struct params *params, struct flags *flags)
-{
-    params->input = G_define_standard_option(G_OPT_V_INPUT);
-    params->input->description = NULL;
-    
-    params->layer = G_define_standard_option(G_OPT_V_FIELD);
-    params->layer->description = NULL;
-    
-    params->dsn = G_define_option();
-    params->dsn->key = "dsn";
-    params->dsn->type = TYPE_STRING;
-    params->dsn->required = YES;
-    params->dsn->label = _("Name for output PostGIS datasource");
-    params->dsn->description =
-        _("Starts with 'PG' prefix, eg. 'PG:dbname=grass'");
-    
-    params->olayer = G_define_option();
-    params->olayer->key = "olayer";
-    params->olayer->type = TYPE_STRING;
-    params->olayer->required = NO;
-    params->olayer->key_desc = "name";
-    params->olayer->label =
-        _("Name for output PostGIS layer");
-    params->olayer->description = 
-        _("If not specified, input name is used");
-    params->olayer->guisection = _("Output settings");
-
-    params->olink = G_define_standard_option(G_OPT_V_OUTPUT);
-    params->olink->key = "olink";
-    params->olink->required = NO;
-    params->olink->label = 
-        _("Name for output vector map defined as a link to the PostGIS feature table");
-    params->olink->description = 
-        _("If not specified, the vector link is not created. "
-          "The link can be also manually created by 'v.external' module.");
-
-    params->opts = G_define_option();
-    params->opts->key = "options";
-    params->opts->label = _("Creation options");
-    params->opts->description = _("Examples:\n"
-                                  "\t\t'FID=cat': define feature id column 'cat'\n"
-                                  "\t\t'GEOMETRY_NAME=wkb_geometry': define geometry column 'wkb_geometry'\n"
-                                  "\t\t'SPATIAL_INDEX=NO': do not create spatial index on geometry column");
-    params->opts->required = NO;
-    params->opts->multiple = YES;
-    params->opts->type = TYPE_STRING;
-    params->opts->key_desc = "key=value";
-    params->opts->guisection = _("Output settings");
-
-    flags->table = G_define_flag();
-    flags->table->key = 't';
-    flags->table->description =
-        _("Don't export attribute table");
-    flags->table->guisection = _("Output settings");
-
-    flags->topo = G_define_flag();
-    flags->topo->key = 'l';
-    flags->topo->description =
-        _("Export PostGIS topology instead of simple features");
-    flags->topo->guisection = _("Output settings");
-}
-



More information about the grass-commit mailing list