[GRASS-SVN] r49812 - in grass/trunk: include/defs lib/vector/Vlib lib/vector/diglib

svn_grass at osgeo.org svn_grass at osgeo.org
Sun Dec 18 14:01:00 EST 2011


Author: martinl
Date: 2011-12-18 11:00:59 -0800 (Sun, 18 Dec 2011)
New Revision: 49812

Modified:
   grass/trunk/include/defs/vector.h
   grass/trunk/lib/vector/Vlib/write_nat.c
   grass/trunk/lib/vector/Vlib/write_ogr.c
   grass/trunk/lib/vector/diglib/plus_area.c
   grass/trunk/lib/vector/diglib/plus_line.c
Log:
vlib: fix bug in dig_del_area() - update centroid topo
      V2_delete_line protype change to use integer for 'line'
      various minor fixes


Modified: grass/trunk/include/defs/vector.h
===================================================================
--- grass/trunk/include/defs/vector.h	2011-12-18 17:44:12 UTC (rev 49811)
+++ grass/trunk/include/defs/vector.h	2011-12-18 19:00:59 UTC (rev 49812)
@@ -493,9 +493,9 @@
 int V2_read_next_line_ogr(struct Map_info *, struct line_pnts *,
 			  struct line_cats *);
 int V1_delete_line_nat(struct Map_info *, off_t);
-int V2_delete_line_nat(struct Map_info *, off_t);
+int V2_delete_line_nat(struct Map_info *, int);
 int V1_delete_line_ogr(struct Map_info *, off_t);
-int V2_delete_line_ogr(struct Map_info *, off_t);
+int V2_delete_line_ogr(struct Map_info *, int);
 int V1_restore_line_nat(struct Map_info *, off_t);
 int V2_restore_line_nat(struct Map_info *, int, off_t);
 off_t V1_write_line_nat(struct Map_info *, int, const struct line_pnts *,

Modified: grass/trunk/lib/vector/Vlib/write_nat.c
===================================================================
--- grass/trunk/lib/vector/Vlib/write_nat.c	2011-12-18 17:44:12 UTC (rev 49811)
+++ grass/trunk/lib/vector/Vlib/write_nat.c	2011-12-18 19:00:59 UTC (rev 49812)
@@ -654,7 +654,7 @@
   \return 0 on success
   \return -1 on error
 */
-int V2_delete_line_nat(struct Map_info *Map, off_t line)
+int V2_delete_line_nat(struct Map_info *Map, int line)
 {
     int ret, i, side, type, first, next_line, area;
     struct P_line *Line;
@@ -665,7 +665,7 @@
     static struct line_cats *Cats = NULL;
     static struct line_pnts *Points = NULL;
 
-    G_debug(3, "V2_delete_line_nat(), line = %lu", (unsigned long) line);
+    G_debug(3, "V2_delete_line_nat(), line = %d", line);
 
     type = first = n_adjacent = 0;
     Line = NULL;
@@ -784,7 +784,10 @@
 		V2__delete_area_cats_from_cidx_nat(Map, topo->area);
 	    }
 	    Area = Map->plus.Area[topo->area];
-	    Area->centroid = 0;
+	    if (Area) 
+		Area->centroid = 0;
+	    else
+		G_warning(_("Attempt to access dead area (%d)"), topo->area);
 	}
     }
 

Modified: grass/trunk/lib/vector/Vlib/write_ogr.c
===================================================================
--- grass/trunk/lib/vector/Vlib/write_ogr.c	2011-12-18 17:44:12 UTC (rev 49811)
+++ grass/trunk/lib/vector/Vlib/write_ogr.c	2011-12-18 19:00:59 UTC (rev 49812)
@@ -36,7 +36,7 @@
 				     const struct line_cats *cats)
 {
     int first, s, i;
-    int type, area, side, new_area[2];
+    int type, area, side;
 
     struct Plus_head *plus;
     struct P_line *Line;
@@ -81,7 +81,6 @@
 		else
 		    Vect_box_extend(&abox, &box);
 	    }
-	    new_area[s] = area;
 	    G_debug(4, "Vect_build_line_area(): -> area = %d", area);
 	}
 
@@ -265,7 +264,7 @@
     if (ret != OGRERR_NONE)
 	return -1;
     
-    G_debug(3, "V1_write_line_ogr(): -> offset = %d", offset);
+    G_debug(3, "V1_write_line_ogr(): -> offset = %lu", (unsigned long) offset);
 
     return offset;
 }
@@ -309,9 +308,9 @@
 	    Vect_box_extend(&(plus->box), &box);
 
 	if (type == GV_BOUNDARY) {
-	    int ret, cline, lines[1];
+	    int ret, cline;
 	    long FID;
-	    double x, y, area_size;
+	    double x, y;
 	    
 	    struct bound_box box;
 	    struct line_pnts *CPoints;
@@ -327,7 +326,7 @@
 		dig_line_box(CPoints, &box);
 		cline = dig_add_line(plus, GV_CENTROID,
 				     CPoints, &box, FID);
-		G_debug(4, "\tCentroid: x = %f, y = %f, cat = %d, line = %d",
+		G_debug(4, "\tCentroid: x = %f, y = %f, cat = %lu, line = %d",
 			x, y, FID, cline);	  
 		dig_cidx_add_cat(plus, 1, (int) FID,
 				 cline, GV_CENTROID);
@@ -443,7 +442,7 @@
   \return 0 on success
   \return -1 on error
 */
-int V2_delete_line_ogr(struct Map_info *Map, off_t line)
+int V2_delete_line_ogr(struct Map_info *Map, int line)
 {
     int ret, i, type, first;
     struct P_line *Line;
@@ -451,7 +450,7 @@
     static struct line_cats *Cats = NULL;
     static struct line_pnts *Points = NULL;
 
-    G_debug(3, "V2_delete_line_ogr(), line = %d", (int) line);
+    G_debug(3, "V2_delete_line_ogr(), line = %d", line);
 
     type = first = 0;
     Line = NULL;

Modified: grass/trunk/lib/vector/diglib/plus_area.c
===================================================================
--- grass/trunk/lib/vector/diglib/plus_area.c	2011-12-18 17:44:12 UTC (rev 49811)
+++ grass/trunk/lib/vector/diglib/plus_area.c	2011-12-18 19:00:59 UTC (rev 49812)
@@ -346,12 +346,12 @@
 {
     int i, line;
 
-    /* int    isle, area_out; */
     struct P_area *Area;
     struct P_line *Line;
     struct P_isle *Isle;
-    struct P_topo_b *topo;
-
+    struct P_topo_b *btopo;
+    struct P_topo_c *ctopo;
+    
     G_debug(3, "dig_del_area() area =  %d", area);
     Area = plus->Area[area];
 
@@ -367,16 +367,16 @@
     for (i = 0; i < Area->n_lines; i++) {
 	line = Area->lines[i];	/* >0 = clockwise -> right, <0 = counterclockwise ->left */
 	Line = plus->Line[abs(line)];
-	topo = (struct P_topo_b *)Line->topo;
+	btopo = (struct P_topo_b *)Line->topo;
 	if (plus->do_uplist)
 	    dig_line_add_updated(plus, abs(line));
 	if (line > 0) {
 	    G_debug(3, "  Set line %d right side to 0", line);
-	    topo->right = 0;
+	    btopo->right = 0;
 	}
 	else {
 	    G_debug(3, "  Set line %d left side to 0", line);
-	    topo->left = 0;
+	    btopo->left = 0;
 	}
 
 	/* Find the isle this area is part of (used late below) */
@@ -401,8 +401,8 @@
 		      line);
 	}
 	else {
-	    topo = (struct P_topo_b *)Line->topo;
-	    topo->left = 0;
+	    ctopo = (struct P_topo_c *)Line->topo;
+	    ctopo->area = 0;
 	    if (plus->do_uplist)
 		dig_line_add_updated(plus, line);
 	}

Modified: grass/trunk/lib/vector/diglib/plus_line.c
===================================================================
--- grass/trunk/lib/vector/diglib/plus_line.c	2011-12-18 17:44:12 UTC (rev 49811)
+++ grass/trunk/lib/vector/diglib/plus_line.c	2011-12-18 19:00:59 UTC (rev 49812)
@@ -324,8 +324,11 @@
     struct P_topo_b *topo;
 
     Line = plus->Line[line];
+    if (!Line) /* dead */
+	return -1;
+    
     if (Line->type != GV_BOUNDARY)
-	return (-1);
+	return -1;
 
     topo = (struct P_topo_b *)Line->topo;
     if (side == GV_LEFT) {



More information about the grass-commit mailing list