Browse Source

remove redundant code in vector lib: update Vlib

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

+ 3 - 3
lib/vector/Vlib/box.c

@@ -250,7 +250,7 @@ int Vect_get_line_box(const struct Map_info *Map, int line, struct bound_box * B
 	    }
 	    }
 	    
 	    
 	    if (list == NULL) {
 	    if (list == NULL) {
-		list = Vect_new_boxlist();
+		list = Vect_new_boxlist(1);
 	    }
 	    }
 	    Vect_reset_boxlist(list);
 	    Vect_reset_boxlist(list);
 	    
 	    
@@ -318,7 +318,7 @@ int Vect_get_area_box(const struct Map_info *Map, int area, struct bound_box * B
 	Node = Plus->Node[topo->N1];
 	Node = Plus->Node[topo->N1];
 
 
 	if (list == NULL) {
 	if (list == NULL) {
-	    list = Vect_new_boxlist();
+	    list = Vect_new_boxlist(1);
 	}
 	}
 	Vect_reset_boxlist(list);
 	Vect_reset_boxlist(list);
 	
 	
@@ -384,7 +384,7 @@ int Vect_get_isle_box(const struct Map_info *Map, int isle, struct bound_box * B
 	Node = Plus->Node[topo->N1];
 	Node = Plus->Node[topo->N1];
 
 
 	if (list == NULL) {
 	if (list == NULL) {
-	    list = Vect_new_boxlist();
+	    list = Vect_new_boxlist(1);
 	}
 	}
 	Vect_reset_boxlist(list);
 	Vect_reset_boxlist(list);
 	
 	

+ 5 - 5
lib/vector/Vlib/break_lines.c

@@ -70,7 +70,7 @@ Vect_break_lines_list(struct Map_info *Map, struct ilist *List_break,
     int naxlines, nbxlines, nx;
     int naxlines, nbxlines, nx;
     double *xx = NULL, *yx = NULL, *zx = NULL;
     double *xx = NULL, *yx = NULL, *zx = NULL;
     struct bound_box ABox, BBox;
     struct bound_box ABox, BBox;
-    struct ilist *List;
+    struct boxlist *List;
     int nbreaks;
     int nbreaks;
     int touch1_n = 0, touch1_s = 0, touch1_e = 0, touch1_w = 0;	/* other vertices except node1 touching box */
     int touch1_n = 0, touch1_s = 0, touch1_e = 0, touch1_w = 0;	/* other vertices except node1 touching box */
     int touch2_n = 0, touch2_s = 0, touch2_e = 0, touch2_w = 0;	/* other vertices except node2 touching box */
     int touch2_n = 0, touch2_s = 0, touch2_e = 0, touch2_w = 0;	/* other vertices except node2 touching box */
@@ -84,7 +84,7 @@ Vect_break_lines_list(struct Map_info *Map, struct ilist *List_break,
     ACats = Vect_new_cats_struct();
     ACats = Vect_new_cats_struct();
     BCats = Vect_new_cats_struct();
     BCats = Vect_new_cats_struct();
     Cats = Vect_new_cats_struct();
     Cats = Vect_new_cats_struct();
-    List = Vect_new_list();
+    List = Vect_new_boxlist(1);
 
 
     is3d = Vect_is_3d(Map);
     is3d = Vect_is_3d(Map);
 
 
@@ -169,7 +169,7 @@ Vect_break_lines_list(struct Map_info *Map, struct ilist *List_break,
 	G_debug(3, "  %d lines selected by box", List->n_values);
 	G_debug(3, "  %d lines selected by box", List->n_values);
 
 
 	for (j = 0; j < List->n_values; j++) {
 	for (j = 0; j < List->n_values; j++) {
-	    bline = List->value[j];
+	    bline = List->id[j];
 	    if (List_break && !Vect_val_in_list(List_break, bline)) {
 	    if (List_break && !Vect_val_in_list(List_break, bline)) {
 		continue;
 		continue;
 	    }
 	    }
@@ -181,7 +181,7 @@ Vect_break_lines_list(struct Map_info *Map, struct ilist *List_break,
 	    if (!is3d) {
 	    if (!is3d) {
 		Vect_get_line_nodes(Map, aline, &anode1, &anode2);
 		Vect_get_line_nodes(Map, aline, &anode1, &anode2);
 		Vect_get_line_nodes(Map, bline, &bnode1, &bnode2);
 		Vect_get_line_nodes(Map, bline, &bnode1, &bnode2);
-		Vect_line_box(BPoints, &BBox);
+		BBox = List->box[j];
 
 
 		if (anode1 == bnode1 || anode1 == bnode2)
 		if (anode1 == bnode1 || anode1 == bnode2)
 		    node = anode1;
 		    node = anode1;
@@ -381,7 +381,7 @@ Vect_break_lines_list(struct Map_info *Map, struct ilist *List_break,
     Vect_destroy_cats_struct(ACats);
     Vect_destroy_cats_struct(ACats);
     Vect_destroy_cats_struct(BCats);
     Vect_destroy_cats_struct(BCats);
     Vect_destroy_cats_struct(Cats);
     Vect_destroy_cats_struct(Cats);
-    Vect_destroy_list(List);
+    Vect_destroy_boxlist(List);
 
 
     return nbreaks;
     return nbreaks;
 }
 }

+ 8 - 8
lib/vector/Vlib/build_nat.c

@@ -158,7 +158,7 @@ int Vect_isle_find_area(struct Map_info *Map, int isle)
     }
     }
 
 
     if (first_call) {
     if (first_call) {
-	List = Vect_new_boxlist();
+	List = Vect_new_boxlist(1);
 	APoints = Vect_new_line_struct();
 	APoints = Vect_new_line_struct();
 	first_call = 0;
 	first_call = 0;
     }
     }
@@ -176,7 +176,7 @@ int Vect_isle_find_area(struct Map_info *Map, int isle)
     box.S = Node->y;
     box.S = Node->y;
     box.T = PORT_DOUBLE_MAX;
     box.T = PORT_DOUBLE_MAX;
     box.B = -PORT_DOUBLE_MAX;
     box.B = -PORT_DOUBLE_MAX;
-    Vect_select_areas_by_box_with_box(Map, &box, List);
+    Vect_select_areas_by_box(Map, &box, List);
     G_debug(3, "%d areas overlap island boundary point", List->n_values);
     G_debug(3, "%d areas overlap island boundary point", List->n_values);
 
 
     sel_area = 0;
     sel_area = 0;
@@ -310,7 +310,7 @@ int Vect_attach_isles(struct Map_info *Map, const struct bound_box * box)
 {
 {
     int i, isle;
     int i, isle;
     static int first = 1;
     static int first = 1;
-    static struct ilist *List;
+    static struct boxlist *List;
     struct Plus_head *plus;
     struct Plus_head *plus;
 
 
     G_debug(3, "Vect_attach_isles ()");
     G_debug(3, "Vect_attach_isles ()");
@@ -318,7 +318,7 @@ int Vect_attach_isles(struct Map_info *Map, const struct bound_box * box)
     plus = &(Map->plus);
     plus = &(Map->plus);
 
 
     if (first) {
     if (first) {
-	List = Vect_new_list();
+	List = Vect_new_boxlist(0);
 	first = 0;
 	first = 0;
     }
     }
 
 
@@ -326,7 +326,7 @@ int Vect_attach_isles(struct Map_info *Map, const struct bound_box * box)
     G_debug(3, "  number of isles to attach = %d", List->n_values);
     G_debug(3, "  number of isles to attach = %d", List->n_values);
 
 
     for (i = 0; i < List->n_values; i++) {
     for (i = 0; i < List->n_values; i++) {
-	isle = List->value[i];
+	isle = List->id[i];
 	/* only attach isles that are not yet attached, see Vect_attach_isle() */
 	/* only attach isles that are not yet attached, see Vect_attach_isle() */
 	if (plus->Isle[isle]->area == 0)
 	if (plus->Isle[isle]->area == 0)
 	    Vect_attach_isle(Map, isle);
 	    Vect_attach_isle(Map, isle);
@@ -346,7 +346,7 @@ int Vect_attach_centroids(struct Map_info *Map, const struct bound_box * box)
 {
 {
     int i, sel_area, centr;
     int i, sel_area, centr;
     static int first = 1;
     static int first = 1;
-    static struct ilist *List;
+    static struct boxlist *List;
     static struct line_pnts *Points;
     static struct line_pnts *Points;
     struct P_area *Area;
     struct P_area *Area;
     struct P_line *Line;
     struct P_line *Line;
@@ -358,7 +358,7 @@ int Vect_attach_centroids(struct Map_info *Map, const struct bound_box * box)
     plus = &(Map->plus);
     plus = &(Map->plus);
 
 
     if (first) {
     if (first) {
-	List = Vect_new_list();
+	List = Vect_new_boxlist(0);
 	Points = Vect_new_line_struct();
 	Points = Vect_new_line_struct();
 	first = 0;
 	first = 0;
     }
     }
@@ -394,7 +394,7 @@ int Vect_attach_centroids(struct Map_info *Map, const struct bound_box * box)
     for (i = 0; i < List->n_values; i++) {
     for (i = 0; i < List->n_values; i++) {
 	int orig_area;
 	int orig_area;
 
 
-	centr = List->value[i];
+	centr = List->id[i];
 	Line = plus->Line[centr];
 	Line = plus->Line[centr];
 	topo = (struct P_topo_c *)Line->topo;
 	topo = (struct P_topo_c *)Line->topo;
 
 

+ 8 - 8
lib/vector/Vlib/find.c

@@ -174,7 +174,7 @@ Vect_find_line_list(struct Map_info *map,
     static int first_time = 1;
     static int first_time = 1;
     const struct Plus_head *Plus;
     const struct Plus_head *Plus;
     struct bound_box box;
     struct bound_box box;
-    struct ilist *List;
+    struct boxlist *List;
 
 
     G_debug(3, "Vect_find_line_list() for %f %f %f type = %d maxdist = %f",
     G_debug(3, "Vect_find_line_list() for %f %f %f type = %d maxdist = %f",
 	    ux, uy, uz, type, maxdist);
 	    ux, uy, uz, type, maxdist);
@@ -202,14 +202,14 @@ Vect_find_line_list(struct Map_info *map,
 	box.B = -PORT_DOUBLE_MAX;
 	box.B = -PORT_DOUBLE_MAX;
     }
     }
 
 
-    List = Vect_new_list();
+    List = Vect_new_boxlist(0);
 
 
     if (found)
     if (found)
 	Vect_reset_list(found);
 	Vect_reset_list(found);
 
 
     Vect_select_lines_by_box(map, &box, type, List);
     Vect_select_lines_by_box(map, &box, type, List);
     for (i = 0; i < List->n_values; i++) {
     for (i = 0; i < List->n_values; i++) {
-	line = List->value[i];
+	line = List->id[i];
 	if (Vect_val_in_list(exclude, line)) {
 	if (Vect_val_in_list(exclude, line)) {
 	    G_debug(3, " line = %d exclude", line);
 	    G_debug(3, " line = %d exclude", line);
 	    continue;
 	    continue;
@@ -248,7 +248,7 @@ Vect_find_line_list(struct Map_info *map,
     if (cur_dist > maxdist)
     if (cur_dist > maxdist)
 	choice = 0;
 	choice = 0;
 
 
-    Vect_destroy_list(List);
+    Vect_destroy_boxlist(List);
 
 
     return (choice);
     return (choice);
 }
 }
@@ -274,7 +274,7 @@ int Vect_find_area(struct Map_info *Map, double x, double y)
     G_debug(3, "Vect_find_area() x = %f y = %f", x, y);
     G_debug(3, "Vect_find_area() x = %f y = %f", x, y);
 
 
     if (first) {
     if (first) {
-	List = Vect_new_boxlist();
+	List = Vect_new_boxlist(1);
 	first = 0;
 	first = 0;
 	alloc_size_list = 10;
 	alloc_size_list = 10;
 	size_list = G_malloc(alloc_size_list * sizeof(BOX_SIZE));
 	size_list = G_malloc(alloc_size_list * sizeof(BOX_SIZE));
@@ -287,7 +287,7 @@ int Vect_find_area(struct Map_info *Map, double x, double y)
     box.S = y;
     box.S = y;
     box.T = PORT_DOUBLE_MAX;
     box.T = PORT_DOUBLE_MAX;
     box.B = -PORT_DOUBLE_MAX;
     box.B = -PORT_DOUBLE_MAX;
-    Vect_select_areas_by_box_with_box(Map, &box, List);
+    Vect_select_areas_by_box(Map, &box, List);
     G_debug(3, "  %d areas selected by box", List->n_values);
     G_debug(3, "  %d areas selected by box", List->n_values);
 
 
     /* sort areas by size, the smallest is likely to be the nearest */
     /* sort areas by size, the smallest is likely to be the nearest */
@@ -345,7 +345,7 @@ int Vect_find_island(struct Map_info *Map, double x, double y)
     G_debug(3, "Vect_find_island() x = %f y = %f", x, y);
     G_debug(3, "Vect_find_island() x = %f y = %f", x, y);
 
 
     if (first) {
     if (first) {
-	List = Vect_new_boxlist();
+	List = Vect_new_boxlist(1);
 	Points = Vect_new_line_struct();
 	Points = Vect_new_line_struct();
 	first = 0;
 	first = 0;
     }
     }
@@ -357,7 +357,7 @@ int Vect_find_island(struct Map_info *Map, double x, double y)
     box.S = y;
     box.S = y;
     box.T = PORT_DOUBLE_MAX;
     box.T = PORT_DOUBLE_MAX;
     box.B = -PORT_DOUBLE_MAX;
     box.B = -PORT_DOUBLE_MAX;
-    Vect_select_isles_by_box_with_box(Map, &box, List);
+    Vect_select_isles_by_box(Map, &box, List);
     G_debug(3, "  %d islands selected by box", List->n_values);
     G_debug(3, "  %d islands selected by box", List->n_values);
 
 
     current_size = -1;
     current_size = -1;

+ 23 - 8
lib/vector/Vlib/list.c

@@ -219,7 +219,7 @@ int Vect_val_in_list(const struct ilist *list, int val)
  * \return pointer to struct boxlist
  * \return pointer to struct boxlist
  * \return NULL on error
  * \return NULL on error
  */
  */
-struct boxlist *Vect_new_boxlist(void)
+struct boxlist *Vect_new_boxlist(int have_boxes)
 {
 {
     struct boxlist *p;
     struct boxlist *p;
 
 
@@ -228,6 +228,7 @@ struct boxlist *Vect_new_boxlist(void)
     if (p) {
     if (p) {
 	p->id = NULL;
 	p->id = NULL;
 	p->box = NULL;
 	p->box = NULL;
+	p->have_boxes = have_boxes != 0;
 	p->n_values = 0;
 	p->n_values = 0;
 	p->alloc_values = 0;
 	p->alloc_values = 0;
     }
     }
@@ -263,7 +264,8 @@ void Vect_destroy_boxlist(struct boxlist *list)
     if (list) {			/* probably a moot test */
     if (list) {			/* probably a moot test */
 	if (list->alloc_values) {
 	if (list->alloc_values) {
 	    G_free((void *)list->id);
 	    G_free((void *)list->id);
-	    G_free((void *)list->box);
+	    if (list->box)
+		G_free((void *)list->box);
 	}
 	}
 	G_free((void *)list);
 	G_free((void *)list);
     }
     }
@@ -296,14 +298,17 @@ int Vect_boxlist_append(struct boxlist *list, int id, struct bound_box box)
 	size = (list->n_values + 1000) * sizeof(int);
 	size = (list->n_values + 1000) * sizeof(int);
 	list->id = (int *)G_realloc((void *)list->id, size);
 	list->id = (int *)G_realloc((void *)list->id, size);
 
 
-	size = (list->n_values + 1000) * sizeof(struct bound_box);
-	list->box = (struct bound_box *)G_realloc((void *)list->box, size);
+	if (list->have_boxes) {
+	    size = (list->n_values + 1000) * sizeof(struct bound_box);
+	    list->box = (struct bound_box *)G_realloc((void *)list->box, size);
+	}
 
 
 	list->alloc_values = list->n_values + 1000;
 	list->alloc_values = list->n_values + 1000;
     }
     }
 
 
     list->id[list->n_values] = id;
     list->id[list->n_values] = id;
-    list->box[list->n_values] = box;
+    if (list->have_boxes)
+	list->box[list->n_values] = box;
     list->n_values++;
     list->n_values++;
 
 
     return 0;
     return 0;
@@ -325,8 +330,17 @@ int Vect_boxlist_append_boxlist(struct boxlist *alist, const struct boxlist *bli
     if (alist == NULL || blist == NULL)
     if (alist == NULL || blist == NULL)
 	return 1;
 	return 1;
 
 
-    for (i = 0; i < blist->n_values; i++)
-	Vect_boxlist_append(alist, blist->id[i], blist->box[i]);
+    if (blist->have_boxes) {
+	for (i = 0; i < blist->n_values; i++)
+	    Vect_boxlist_append(alist, blist->id[i], blist->box[i]);
+    }
+    else {
+	struct bound_box box;
+
+	box.E = box.N = box.N = box.S = box.T = box.B = 0;
+	for (i = 0; i < blist->n_values; i++)
+	    Vect_boxlist_append(alist, blist->id[i], box);
+    }
 
 
     return 0;
     return 0;
 }
 }
@@ -351,7 +365,8 @@ int Vect_boxlist_delete(struct boxlist *list, int id)
 	if (id == list->id[i]) {
 	if (id == list->id[i]) {
 	    for (j = i + 1; j < list->n_values; j++) {
 	    for (j = i + 1; j < list->n_values; j++) {
 		list->id[j - 1] = list->id[j];
 		list->id[j - 1] = list->id[j];
-		list->box[j - 1] = list->box[j];
+		if (list->have_boxes)
+		    list->box[j - 1] = list->box[j];
 	    }
 	    }
 
 
 	    list->n_values--;
 	    list->n_values--;

+ 2 - 2
lib/vector/Vlib/read_ogr.c

@@ -473,8 +473,8 @@ int V2_read_line_ogr(struct Map_info *Map, struct line_pnts *line_p,
 	    /* get area bbox */
 	    /* get area bbox */
 	    Vect_get_area_box(Map, topo->area, &box);
 	    Vect_get_area_box(Map, topo->area, &box);
 	    /* search in spatial index for centroid with area bbox */
 	    /* search in spatial index for centroid with area bbox */
-	    dig_init_boxlist(&list);
-	    Vect_select_lines_by_box_with_box(Map, &box, Line->type, &list);
+	    dig_init_boxlist(&list, 1);
+	    Vect_select_lines_by_box(Map, &box, Line->type, &list);
 	    
 	    
 	    found = 0;
 	    found = 0;
 	    for (i = 0; i < list.n_values; i++) {
 	    for (i = 0; i < list.n_values; i++) {

+ 3 - 3
lib/vector/Vlib/remove_duplicates.c

@@ -39,7 +39,7 @@ Vect_remove_duplicates(struct Map_info *Map, int type, struct Map_info *Err)
     int i, j, c, atype, btype, bline;
     int i, j, c, atype, btype, bline;
     int nlines, nbcats_orig;
     int nlines, nbcats_orig;
     struct bound_box ABox;
     struct bound_box ABox;
-    struct ilist *List;
+    struct boxlist *List;
     int ndupl;
     int ndupl;
 
 
 
 
@@ -48,7 +48,7 @@ Vect_remove_duplicates(struct Map_info *Map, int type, struct Map_info *Err)
     ACats = Vect_new_cats_struct();
     ACats = Vect_new_cats_struct();
     BCats = Vect_new_cats_struct();
     BCats = Vect_new_cats_struct();
     Cats = Vect_new_cats_struct();
     Cats = Vect_new_cats_struct();
-    List = Vect_new_list();
+    List = Vect_new_boxlist(0);
 
 
     nlines = Vect_get_num_lines(Map);
     nlines = Vect_get_num_lines(Map);
 
 
@@ -74,7 +74,7 @@ Vect_remove_duplicates(struct Map_info *Map, int type, struct Map_info *Err)
 	G_debug(3, "  %d lines selected by box", List->n_values);
 	G_debug(3, "  %d lines selected by box", List->n_values);
 
 
 	for (j = 0; j < List->n_values; j++) {
 	for (j = 0; j < List->n_values; j++) {
-	    bline = List->value[j];
+	    bline = List->id[j];
 	    G_debug(3, "  j = %d bline = %d", j, bline);
 	    G_debug(3, "  j = %d bline = %d", j, bline);
 	    if (i == bline)
 	    if (i == bline)
 		continue;
 		continue;

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

@@ -16,60 +16,6 @@
 #include <stdlib.h>
 #include <stdlib.h>
 #include <grass/vector.h>
 #include <grass/vector.h>
 
 
-/*!
-   \brief Select lines by box.
-
-   Select lines whose boxes overlap specified box!!!  It means that
-   selected line may or may not overlap the box.
-
-   \param Map vector map
-   \param Box bounding box
-   \param type line type
-   \param[out] list output list, must be initialized
-
-   \return number of lines
- */
-int
-Vect_select_lines_by_box(struct Map_info *Map, const struct bound_box * Box,
-			 int type, struct ilist *list)
-{
-    int i, line, nlines;
-    struct Plus_head *plus;
-    struct P_line *Line;
-    static struct ilist *LocList = NULL;
-
-    G_debug(3, "Vect_select_lines_by_box()");
-    G_debug(3, "  Box(N,S,E,W,T,B): %e, %e, %e, %e, %e, %e", Box->N, Box->S,
-	    Box->E, Box->W, Box->T, Box->B);
-    plus = &(Map->plus);
-
-    if (!(plus->Spidx_built)) {
-	G_debug(3, "Building spatial index.");
-	Vect_build_sidx_from_topo(Map);
-    }
-
-    list->n_values = 0;
-    if (!LocList)
-	LocList = Vect_new_list();
-
-    nlines = dig_select_lines(plus, Box, LocList);
-    G_debug(3, "  %d lines selected (all types)", nlines);
-
-    /* Remove lines of not requested types */
-    for (i = 0; i < nlines; i++) {
-	line = LocList->value[i];
-	if (plus->Line[line] == NULL)
-	    continue;		/* Should not happen */
-	Line = plus->Line[line];
-	if (!(Line->type & type))
-	    continue;
-	dig_list_add(list, line);
-    }
-
-    G_debug(3, "  %d lines of requested type", list->n_values);
-
-    return list->n_values;
-}
 
 
 /*!
 /*!
    \brief Select lines with bounding boxes by box.
    \brief Select lines with bounding boxes by box.
@@ -85,7 +31,7 @@ Vect_select_lines_by_box(struct Map_info *Map, const struct bound_box * Box,
    \return number of lines
    \return number of lines
  */
  */
 int
 int
-Vect_select_lines_by_box_with_box(struct Map_info *Map, const struct bound_box *Box,
+Vect_select_lines_by_box(struct Map_info *Map, const struct bound_box *Box,
 			 int type, struct boxlist *list)
 			 int type, struct boxlist *list)
 {
 {
     int i, line, nlines;
     int i, line, nlines;
@@ -98,18 +44,13 @@ Vect_select_lines_by_box_with_box(struct Map_info *Map, const struct bound_box *
 	    Box->E, Box->W, Box->T, Box->B);
 	    Box->E, Box->W, Box->T, Box->B);
     plus = &(Map->plus);
     plus = &(Map->plus);
 
 
-    if (!(plus->Spidx_built)) {
-	G_debug(3, "Building spatial index.");
-	Vect_build_sidx_from_topo(Map);
-    }
-
     list->n_values = 0;
     list->n_values = 0;
     if (!LocList) {
     if (!LocList) {
 	LocList = (struct boxlist *)G_malloc(sizeof(struct boxlist));
 	LocList = (struct boxlist *)G_malloc(sizeof(struct boxlist));
-	dig_init_boxlist(LocList);
+	dig_init_boxlist(LocList, 1);
     }
     }
 
 
-    nlines = dig_select_lines_with_box(plus, Box, LocList);
+    nlines = dig_select_lines(plus, Box, LocList);
     G_debug(3, "  %d lines selected (all types)", nlines);
     G_debug(3, "  %d lines selected (all types)", nlines);
 
 
     /* Remove lines of not requested types */
     /* Remove lines of not requested types */
@@ -128,57 +69,6 @@ Vect_select_lines_by_box_with_box(struct Map_info *Map, const struct bound_box *
     return list->n_values;
     return list->n_values;
 }
 }
 
 
-/*!
-   \brief Select areas by box.
-
-   Select areas whose boxes overlap specified box!!!
-   It means that selected area may or may not overlap the box.
-
-   \param Map vector map
-   \param Box bounding box
-   \param[out] output list, must be initialized
-
-   \return number of areas
- */
-int
-Vect_select_areas_by_box(struct Map_info *Map, const struct bound_box * Box,
-			 struct ilist *list)
-{
-    int i;
-    static int debug_level = -1;
-
-    if (debug_level == -1) {
-	const char *dstr = G__getenv("DEBUG");
-
-	if (dstr != NULL)
-	    debug_level = atoi(dstr);
-	else
-	    debug_level = 0;
-    }
-
-    G_debug(3, "Vect_select_areas_by_box()");
-    G_debug(3, "Box(N,S,E,W,T,B): %e, %e, %e, %e, %e, %e", Box->N, Box->S,
-	    Box->E, Box->W, Box->T, Box->B);
-
-    if (!(Map->plus.Spidx_built)) {
-	G_debug(3, "Building spatial index.");
-	Vect_build_sidx_from_topo(Map);
-    }
-
-    dig_select_areas(&(Map->plus), Box, list);
-    G_debug(3, "  %d areas selected", list->n_values);
-    /* avoid loop when not debugging */
-    if (debug_level > 2) {
-	for (i = 0; i < list->n_values; i++) {
-	    G_debug(3, "  area = %d pointer to area structure = %lx",
-		    list->value[i],
-		    (unsigned long)Map->plus.Area[list->value[i]]);
-	}
-    }
-
-    return list->n_values;
-}
-
 
 
 /*!
 /*!
    \brief Select areas with bounding boxes by box.
    \brief Select areas with bounding boxes by box.
@@ -193,7 +83,7 @@ Vect_select_areas_by_box(struct Map_info *Map, const struct bound_box * Box,
    \return number of areas
    \return number of areas
  */
  */
 int
 int
-Vect_select_areas_by_box_with_box(struct Map_info *Map, const struct bound_box * Box,
+Vect_select_areas_by_box(struct Map_info *Map, const struct bound_box * Box,
 			 struct boxlist *list)
 			 struct boxlist *list)
 {
 {
     int i;
     int i;
@@ -212,7 +102,7 @@ Vect_select_areas_by_box_with_box(struct Map_info *Map, const struct bound_box *
     G_debug(3, "Box(N,S,E,W,T,B): %e, %e, %e, %e, %e, %e", Box->N, Box->S,
     G_debug(3, "Box(N,S,E,W,T,B): %e, %e, %e, %e, %e, %e", Box->N, Box->S,
 	    Box->E, Box->W, Box->T, Box->B);
 	    Box->E, Box->W, Box->T, Box->B);
 
 
-    dig_select_areas_with_box(&(Map->plus), Box, list);
+    dig_select_areas(&(Map->plus), Box, list);
     G_debug(3, "  %d areas selected", list->n_values);
     G_debug(3, "  %d areas selected", list->n_values);
     /* avoid loop when not debugging */
     /* avoid loop when not debugging */
     if (debug_level > 2) {
     if (debug_level > 2) {
@@ -228,7 +118,7 @@ Vect_select_areas_by_box_with_box(struct Map_info *Map, const struct bound_box *
 
 
 
 
 /*!
 /*!
-   \brief Select isles by box.
+   \brief Select isles with bounding boxes by box.
 
 
    Select isles whose boxes overlap specified box!!!
    Select isles whose boxes overlap specified box!!!
    It means that selected isle may or may not overlap the box.
    It means that selected isle may or may not overlap the box.
@@ -241,17 +131,12 @@ Vect_select_areas_by_box_with_box(struct Map_info *Map, const struct bound_box *
  */
  */
 int
 int
 Vect_select_isles_by_box(struct Map_info *Map, const struct bound_box * Box,
 Vect_select_isles_by_box(struct Map_info *Map, const struct bound_box * Box,
-			 struct ilist *list)
+			 struct boxlist *list)
 {
 {
     G_debug(3, "Vect_select_isles_by_box()");
     G_debug(3, "Vect_select_isles_by_box()");
     G_debug(3, "Box(N,S,E,W,T,B): %e, %e, %e, %e, %e, %e", Box->N, Box->S,
     G_debug(3, "Box(N,S,E,W,T,B): %e, %e, %e, %e, %e, %e", Box->N, Box->S,
 	    Box->E, Box->W, Box->T, Box->B);
 	    Box->E, Box->W, Box->T, Box->B);
 
 
-    if (!(Map->plus.Spidx_built)) {
-	G_debug(3, "Building spatial index.");
-	Vect_build_sidx_from_topo(Map);
-    }
-
     dig_select_isles(&(Map->plus), Box, list);
     dig_select_isles(&(Map->plus), Box, list);
     G_debug(3, "  %d isles selected", list->n_values);
     G_debug(3, "  %d isles selected", list->n_values);
 
 
@@ -259,32 +144,6 @@ Vect_select_isles_by_box(struct Map_info *Map, const struct bound_box * Box,
 }
 }
 
 
 /*!
 /*!
-   \brief Select isles with bounding boxes by box.
-
-   Select isles whose boxes overlap specified box!!!
-   It means that selected isle may or may not overlap the box.
-
-   \param Map vector map
-   \param Box bounding box
-   \param[out] list output list, must be initialized
-
-   \return number of isles
- */
-int
-Vect_select_isles_by_box_with_box(struct Map_info *Map, const struct bound_box * Box,
-			 struct boxlist *list)
-{
-    G_debug(3, "Vect_select_isles_by_box_with_box()");
-    G_debug(3, "Box(N,S,E,W,T,B): %e, %e, %e, %e, %e, %e", Box->N, Box->S,
-	    Box->E, Box->W, Box->T, Box->B);
-
-    dig_select_isles_with_box(&(Map->plus), Box, list);
-    G_debug(3, "  %d isles selected", list->n_values);
-
-    return list->n_values;
-}
-
-/*!
    \brief Select nodes by box.
    \brief Select nodes by box.
 
 
    \param Map vector map
    \param Map vector map
@@ -305,11 +164,6 @@ Vect_select_nodes_by_box(struct Map_info *Map, const struct bound_box * Box,
 
 
     plus = &(Map->plus);
     plus = &(Map->plus);
 
 
-    if (!(plus->Spidx_built)) {
-	G_debug(3, "Building spatial index.");
-	Vect_build_sidx_from_topo(Map);
-    }
-
     list->n_values = 0;
     list->n_values = 0;
 
 
     dig_select_nodes(plus, Box, list);
     dig_select_nodes(plus, Box, list);
@@ -340,7 +194,7 @@ Vect_select_lines_by_polygon(struct Map_info *Map, struct line_pnts *Polygon,
     int i;
     int i;
     struct bound_box box;
     struct bound_box box;
     static struct line_pnts *LPoints = NULL;
     static struct line_pnts *LPoints = NULL;
-    static struct ilist *LocList = NULL;
+    static struct boxlist *LocList = NULL;
 
 
     /* TODO: this function was not tested with isles */
     /* TODO: this function was not tested with isles */
     G_debug(3, "Vect_select_lines_by_polygon() nisles = %d", nisles);
     G_debug(3, "Vect_select_lines_by_polygon() nisles = %d", nisles);
@@ -348,8 +202,9 @@ Vect_select_lines_by_polygon(struct Map_info *Map, struct line_pnts *Polygon,
     List->n_values = 0;
     List->n_values = 0;
     if (!LPoints)
     if (!LPoints)
 	LPoints = Vect_new_line_struct();
 	LPoints = Vect_new_line_struct();
-    if (!LocList)
-	LocList = Vect_new_list();
+    if (!LocList) {
+	LocList = Vect_new_boxlist(0);
+    }
 
 
     /* Select first all lines by box */
     /* Select first all lines by box */
     dig_line_box(Polygon, &box);
     dig_line_box(Polygon, &box);
@@ -362,7 +217,7 @@ Vect_select_lines_by_polygon(struct Map_info *Map, struct line_pnts *Polygon,
     for (i = 0; i < LocList->n_values; i++) {
     for (i = 0; i < LocList->n_values; i++) {
 	int j, line, intersect = 0;
 	int j, line, intersect = 0;
 
 
-	line = LocList->value[i];
+	line = LocList->id[i];
 	/* Read line points */
 	/* Read line points */
 	Vect_read_line(Map, LPoints, NULL, line);
 	Vect_read_line(Map, LPoints, NULL, line);