[GRASS-SVN] r55409 - grass/trunk/lib/vector/Vlib
svn_grass at osgeo.org
svn_grass at osgeo.org
Sun Mar 17 07:18:28 PDT 2013
Author: martinl
Date: 2013-03-17 07:18:28 -0700 (Sun, 17 Mar 2013)
New Revision: 55409
Modified:
grass/trunk/lib/vector/Vlib/close.c
grass/trunk/lib/vector/Vlib/header_finfo.c
grass/trunk/lib/vector/Vlib/open.c
Log:
vlib(pg): use temporary map in native format when output is simple features
Modified: grass/trunk/lib/vector/Vlib/close.c
===================================================================
--- grass/trunk/lib/vector/Vlib/close.c 2013-03-17 13:41:22 UTC (rev 55408)
+++ grass/trunk/lib/vector/Vlib/close.c 2013-03-17 14:18:28 UTC (rev 55409)
@@ -81,11 +81,11 @@
Map->name, Map->mapset, Map->format, Map->level, Map->temporary);
if (Map->temporary &&
- (Map->fInfo.ogr.dsn || Map->fInfo.pg.db_name)) {
+ (Map->fInfo.ogr.dsn || Map->fInfo.pg.conninfo)) {
/* transfer features for external output format */
struct Map_info Out;
- putenv("GRASS_VECTOR_OGR_DIRECT=1");
+ putenv("GRASS_VECTOR_EXTERNAL_DIRECT=1");
if (-1 == Vect_open_new(&Out, Vect_get_name(Map), Vect_is_3d(Map))) {
G_warning(_("Unable to create vector map <%s>"),
Vect_get_name(Map));
@@ -103,7 +103,7 @@
Vect_build(&Out);
Vect_close(&Out);
- putenv("GRASS_VECTOR_OGR_DIRECT="); /* unset variable */
+ putenv("GRASS_VECTOR_EXTERNAL_DIRECT="); /* unset variable */
}
/* check for external formats whether to create a link */
Modified: grass/trunk/lib/vector/Vlib/header_finfo.c
===================================================================
--- grass/trunk/lib/vector/Vlib/header_finfo.c 2013-03-17 13:41:22 UTC (rev 55408)
+++ grass/trunk/lib/vector/Vlib/header_finfo.c 2013-03-17 14:18:28 UTC (rev 55409)
@@ -180,8 +180,8 @@
res = PQexec(pg_info->conn, stmt);
if (!res || PQresultStatus(res) != PGRES_TUPLES_OK ||
PQntuples(res) != 1) {
- G_warning("%s\n%s", _("Unable to get feature type"),
- PQresultErrorMessage(res));
+ G_debug(1, "Unable to get feature type: %s",
+ PQresultErrorMessage(res));
return NULL;
}
ftype_tmp = G_store(PQgetvalue(res, 0, 0));
Modified: grass/trunk/lib/vector/Vlib/open.c
===================================================================
--- grass/trunk/lib/vector/Vlib/open.c 2013-03-17 13:41:22 UTC (rev 55408)
+++ grass/trunk/lib/vector/Vlib/open.c 2013-03-17 14:18:28 UTC (rev 55409)
@@ -1200,7 +1200,7 @@
struct Format_info_ogr *ogr_info;
G_debug(2, " using OGR format");
- if (getenv("GRASS_VECTOR_OGR_DIRECT")) {
+ if (getenv("GRASS_VECTOR_EXTERNAL_DIRECT")) {
/* vector features are written directly to OGR layer */
format = GV_FORMAT_OGR;
}
@@ -1242,6 +1242,7 @@
G_warning(_("OGR output also detected, using OGR"));
}
else {
+ int topology;
FILE *fp;
const char *p;
@@ -1249,7 +1250,6 @@
struct Format_info_pg *pg_info;
G_debug(2, " using PostGIS format");
- format = GV_FORMAT_POSTGIS;
fp = G_fopen_old("", def_file ? def_file : "PG", G_mapset());
if (!fp) {
G_fatal_error(_("Unable to open PG file"));
@@ -1301,6 +1301,21 @@
/* table name */
Map->fInfo.pg.table_name = G_store(Map->name);
+
+ p = G_find_key_value("topology", key_val);
+ topology = p && G_strcasecmp(p, "yes") == 0;
+
+ if (topology || getenv("GRASS_VECTOR_EXTERNAL_DIRECT")) {
+ /* vector features are written directly to PostGIS layer */
+ format = GV_FORMAT_POSTGIS;
+ }
+ else {
+ /* vector features are written to the temporary vector map
+ * in the native format and when closing the map
+ * transfered to output PostGIS layer */
+ format = GV_FORMAT_NATIVE;
+ Map->temporary = TRUE;
+ }
}
}
More information about the grass-commit
mailing list