[GRASS5] [bug #1177] (grass) v.digit break line command should keep information about areas

Request Tracker grass-bugs at intevation.de
Wed Jul 3 16:57:28 EDT 2002


this bug's URL: http://intevation.de/rt/webrt?serial_num=1177
-------------------------------------------------------------------------

Subject: v.digit break line command should keep information about areas

Platform: GNU/Linux/i386
grass obtained from: Trento Italy site
grass binary for platform: Compiled from Sources

  Hi,

  When using "break line" it will destroy the attribute/category information of the areas to the left and to the right of the "broken line". But the act of breaking a line can also be seen as adding a new node to the line.

  I wrote this patch to mapdev/v.digit/break.c:

--%<--
--- break.c.orig	2002-07-03 14:05:50.000000000 -0300
+++ break.c	2002-07-03 16:17:21.000000000 -0300
@@ -105,6 +105,8 @@
     int label;
     int N1, N2;
     int line1, line2;
+    int area1, area2, cat1, cat2;
+    double x1, y1, x2, y2;
 
     if (first_time)	/* change 10/90   was buggy in 3.1  */
     {
@@ -115,6 +117,18 @@
 
     Line = &(map->Line[line]);
 
+    /* Save information about areas around line being "broken" */
+    if ((area1 = abs(Line->left)) != 0) {
+	x1 = map->Att[map->Area[area1].att].x;
+	y1 = map->Att[map->Area[area1].att].y;
+	cat1 = map->Att[map->Area[area1].att].cat;
+    }
+    if ((area2 = abs(Line->right)) != 0) {
+	x2 = map->Att[map->Area[area2].att].x;
+	y2 = map->Att[map->Area[area2].att].y;
+	cat2 = map->Att[map->Area[area2].att].cat;
+    }
+
     /* hold on to node numbers for new lines */
     N1 = Line->N1;
     N2 = Line->N2;
@@ -231,5 +245,31 @@
 	return (-1);
     }
     display_line (type, &NPoints, line1, map);
+
+    /* Restore attributes of areas around "broken" line */
+    if (area1 || area2) {
+	int att;
+
+	if (area1) {
+	    dig_build_area_with_line(map, line1, &Garea);
+	    att = dig_new_att(map, x1, y1, AREA, area1, cat1);
+	    map->Area[area1].att = att;
+	    map->Area[area1].alive = 1;
+	    map->Line[line1].left = map->Line[line2].left = area1;
+	    if (area2)
+		map->Line[line2].left = area1;
+	    Vect__Rewrite_line(map, map->Line[line1].offset, AREA, &Gpoints);
+	}
+
+	if (area2) {
+	    dig_build_area_with_line(map, -line1, &Garea);
+	    att = dig_new_att(map, x2, y2, AREA, area2, cat2);
+	    map->Area[area2].att = att;
+	    map->Area[area2].alive = 1;
+	    map->Line[line1].right = map->Line[line2].right = area2;
+	    Vect__Rewrite_line(map, map->Line[line2].offset, AREA, &Gpoints);
+	}
+    }
+
     return (0);
 }
--%<--

  I am not sure if it is the correct way to do it, but this patch seens to work for the behaviour the user asked for (subdivide polygons but not miss the category information of the unmodified polygons that touch the modified ones).

  Hope this is useful.


-------------------------------------------- Managed by Request Tracker



More information about the grass-dev mailing list