Browse Source

adjust Vlib to changed rtree

git-svn-id: https://svn.osgeo.org/grass/grass/trunk@51801 15284696-431f-4ddb-bdfa-cd5b030d7da7
Markus Metz 13 years ago
parent
commit
27ea6f3600
1 changed files with 21 additions and 3 deletions
  1. 21 3
      lib/vector/Vlib/select.c

+ 21 - 3
lib/vector/Vlib/select.c

@@ -62,7 +62,13 @@ void Vect_spatial_index_destroy(struct spatial_index * si)
 void Vect_spatial_index_add_item(struct spatial_index * si, int id,
 				 const struct bound_box * box)
 {
-    struct RTree_Rect rect;
+    static struct RTree_Rect rect;
+    static int rect_init = 0;
+
+    if (!rect_init) {
+	rect.boundary = G_malloc(si->si_tree->nsides_alloc * sizeof(RectReal));
+	rect_init = si->si_tree->nsides_alloc;
+    }
 
     G_debug(3, "Vect_spatial_index_add_item(): id = %d", id);
 
@@ -87,7 +93,13 @@ void Vect_spatial_index_del_item(struct spatial_index * si, int id,
 				 const struct bound_box * box)
 {
     int ret;
-    struct RTree_Rect rect;
+    static struct RTree_Rect rect;
+    static int rect_init = 0;
+
+    if (!rect_init) {
+	rect.boundary = G_malloc(si->si_tree->nsides_alloc * sizeof(RectReal));
+	rect_init = si->si_tree->nsides_alloc;
+    }
 
     G_debug(3, "Vect_spatial_index_del_item(): id = %d", id);
 
@@ -125,7 +137,13 @@ int
 Vect_spatial_index_select(const struct spatial_index * si, const struct bound_box * box,
 			  struct ilist *list)
 {
-    struct RTree_Rect rect;
+    static struct RTree_Rect rect;
+    static int rect_init = 0;
+
+    if (!rect_init) {
+	rect.boundary = G_malloc(si->si_tree->nsides_alloc * sizeof(RectReal));
+	rect_init = si->si_tree->nsides_alloc;
+    }
 
     G_debug(3, "Vect_spatial_index_select()");