[GRASS-SVN] r52005 - grass/trunk/lib/vector/Vlib
svn_grass at osgeo.org
svn_grass at osgeo.org
Thu Jun 7 16:03:39 PDT 2012
Author: martinl
Date: 2012-06-07 16:03:39 -0700 (Thu, 07 Jun 2012)
New Revision: 52005
Modified:
grass/trunk/lib/vector/Vlib/open_pg.c
Log:
vlib/pg: attach centroids when building topo from PostGIS topology schema
Modified: grass/trunk/lib/vector/Vlib/open_pg.c
===================================================================
--- grass/trunk/lib/vector/Vlib/open_pg.c 2012-06-07 22:36:38 UTC (rev 52004)
+++ grass/trunk/lib/vector/Vlib/open_pg.c 2012-06-07 23:03:39 UTC (rev 52005)
@@ -1261,7 +1261,8 @@
struct Format_info_pg *pg_info;
struct Plus_head *plus;
- struct P_line *Line;
+ struct P_line *line;
+ struct P_area *area;
PGresult *res;
@@ -1366,9 +1367,9 @@
line_data.right_face = atoi(PQgetvalue(res, i, 4));
id = plus->n_plines + i + 1; /* points already registered */
- Line = read_p_line(plus, id, &line_data);
+ line = read_p_line(plus, id, &line_data);
if (line_data.left_face != 0 || line_data.right_face != 0) {
- /* boundary detected -> build area on left and right*/
+ /* boundary detected -> build area/isle on left and right*/
int s, side;
for (s = 0; s < 2; s++) {
@@ -1382,7 +1383,7 @@
Vect_build_line_area(Map, id, side);
}
}
- if (Line->type == GV_BOUNDARY) {
+ if (line->type == GV_BOUNDARY) {
struct P_topo_b *topo;
if (line_data.left_face == 0)
@@ -1390,7 +1391,7 @@
if (line_data.right_face == 0)
line_data.right_face = -1;
- topo = (struct P_topo_b *)Line->topo;
+ topo = (struct P_topo_b *)line->topo;
if (topo->left != line_data.left_face)
G_warning(_("Left area detected as %d (should be %d"),
topo->left, line_data.left_face);
@@ -1401,6 +1402,16 @@
}
PQclear(res);
+ /* attach centroids */
+ G_zero(&line_data, sizeof(struct edge_data));
+ for (i = 1; i <= plus->n_areas; i++) {
+ area = plus->Area[i];
+
+ line_data.id = plus->n_lines - plus->n_clines + i;
+ line_data.left_face = i;
+ read_p_line(plus, line_data.id, &line_data);
+ area->centroid = line_data.id;
+ }
return 0;
}
More information about the grass-commit
mailing list