[GRASS-SVN] r48300 - sandbox/martinl/v.topo.to.postgis
svn_grass at osgeo.org
svn_grass at osgeo.org
Thu Sep 15 06:20:20 EDT 2011
Author: martinl
Date: 2011-09-15 03:20:19 -0700 (Thu, 15 Sep 2011)
New Revision: 48300
Modified:
sandbox/martinl/v.topo.to.postgis/main.c
sandbox/martinl/v.topo.to.postgis/topo.c
Log:
v.topo.to.postgis: add summary
Modified: sandbox/martinl/v.topo.to.postgis/main.c
===================================================================
--- sandbox/martinl/v.topo.to.postgis/main.c 2011-09-15 09:11:40 UTC (rev 48299)
+++ sandbox/martinl/v.topo.to.postgis/main.c 2011-09-15 10:20:19 UTC (rev 48300)
@@ -88,8 +88,35 @@
Vect_topo_to_pg(&Map, conn,
G_check_overwrite(argc, argv));
- /* close the connection to the database and cleanup */
- PQfinish(conn);
+ if (conn) {
+ int i, j, nFields;
+ dbString stmt;
+ PGresult *res;
+
+ db_init_string(&stmt);
+ db_set_string(&stmt, "SELECT TopologySummary('");
+ db_append_string(&stmt, name);
+ db_append_string(&stmt, "')");
+ fprintf(stdout, "---------- SUMMARY ----------\n");
+ res = PQexec(conn, db_get_string(&stmt));
+ if (PQresultStatus(res) != PGRES_TUPLES_OK) {
+ PQclear(res);
+ PQfinish(conn);
+ G_fatal_error(_("%s command failed: %s"), "TopologySummary",
+ PQerrorMessage(conn));
+ }
+
+ nFields = PQnfields(res);
+ for (i = 0; i < PQntuples(res); i++) {
+ for (j = 0; j < nFields; j++)
+ fprintf(stdout, "%-15s", PQgetvalue(res, i, j));
+ }
+ G_done_msg(" ");
+
+ /* close the connection to the database and cleanup */
+ PQfinish(conn);
+ }
+
exit(EXIT_SUCCESS);
}
Modified: sandbox/martinl/v.topo.to.postgis/topo.c
===================================================================
--- sandbox/martinl/v.topo.to.postgis/topo.c 2011-09-15 09:11:40 UTC (rev 48299)
+++ sandbox/martinl/v.topo.to.postgis/topo.c 2011-09-15 10:20:19 UTC (rev 48300)
@@ -139,9 +139,9 @@
*res = PQexec(conn, db_get_string(stmt));
if (PQresultStatus(*res) != status) {
PQclear(*res);
+ PQfinish(conn);
G_fatal_error(_("%s command failed: %s"), cmd,
PQerrorMessage(conn));
- PQfinish(conn);
}
}
More information about the grass-commit
mailing list