Prechádzať zdrojové kódy

Vlib: Don't select duplicate areas

git-svn-id: https://svn.osgeo.org/grass/grass/trunk@70711 15284696-431f-4ddb-bdfa-cd5b030d7da7
Huidae Cho 8 rokov pred
rodič
commit
d85ab89667
1 zmenil súbory, kde vykonal 12 pridanie a 14 odobranie
  1. 12 14
      lib/vector/Vlib/sindex.c

+ 12 - 14
lib/vector/Vlib/sindex.c

@@ -44,7 +44,7 @@ Vect_select_lines_by_box(struct Map_info *Map, const struct bound_box *Box,
 	    Box->E, Box->W, Box->T, Box->B);
     plus = &(Map->plus);
 
-    list->n_values = 0;
+    Vect_reset_list(list);
 
     ntypes = mtype = 0;
     /* count the number of different primitives in Map */
@@ -203,7 +203,7 @@ Vect_select_nodes_by_box(struct Map_info *Map, const struct bound_box * Box,
 
     plus = &(Map->plus);
 
-    list->n_values = 0;
+    Vect_reset_list(list);
 
     dig_select_nodes(plus, Box, list);
     G_debug(3, "  %d nodes selected", list->n_values);
@@ -238,7 +238,7 @@ Vect_select_lines_by_polygon(struct Map_info *Map, struct line_pnts *Polygon,
     /* TODO: this function was not tested with isles */
     G_debug(3, "Vect_select_lines_by_polygon() nisles = %d", nisles);
 
-    List->n_values = 0;
+    Vect_reset_list(List);
     if (!LPoints)
 	LPoints = Vect_new_line_struct();
     if (!LocList) {
@@ -279,14 +279,14 @@ Vect_select_lines_by_polygon(struct Map_info *Map, struct line_pnts *Polygon,
 	    }
 	}
 	if (intersect) {
-	    G_ilist_add(List, line);
+	    Vect_list_append(List, line);
 	    continue;
 	}
 
 	/* Check intersections of the line with area/isles boundary */
 	/* Outer boundary */
 	if (Vect_line_check_intersection(LPoints, Polygon, 0)) {
-	    G_ilist_add(List, line);
+	    Vect_list_append(List, line);
 	    continue;
 	}
 
@@ -298,7 +298,7 @@ Vect_select_lines_by_polygon(struct Map_info *Map, struct line_pnts *Polygon,
 	    }
 	}
 	if (intersect) {
-	    G_ilist_add(List, line);
+	    Vect_list_append(List, line);
 	}
     }
 
@@ -313,8 +313,6 @@ Vect_select_lines_by_polygon(struct Map_info *Map, struct line_pnts *Polygon,
 
    Polygons should be closed, i.e. first and last points must be identical.
 
-   Warning : values in list may be duplicate!
-
    \param Map vector map
    \param Polygon outer ring
    \param nisles number of islands or 0
@@ -334,7 +332,7 @@ Vect_select_areas_by_polygon(struct Map_info *Map, struct line_pnts *Polygon,
     /* TODO: this function was not tested with isles */
     G_debug(3, "Vect_select_areas_by_polygon() nisles = %d", nisles);
 
-    List->n_values = 0;
+    Vect_reset_list(List);
     if (!BoundList)
 	BoundList = Vect_new_list();
 
@@ -352,23 +350,23 @@ Vect_select_areas_by_polygon(struct Map_info *Map, struct line_pnts *Polygon,
 	G_debug(4, "boundary = %d left = %d right = %d", line, left, right);
 
 	if (left > 0) {
-	    G_ilist_add(List, left);
+	    Vect_list_append(List, left);
 	}
 	else if (left < 0) {	/* island */
 	    area = Vect_get_isle_area(Map, abs(left));
 	    G_debug(4, "  left island -> area = %d", area);
 	    if (area > 0)
-		G_ilist_add(List, area);
+		Vect_list_append(List, area);
 	}
 
 	if (right > 0) {
-	    G_ilist_add(List, right);
+	    Vect_list_append(List, right);
 	}
 	else if (right < 0) {	/* island */
 	    area = Vect_get_isle_area(Map, abs(right));
 	    G_debug(4, "  right island -> area = %d", area);
 	    if (area > 0)
-		G_ilist_add(List, area);
+		Vect_list_append(List, area);
 	}
     }
 
@@ -376,7 +374,7 @@ Vect_select_areas_by_polygon(struct Map_info *Map, struct line_pnts *Polygon,
      * we find the area by one polygon point and add it to the list */
     area = Vect_find_area(Map, Polygon->x[0], Polygon->y[0]);
     if (area > 0)
-	G_ilist_add(List, area);
+	Vect_list_append(List, area);
 
     G_debug(3, "  %d areas selected by polygon", List->n_values);