Browse Source

v.overlay speed-up

git-svn-id: https://svn.osgeo.org/grass/grass/trunk@53688 15284696-431f-4ddb-bdfa-cd5b030d7da7
Markus Metz 12 years ago
parent
commit
ee7faa23e0
4 changed files with 15 additions and 10 deletions
  1. 2 2
      vector/v.overlay/area_area.c
  2. 2 2
      vector/v.overlay/line_area.c
  3. 2 2
      vector/v.overlay/local.h
  4. 9 4
      vector/v.overlay/main.c

+ 2 - 2
vector/v.overlay/area_area.c

@@ -17,7 +17,7 @@
 
 int area_area(struct Map_info *In, int *field, struct Map_info *Out,
 	      struct field_info *Fi, dbDriver * driver, int operator,
-	      int *ofield, ATTRIBUTES * attr)
+	      int *ofield, ATTRIBUTES * attr, struct ilist *BList)
 {
     int ret, input, line, nlines, area, nareas;
     int in_area, in_centr, out_cat;
@@ -37,7 +37,7 @@ int area_area(struct Map_info *In, int *field, struct Map_info *Out,
      * and Vect_clean_small_angles_at_nodes() until no more small dangles are found */
     do {
 	G_message(_("Breaking lines..."));
-	Vect_break_lines(Out, GV_LINE | GV_BOUNDARY, NULL);
+	Vect_break_lines_list(Out, NULL, BList, GV_LINE | GV_BOUNDARY, NULL);
 
 	/* Probably not necessary for LINE x AREA */
 	G_message(_("Removing duplicates..."));

+ 2 - 2
vector/v.overlay/line_area.c

@@ -51,7 +51,7 @@ int point_area(struct Map_info *Map, int field, double x, double y,
 
 int line_area(struct Map_info *In, int *field, struct Map_info *Out,
 	      struct field_info *Fi, dbDriver * driver, int operator,
-	      int *ofield, ATTRIBUTES * attr)
+	      int *ofield, ATTRIBUTES * attr, struct ilist *BList)
 {
     int line, nlines, ncat;
     struct line_pnts *Points;
@@ -67,7 +67,7 @@ int line_area(struct Map_info *In, int *field, struct Map_info *Out,
     db_init_string(&stmt);
 
     G_message(_("Breaking lines..."));
-    Vect_break_lines(Out, GV_LINE | GV_BOUNDARY, NULL);
+    Vect_break_lines_list(Out, NULL, BList, GV_LINE | GV_BOUNDARY, NULL);
 
     /* Basic topology needed only */
     Vect_build_partial(Out, GV_BUILD_BASE);

+ 2 - 2
vector/v.overlay/local.h

@@ -32,7 +32,7 @@ ATTR *find_attr(ATTRIBUTES * attributes, int cat);
 
 int area_area(struct Map_info *In, int *field, struct Map_info *Out,
 	      struct field_info *Fi, dbDriver * driver, int operator,
-	      int *ofield, ATTRIBUTES * attr);
+	      int *ofield, ATTRIBUTES * attr, struct ilist *BList);
 int line_area(struct Map_info *In, int *field, struct Map_info *Out,
 	      struct field_info *Fi, dbDriver * driver, int operator,
-	      int *ofield, ATTRIBUTES * attr);
+	      int *ofield, ATTRIBUTES * attr, struct ilist *BList);

+ 9 - 4
vector/v.overlay/main.c

@@ -40,6 +40,7 @@ int main(int argc, char *argv[])
     struct Map_info In[2], Out;
     struct line_pnts *Points;
     struct line_cats *Cats;
+    struct ilist *BList;
     char *desc;
 
     struct field_info *Fi = NULL;
@@ -194,8 +195,10 @@ int main(int argc, char *argv[])
     }
 
     /* Copy lines to output */
+    BList = Vect_new_list();
+    Vect_build_partial(&Out, GV_BUILD_BASE);
     for (input = 0; input < 2; input++) {
-	int ncats, index, nlines_out;
+	int ncats, index, nlines_out, newline;
 
 	Vect_set_open_level(2);
 	Vect_open_old2(&(In[input]), in_opt[input]->answer, "", field_opt[input]->answer);
@@ -223,7 +226,9 @@ int main(int argc, char *argv[])
 		    continue;
 	    }
 
-	    Vect_write_line(&Out, ltype, Points, Cats);
+	    newline = Vect_write_line(&Out, ltype, Points, Cats);
+	    if (input == 1)
+		G_ilist_add(BList, newline);
 	    nlines_out++;
 	}
 	if (nlines_out == 0) {
@@ -485,10 +490,10 @@ int main(int argc, char *argv[])
 
     /* AREA x AREA */
     if (type[0] == GV_AREA) {
-	area_area(In, field, &Out, Fi, driver, operator, ofield, attr);
+	area_area(In, field, &Out, Fi, driver, operator, ofield, attr, BList);
     }
     else {			/* LINE x AREA */
-	line_area(In, field, &Out, Fi, driver, operator, ofield, attr);
+	line_area(In, field, &Out, Fi, driver, operator, ofield, attr, BList);
     }
 
     G_message(_("Rebuilding topology..."));