[GRASS-SVN] r51128 - in grass/trunk: lib/vector/Vlib vector/v.edit
svn_grass at osgeo.org
svn_grass at osgeo.org
Wed Mar 21 10:21:47 EDT 2012
Author: martinl
Date: 2012-03-21 07:21:47 -0700 (Wed, 21 Mar 2012)
New Revision: 51128
Modified:
grass/trunk/lib/vector/Vlib/open_pg.c
grass/trunk/vector/v.edit/main.c
Log:
v.edit: fix `tool=create` for PostGIS data driver
Modified: grass/trunk/lib/vector/Vlib/open_pg.c
===================================================================
--- grass/trunk/lib/vector/Vlib/open_pg.c 2012-03-21 11:37:08 UTC (rev 51127)
+++ grass/trunk/lib/vector/Vlib/open_pg.c 2012-03-21 14:21:47 UTC (rev 51128)
@@ -246,8 +246,9 @@
}
}
else {
- G_warning(_("PostGIS layer <%s> already exists in database '%s'"),
- pg_info->table_name, pg_info->db_name);
+ G_fatal_error(_("PostGIS layer <%s.%s> already exists in database '%s'"),
+ pg_info->schema_name, pg_info->table_name,
+ pg_info->db_name);
return -1;
}
}
Modified: grass/trunk/vector/v.edit/main.c
===================================================================
--- grass/trunk/vector/v.edit/main.c 2012-03-21 11:37:08 UTC (rev 51127)
+++ grass/trunk/vector/v.edit/main.c 2012-03-21 14:21:47 UTC (rev 51128)
@@ -84,10 +84,12 @@
G_fatal_error(_("Required parameter <%s> not set"), params.in->key);
if (action_mode == MODE_CREATE) {
- int overwrite;
-
+ int overwrite, map_type;
+
overwrite = G_check_overwrite(argc, argv);
- if (G_find_vector2(params.map->answer, G_mapset())) {
+ if (G_find_vector2(params.map->answer, G_mapset()) &&
+ (!G_find_file("", "OGR", G_mapset()) &&
+ !G_find_file("", "PG", G_mapset()))) {
if (!overwrite)
G_fatal_error(_("Vector map <%s> already exists"),
params.map->answer);
@@ -95,20 +97,26 @@
/* 3D vector maps? */
ret = Vect_open_new(&Map, params.map->answer, WITHOUT_Z);
- if (Vect_maptype(&Map) == GV_FORMAT_OGR_DIRECT) {
+ if (ret == -1) {
+ G_fatal_error(_("Unable to create vector map <%s>"),
+ params.map->answer);
+ }
+
+ /* native or external data source ? */
+ map_type = Vect_maptype(&Map);
+ if (map_type != GV_FORMAT_NATIVE) {
int type;
type = Vect_option_to_types(params.type);
if (type != GV_POINT && type != GV_LINE &&
type != GV_BOUNDARY)
G_fatal_error(_("Supported feature type for OGR layer: "
"%s, %s or %s"), "point", "line", "boundary");
- V2_open_new_ogr(&Map, type);
+ if (map_type == GV_FORMAT_POSTGIS)
+ V2_open_new_pg(&Map, type);
+ else
+ V2_open_new_ogr(&Map, type);
}
- if (ret == -1) {
- G_fatal_error(_("Unable to create vector map <%s>"),
- params.map->answer);
- }
-
+
G_debug(1, "Map created");
if (ascii) {
More information about the grass-commit
mailing list