[GRASS-SVN] r46955 - grass/trunk/lib/vector/diglib
svn_grass at osgeo.org
svn_grass at osgeo.org
Mon Jul 4 06:46:44 EDT 2011
Author: mmetz
Date: 2011-07-04 03:46:44 -0700 (Mon, 04 Jul 2011)
New Revision: 46955
Modified:
grass/trunk/lib/vector/diglib/list.c
grass/trunk/lib/vector/diglib/spindex.c
Log:
remove redundant code in vector lib: update diglib
Modified: grass/trunk/lib/vector/diglib/list.c
===================================================================
--- grass/trunk/lib/vector/diglib/list.c 2011-07-04 10:11:58 UTC (rev 46954)
+++ grass/trunk/lib/vector/diglib/list.c 2011-07-04 10:46:44 UTC (rev 46955)
@@ -29,10 +29,11 @@
}
/* Init box list */
-int dig_init_boxlist(struct boxlist *list)
+int dig_init_boxlist(struct boxlist *list, int have_boxes)
{
list->id = NULL;
list->box = NULL;
+ list->have_boxes = have_boxes != 0;
list->n_values = 0;
list->alloc_values = 0;
@@ -69,18 +70,21 @@
return 0;
list->id = (int *)p;
- size = (list->n_values + 1000) * sizeof(struct bound_box);
- p = G_realloc((void *)list->box, size);
+ if (list->have_boxes) {
+ size = (list->n_values + 1000) * sizeof(struct bound_box);
+ p = G_realloc((void *)list->box, size);
- if (p == NULL)
- return 0;
- list->box = (int *)p;
+ if (p == NULL)
+ return 0;
+ list->box = (int *)p;
+ }
list->alloc_values = list->n_values + 1000;
}
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++;
return 1;
Modified: grass/trunk/lib/vector/diglib/spindex.c
===================================================================
--- grass/trunk/lib/vector/diglib/spindex.c 2011-07-04 10:11:58 UTC (rev 46954)
+++ grass/trunk/lib/vector/diglib/spindex.c 2011-07-04 10:46:44 UTC (rev 46955)
@@ -626,40 +626,6 @@
}
/*!
- \brief Select lines by box
-
- \param Plus pointer to Plus_head structure
- \param box bounding box
- \param list list of selected lines
-
- \return number of selected lines
- */
-int
-dig_select_lines(struct Plus_head *Plus, const struct bound_box * box,
- struct ilist *list)
-{
- struct RTree_Rect rect;
-
- G_debug(3, "dig_select_lines()");
-
- list->n_values = 0;
-
- rect.boundary[0] = box->W;
- rect.boundary[1] = box->S;
- rect.boundary[2] = box->B;
- rect.boundary[3] = box->E;
- rect.boundary[4] = box->N;
- rect.boundary[5] = box->T;
-
- if (Plus->Spidx_new)
- RTreeSearch(Plus->Line_spidx, &rect, (void *)_add_item, list);
- else
- rtree_search(Plus->Line_spidx, &rect, (void *)_add_item, list, Plus);
-
- return (list->n_values);
-}
-
-/*!
\brief Select lines with boxes by box
\param Plus pointer to Plus_head structure
@@ -669,7 +635,7 @@
\return number of selected lines
\return 0 not found
*/
-int dig_select_lines_with_box(struct Plus_head *Plus, const struct bound_box *box,
+int dig_select_lines(struct Plus_head *Plus, const struct bound_box *box,
struct boxlist *list)
{
struct RTree_Rect rect;
@@ -728,40 +694,6 @@
}
/*!
- \brief Select areas by box
-
- \param Plus pointer to Plus_head structure
- \param box bounding box
- \param list list of selected lines
-
- \return number of selected areas
- */
-int
-dig_select_areas(struct Plus_head *Plus, const struct bound_box * box,
- struct ilist *list)
-{
- struct RTree_Rect rect;
-
- G_debug(3, "dig_select_areas()");
-
- list->n_values = 0;
-
- rect.boundary[0] = box->W;
- rect.boundary[1] = box->S;
- rect.boundary[2] = box->B;
- rect.boundary[3] = box->E;
- rect.boundary[4] = box->N;
- rect.boundary[5] = box->T;
-
- if (Plus->Spidx_new)
- RTreeSearch(Plus->Area_spidx, &rect, (void *)_add_item, list);
- else
- rtree_search(Plus->Area_spidx, &rect, (void *)_add_item, list, Plus);
-
- return (list->n_values);
-}
-
-/*!
\brief Select areas with boxes by box
\param Plus pointer to Plus_head structure
@@ -771,7 +703,7 @@
\return number of selected areas
*/
int
-dig_select_areas_with_box(struct Plus_head *Plus, const struct bound_box * box,
+dig_select_areas(struct Plus_head *Plus, const struct bound_box * box,
struct boxlist *list)
{
struct RTree_Rect rect;
@@ -829,40 +761,6 @@
return (ret);
}
-/*!
- \brief Select isles by box
-
- \param Plus pointer to Plus_head structure
- \param box bounding box
- \param list list of selected lines
-
- \return number of selected isles
- */
-int
-dig_select_isles(struct Plus_head *Plus, const struct bound_box * box,
- struct ilist *list)
-{
- struct RTree_Rect rect;
-
- G_debug(3, "dig_select_isles()");
-
- list->n_values = 0;
-
- rect.boundary[0] = box->W;
- rect.boundary[1] = box->S;
- rect.boundary[2] = box->B;
- rect.boundary[3] = box->E;
- rect.boundary[4] = box->N;
- rect.boundary[5] = box->T;
-
- if (Plus->Spidx_new)
- RTreeSearch(Plus->Isle_spidx, &rect, (void *)_add_item, list);
- else
- rtree_search(Plus->Isle_spidx, &rect, (void *)_add_item, list, Plus);
-
- return (list->n_values);
-}
-
/*!
\brief Select isles with boxes by box
@@ -873,7 +771,7 @@
\return number of selected isles
*/
int
-dig_select_isles_with_box(struct Plus_head *Plus, const struct bound_box * box,
+dig_select_isles(struct Plus_head *Plus, const struct bound_box * box,
struct boxlist *list)
{
struct RTree_Rect rect;
More information about the grass-commit
mailing list