Browse Source

diglib: change content of list of changed lines

git-svn-id: https://svn.osgeo.org/grass/grass/trunk@63265 15284696-431f-4ddb-bdfa-cd5b030d7da7
Markus Metz 10 years ago
parent
commit
fe975e7913

+ 1 - 1
include/vect/dig_externs.h

@@ -252,7 +252,7 @@ int dig_type_from_store(int);
 /* update.c */
 /* list of updated */
 void dig_line_reset_updated(struct Plus_head *);
-void dig_line_add_updated(struct Plus_head *, int);
+void dig_line_add_updated(struct Plus_head *, int, off_t);
 void dig_node_reset_updated(struct Plus_head *);
 void dig_node_add_updated(struct Plus_head *, int);
 

+ 1 - 7
lib/vector/Vlib/build.c

@@ -535,18 +535,12 @@ int Vect_attach_centroids(struct Map_info *Map, const struct bound_box * box)
 		G_debug(3, "\tfirst centroid -> attach to area");
 		Area->centroid = centr;
 		topo->area = sel_area;
-
-		if (sel_area != orig_area && plus->uplist.do_uplist)
-                  dig_line_add_updated(plus, centr);
 	    }
 	    else if (Area->centroid != centr) {	/* duplicate centroid */
 		/* Note: it cannot happen that Area->centroid == centr, because the centroid
 		 * was not registered or a duplicate */
 		G_debug(3, "\tduplicate centroid -> do not attach to area");
 		topo->area = -sel_area;
-
-		if (-sel_area != orig_area && plus->uplist.do_uplist)
-                  dig_line_add_updated(plus, centr);
 	    }
 	}
     }
@@ -864,7 +858,7 @@ int Vect_build_partial(struct Map_info *Map, int build)
     plus->with_z = Map->head.with_z;
     plus->spidx_with_z = Map->head.with_z;
 
-    if (build == GV_BUILD_ALL) {
+    if (build == GV_BUILD_ALL && plus->built < GV_BUILD_ALL) {
 	dig_cidx_free(plus);	/* free old (if any) category index */
 	dig_cidx_init(plus);
     }

+ 1 - 2
lib/vector/Vlib/open_pg.c

@@ -955,8 +955,7 @@ struct P_line *read_p_line(struct Plus_head *plus, int n,
     
     if (plus->uplist.do_uplist) {
         /* collect updated lines if requested */
-        dig_line_add_updated(plus, n);
-        plus->uplist.uplines_offset[plus->uplist.n_uplines - 1] = line->offset;
+        dig_line_add_updated(plus, n, line->offset);
     }
     
     plus->Line[n] = line;

+ 0 - 10
lib/vector/diglib/plus_area.c

@@ -210,8 +210,6 @@ int dig_add_area(struct Plus_head *plus, int n_lines, plus_t * lines,
 	Area->lines[i] = line;
 	Line = plus->Line[abs(line)];
 	topo = (struct P_topo_b *)Line->topo;
-	if (plus->uplist.do_uplist)
-	    dig_line_add_updated(plus, abs(line));
 	if (line < 0) {		/* revers direction -> area on left */
 	    if (topo->left != 0) {
 		G_warning(_("Line %d already has area/isle %d to left"), line,
@@ -380,8 +378,6 @@ int dig_del_area(struct Plus_head *plus, int area)
 	line = Area->lines[i];	/* >0 = clockwise -> right, <0 = counterclockwise ->left */
 	Line = plus->Line[abs(line)];
 	btopo = (struct P_topo_b *)Line->topo;
-	if (plus->uplist.do_uplist)
-	    dig_line_add_updated(plus, abs(line));
 	if (line > 0) {
 	    G_debug(3, "  Set line %d right side to 0", line);
 	    btopo->right = 0;
@@ -415,8 +411,6 @@ int dig_del_area(struct Plus_head *plus, int area)
 	else {
 	    ctopo = (struct P_topo_c *)Line->topo;
 	    ctopo->area = 0;
-	    if (plus->uplist.do_uplist)
-		dig_line_add_updated(plus, line);
 	}
     }
 
@@ -712,8 +706,6 @@ int dig_add_isle(struct Plus_head *plus, int n_lines, plus_t * lines,
 	Isle->lines[i] = line;
 	Line = plus->Line[abs(line)];
 	topo = (struct P_topo_b *)Line->topo;
-	if (plus->uplist.do_uplist)
-	    dig_line_add_updated(plus, abs(line));
 	if (line < 0) {		/* revers direction -> isle on left */
 	    if (topo->left != 0) {
 		G_warning(_("Line %d already has area/isle %d to left"), line,
@@ -772,8 +764,6 @@ int dig_del_isle(struct Plus_head *plus, int isle)
 	line = Isle->lines[i];	/* >0 = clockwise -> right, <0 = counterclockwise ->left */
 	Line = plus->Line[abs(line)];
 	topo = (struct P_topo_b *)Line->topo;
-	if (plus->uplist.do_uplist)
-	    dig_line_add_updated(plus, abs(line));
 	if (line > 0)
 	    topo->right = 0;
 	else

+ 2 - 4
lib/vector/diglib/plus_line.c

@@ -32,8 +32,7 @@ static int add_line(struct Plus_head *plus, int lineid, int type, const struct l
 
     dig_spidx_add_line(plus, lineid, box);
     if (plus->uplist.do_uplist) {
-	dig_line_add_updated(plus, lineid);
-	plus->uplist.uplines_offset[plus->uplist.n_uplines - 1] = line->offset;
+	dig_line_add_updated(plus, lineid, offset);
     }
     
     if (type & GV_POINT) {
@@ -229,8 +228,7 @@ int dig_del_line(struct Plus_head *plus, int line, double x, double y, double z)
     dig_spidx_del_line(plus, line, x, y, z);
 
     if (plus->uplist.do_uplist) {
-	dig_line_add_updated(plus, line);
-	plus->uplist.uplines_offset[plus->uplist.n_uplines - 1] = -1 * Line->offset;
+	dig_line_add_updated(plus, line, -Line->offset);
     }
     
     if (!(Line->type & GV_LINES)) {

+ 3 - 1
lib/vector/diglib/update.c

@@ -34,7 +34,7 @@ void dig_line_reset_updated(struct Plus_head *Plus)
    \param line line id
    \param offset line offset (negative offset is ignored)
  */
-void dig_line_add_updated(struct Plus_head *Plus, int line)
+void dig_line_add_updated(struct Plus_head *Plus, int line, off_t offset)
 {
     int i;
     
@@ -43,6 +43,7 @@ void dig_line_add_updated(struct Plus_head *Plus, int line)
     /* Check if already in list */
     for (i = 0; i < Plus->uplist.n_uplines; i++) {
 	if (Plus->uplist.uplines[i] == line) {
+	    Plus->uplist.uplines_offset[i] = offset;
             G_debug(3, "\tskipped");
 	    return;
         }
@@ -60,6 +61,7 @@ void dig_line_add_updated(struct Plus_head *Plus, int line)
     }
 
     Plus->uplist.uplines[Plus->uplist.n_uplines] = line;
+    Plus->uplist.uplines_offset[Plus->uplist.n_uplines] = offset;
     Plus->uplist.n_uplines++;
 }