[GRASS-SVN] r56448 - grass/trunk/lib/vector/Vlib

svn_grass at osgeo.org svn_grass at osgeo.org
Tue May 28 04:23:21 PDT 2013


Author: martinl
Date: 2013-05-28 04:23:21 -0700 (Tue, 28 May 2013)
New Revision: 56448

Modified:
   grass/trunk/lib/vector/Vlib/build_pg.c
Log:
vlib(pg): fix write_areas() for areas which do not have centroid


Modified: grass/trunk/lib/vector/Vlib/build_pg.c
===================================================================
--- grass/trunk/lib/vector/Vlib/build_pg.c	2013-05-28 10:39:40 UTC (rev 56447)
+++ grass/trunk/lib/vector/Vlib/build_pg.c	2013-05-28 11:23:21 UTC (rev 56448)
@@ -601,18 +601,28 @@
     stmt_lines = stmt_isles = NULL;
     for (area = 1; area <= plus->n_areas; area++) {
         Area = plus->Area[area];
-        if (!Area)
+        if (!Area) {
+            G_debug(3, "Area %d skipped (dead)", area);
             continue; /* should not happen */
+        }
         
         /* 'lines' array */
         build_stmt_id(Area->lines, Area->n_lines, TRUE, NULL, &stmt_lines, &stmt_lines_size);
         /* 'isles' array */
         build_stmt_id(Area->isles, Area->n_isles, TRUE, NULL, &stmt_isles, &stmt_isles_size);
         
-        Line = plus->Line[Area->centroid];
-        if (!Line)
-            return -1;
-        centroid = (int) Line->offset;
+        if (Area->centroid != 0) {
+            Line = plus->Line[Area->centroid];
+            if (!Line) {
+                G_warning(_("Topology for centroid %d not available. Area %d skipped"),
+                          Area->centroid, area);
+                continue;
+            }
+            centroid = (int) Line->offset;
+        }
+        else {
+            centroid = 0;
+        }
         
         /* build SQL statement to add new node into 'node_grass' */
         sprintf(stmt, "INSERT INTO \"%s\".%s VALUES ("



More information about the grass-commit mailing list