[GRASS-SVN] r46959 - in grass/trunk/vector: v.clean v.distance
v.edit v.generalize v.kernel v.neighbors v.net.steiner v.select
svn_grass at osgeo.org
svn_grass at osgeo.org
Mon Jul 4 06:49:36 EDT 2011
Author: mmetz
Date: 2011-07-04 03:49:36 -0700 (Mon, 04 Jul 2011)
New Revision: 46959
Modified:
grass/trunk/vector/v.clean/prune.c
grass/trunk/vector/v.distance/main.c
grass/trunk/vector/v.edit/select.c
grass/trunk/vector/v.generalize/misc.c
grass/trunk/vector/v.kernel/main.c
grass/trunk/vector/v.neighbors/main.c
grass/trunk/vector/v.net.steiner/main.c
grass/trunk/vector/v.select/main.c
Log:
remove redundant code in vector lib: update modules
Modified: grass/trunk/vector/v.clean/prune.c
===================================================================
--- grass/trunk/vector/v.clean/prune.c 2011-07-04 10:48:20 UTC (rev 46958)
+++ grass/trunk/vector/v.clean/prune.c 2011-07-04 10:49:36 UTC (rev 46959)
@@ -42,14 +42,14 @@
struct line_pnts *Points, *TPoints, *BPoints, *Points_orig;
struct line_cats *Cats;
struct bound_box box;
- struct ilist *List;
+ struct boxlist *List;
Points = Vect_new_line_struct();
Points_orig = Vect_new_line_struct();
TPoints = Vect_new_line_struct();
BPoints = Vect_new_line_struct();
Cats = Vect_new_cats_struct();
- List = Vect_new_list();
+ List = Vect_new_boxlist(0);
nlines = Vect_get_num_lines(Out);
@@ -122,7 +122,7 @@
struct line_pnts **AXLines, **BXLines;
int naxlines, nbxlines;
- bline = List->value[i];
+ bline = List->id[i];
if (bline == line)
continue;
@@ -131,6 +131,7 @@
/* Vect_line_intersection is quite slow, hopefully not so bad because only few
* intersections should be found if any */
+ AXLines = BXLines = NULL;
Vect_line_intersection(TPoints, BPoints, &AXLines, &BXLines,
&naxlines, &nbxlines, 0);
@@ -143,14 +144,16 @@
for (j = 0; j < naxlines; j++) {
Vect_destroy_line_struct(AXLines[j]);
}
+ }
+ if (AXLines)
G_free(AXLines);
- }
if (nbxlines > 0) {
for (j = 0; j < nbxlines; j++) {
Vect_destroy_line_struct(BXLines[j]);
}
+ }
+ if (BXLines)
G_free(BXLines);
- }
if (naxlines > 1 || nbxlines > 1) {
intersect = 1;
@@ -221,7 +224,7 @@
Vect_destroy_line_struct(TPoints);
Vect_destroy_line_struct(BPoints);
Vect_destroy_cats_struct(Cats);
- Vect_destroy_list(List);
+ Vect_destroy_boxlist(List);
return 1;
}
Modified: grass/trunk/vector/v.distance/main.c
===================================================================
--- grass/trunk/vector/v.distance/main.c 2011-07-04 10:48:20 UTC (rev 46958)
+++ grass/trunk/vector/v.distance/main.c 2011-07-04 10:49:36 UTC (rev 46959)
@@ -103,7 +103,7 @@
char buf1[2000], buf2[2000];
int update_ok, update_err, update_exist, update_notexist, update_dupl,
update_notfound;
- struct ilist *List;
+ struct boxlist *List;
struct bound_box box;
dbCatValArray cvarr;
dbColumn *column;
@@ -504,7 +504,7 @@
TPoints = Vect_new_line_struct();
FCats = Vect_new_cats_struct();
TCats = Vect_new_cats_struct();
- List = Vect_new_list();
+ List = Vect_new_boxlist(0);
/* Allocate space ( may be more than needed (duplicate cats and elements without cats) ) */
nfrom = Vect_get_num_lines(&From);
@@ -595,7 +595,7 @@
/* the objective is to enlarge the search box
* in the first iterations just a little bit
* to keep the number of hits low */
- Vect_reset_list(List);
+ Vect_reset_boxlist(List);
while (curr_step < n_max_steps) {
box_edge = max_step[curr_step];
@@ -633,7 +633,7 @@
dist = PORT_DOUBLE_MAX;
for (i = 0; i < List->n_values; i++) {
tmp_tcat = -1;
- Vect_read_line(&To, TPoints, TCats, List->value[i]);
+ Vect_read_line(&To, TPoints, TCats, List->id[i]);
tseg =
Vect_line_distance(TPoints, FPoints->x[0], FPoints->y[0],
@@ -692,7 +692,7 @@
}
else {
if (tline == 0 || (tmp_dist < dist)) {
- tline = List->value[i];
+ tline = List->id[i];
tcat = tmp_tcat;
dist = tmp_dist;
tx = tmp_tx;
@@ -777,7 +777,7 @@
/* the objective is to enlarge the search box
* in the first iterations just a little bit
* to keep the number of hits low */
- Vect_reset_list(List);
+ Vect_reset_boxlist(List);
while (curr_step < n_max_steps) {
box_edge = max_step[curr_step];
@@ -817,7 +817,7 @@
for (i = 0; i < List->n_values; i++) {
int tmp_tcat;
- area = List->value[i];
+ area = List->id[i];
G_debug(4, "%d: area %d", i, area);
Vect_get_area_points(&To, area, TPoints);
Modified: grass/trunk/vector/v.edit/select.c
===================================================================
--- grass/trunk/vector/v.edit/select.c 2011-07-04 10:48:20 UTC (rev 46958)
+++ grass/trunk/vector/v.edit/select.c 2011-07-04 10:49:36 UTC (rev 46959)
@@ -23,6 +23,7 @@
static char first_selection = 1;
static int merge_lists(struct ilist *, struct ilist *);
+static int merge_lists2(struct ilist *, struct boxlist *);
/**
\brief Select vector features
@@ -342,14 +343,14 @@
{
struct bound_box bbox;
- struct ilist *List_tmp;
+ struct boxlist *List_tmp;
if (first_selection) {
List_tmp = List;
first_selection = 0;
}
else {
- List_tmp = Vect_new_list();
+ List_tmp = Vect_new_boxlist();
}
/* bounding box */
@@ -367,7 +368,7 @@
/* merge lists (only duplicate items) */
if (List_tmp != List) {
merge_lists(List, List_tmp);
- Vect_destroy_list(List_tmp);
+ Vect_destroy_boxlist(List_tmp);
}
return List->n_values;
@@ -547,7 +548,7 @@
}
/**
- \brief merge two list, i.e. store only duplicate items
+ \brief merge two lists, i.e. store only duplicate items
\param[in] alist,blist list to be merged
@@ -574,6 +575,33 @@
}
/**
+ \brief merge two lists, i.e. store only duplicate items
+
+ \param[in] alist,blist list to be merged
+
+ \return result number of items
+*/
+static int merge_lists2(struct ilist *alist, struct boxlist *blist)
+{
+ int i;
+
+ struct ilist *list_del;
+
+ list_del = Vect_new_list();
+
+ for (i = 0; i < alist->n_values; i++) {
+ if (!Vect_val_in_boxlist(blist, alist->value[i]))
+ Vect_list_append(list_del, alist->value[i]);
+ }
+
+ Vect_list_delete_list(alist, list_del);
+
+ Vect_destroy_list(list_del);
+
+ return alist->n_values;
+}
+
+/**
\brief Reverse list selection
\param[in] Map vector map
Modified: grass/trunk/vector/v.generalize/misc.c
===================================================================
--- grass/trunk/vector/v.generalize/misc.c 2011-07-04 10:48:20 UTC (rev 46958)
+++ grass/trunk/vector/v.generalize/misc.c 2011-07-04 10:49:36 UTC (rev 46959)
@@ -261,12 +261,12 @@
left_new, right_new;
struct bound_box box;
static struct line_pnts *BPoints = NULL;
- static struct ilist *List = NULL;
+ static struct boxlist *List = NULL;
if (!BPoints)
BPoints = Vect_new_line_struct();
if (!List)
- List = Vect_new_list();
+ List = Vect_new_boxlist(0);
/* Check intersection of the modified boundary with other boundaries */
Vect_line_box(Points, &box);
@@ -278,7 +278,7 @@
struct line_pnts **AXLines, **BXLines;
int naxlines, nbxlines;
- bline = List->value[i];
+ bline = List->id[i];
if (bline == line)
continue;
@@ -287,6 +287,7 @@
/* Vect_line_intersection is quite slow, hopefully not so bad because only few
* intersections should be found if any */
+ AXLines = BXLines = NULL;
Vect_line_intersection(Points, BPoints, &AXLines, &BXLines,
&naxlines, &nbxlines, 0);
@@ -299,14 +300,16 @@
for (j = 0; j < naxlines; j++) {
Vect_destroy_line_struct(AXLines[j]);
}
+ }
+ if (AXLines)
G_free(AXLines);
- }
if (nbxlines > 0) {
for (j = 0; j < nbxlines; j++) {
Vect_destroy_line_struct(BXLines[j]);
}
+ }
+ if (BXLines)
G_free(BXLines);
- }
if (naxlines > 1 || nbxlines > 1) {
intersect = 1;
Modified: grass/trunk/vector/v.kernel/main.c
===================================================================
--- grass/trunk/vector/v.kernel/main.c 2011-07-04 10:48:20 UTC (rev 46958)
+++ grass/trunk/vector/v.kernel/main.c 2011-07-04 10:49:36 UTC (rev 46959)
@@ -605,11 +605,11 @@
double dist;
struct line_pnts *APoints, *BPoints;
struct bound_box box;
- struct ilist *List;
+ struct boxlist *List;
APoints = Vect_new_line_struct();
BPoints = Vect_new_line_struct();
- List = Vect_new_list();
+ List = Vect_new_boxlist(0);
nn = Vect_get_num_primitives(In, GV_POINTS);
nn = nn * (nn - 1);
@@ -639,7 +639,7 @@
for (i = 0; i < List->n_values; i++) {
int bline, ret;
- bline = List->value[i];
+ bline = List->id[i];
if (bline == aline)
continue;
@@ -701,14 +701,14 @@
static struct line_pnts *Points = NULL;
static struct line_pnts *FPoints = NULL;
struct bound_box box;
- static struct ilist *PointsList = NULL;
+ static struct boxlist *PointsList = NULL;
static struct ilist *NodesList = NULL;
if (!Points)
Points = Vect_new_line_struct();
if (!PointsList)
- PointsList = Vect_new_list();
+ PointsList = Vect_new_boxlist(0);
if (node_method == NODE_EQUAL_SPLIT) {
if (!NodesList)
@@ -736,7 +736,7 @@
for (i = 0; i < PointsList->n_values; i++) {
int line, ret;
- line = PointsList->value[i];
+ line = PointsList->id[i];
Vect_read_line(In, Points, NULL, line);
G_debug(3, " SP: %f %f -> %f %f", x, y, Points->x[0], Points->y[0]);
@@ -800,14 +800,15 @@
/* spatial index handling, borrowed from lib/vector/Vlib/find.c */
struct bound_box box;
- static struct ilist *NList = NULL;
+ static struct boxlist *NList = NULL;
static struct line_pnts *Points = NULL;
a[0] = E;
a[1] = N;
- if (!NList)
- NList = Vect_new_list();
+ if (!NList) {
+ NList = Vect_new_boxlist(0);
+ }
if (!Points)
Points = Vect_new_line_struct();
@@ -826,7 +827,7 @@
for (line = 0; line < nlines; line++) {
- Vect_read_line(In, Points, NULL, NList->value[line]);
+ Vect_read_line(In, Points, NULL, NList->id[line]);
b[0] = Points->x[0];
b[1] = Points->y[0];
Modified: grass/trunk/vector/v.neighbors/main.c
===================================================================
--- grass/trunk/vector/v.neighbors/main.c 2011-07-04 10:48:20 UTC (rev 46958)
+++ grass/trunk/vector/v.neighbors/main.c 2011-07-04 10:49:36 UTC (rev 46959)
@@ -37,7 +37,7 @@
struct Option *method_opt, *size_opt;
struct Map_info In;
double radius;
- struct ilist *List;
+ struct boxlist *List;
struct Cell_head region;
struct bound_box box;
struct line_pnts *Points;
@@ -91,7 +91,7 @@
result = Rast_allocate_buf(CELL_TYPE);
Points = Vect_new_line_struct();
Cats = Vect_new_cats_struct();
- List = Vect_new_list();
+ List = Vect_new_boxlist(0);
/*open the new cellfile */
out_fd = Rast_open_new(out_opt->answer, CELL_TYPE);
@@ -127,7 +127,7 @@
count = 0;
for (i = 0; i < List->n_values; i++) {
- Vect_read_line(&In, Points, Cats, List->value[i]);
+ Vect_read_line(&In, Points, Cats, List->id[i]);
if (field != -1 && Vect_cat_get(Cats, field, NULL) == 0)
continue;
Modified: grass/trunk/vector/v.net.steiner/main.c
===================================================================
--- grass/trunk/vector/v.net.steiner/main.c 2011-07-04 10:48:20 UTC (rev 46958)
+++ grass/trunk/vector/v.net.steiner/main.c 2011-07-04 10:49:36 UTC (rev 46959)
@@ -332,7 +332,7 @@
struct ilist *TList; /* list of terminal nodes */
struct ilist *StArcs; /* list of arcs on Steiner tree */
struct ilist *StNodes; /* list of nodes on Steiner tree */
- struct ilist *pointlist;
+ struct boxlist *pointlist;
double cost, tmpcost;
struct cat_list *Clist;
struct line_cats *Cats;
@@ -633,7 +633,7 @@
StNodes->n_values);
k = 0;
- pointlist = Vect_new_list();
+ pointlist = Vect_new_boxlist(0);
for (i = 0; i < StNodes->n_values; i++) {
double x, y, z;
struct bound_box box;
@@ -648,7 +648,7 @@
nlines = Vect_get_node_n_lines(&Map, node);
for (j = 0; j < pointlist->n_values; j++) {
- line = pointlist->value[j];
+ line = pointlist->id[j];
ltype = Vect_read_line(&Map, Points, Cats, line);
if (!(ltype & GV_POINT))
continue;
Modified: grass/trunk/vector/v.select/main.c
===================================================================
--- grass/trunk/vector/v.select/main.c 2011-07-04 10:48:20 UTC (rev 46958)
+++ grass/trunk/vector/v.select/main.c 2011-07-04 10:49:36 UTC (rev 46959)
@@ -40,7 +40,8 @@
struct line_pnts *APoints, *BPoints;
struct line_cats *ACats, *BCats;
int *ALines; /* List of lines: 0 do not output, 1 - write to output */
- struct ilist *List, *TmpList, *BoundList;
+ struct ilist *BoundList, *LList;
+ struct boxlist *List, *TmpList;
G_gisinit(argv[0]);
@@ -109,9 +110,10 @@
BPoints = Vect_new_line_struct();
ACats = Vect_new_cats_struct();
BCats = Vect_new_cats_struct();
- List = Vect_new_list();
- TmpList = Vect_new_list();
+ List = Vect_new_boxlist(0);
+ TmpList = Vect_new_boxlist(0);
BoundList = Vect_new_list();
+ LList = Vect_new_list();
/* Open output */
Vect_open_new(&Out, parm.output->answer, Vect_is_3d(&(In[0])));
@@ -184,7 +186,7 @@
for (i = 0; i < List->n_values; i++) {
int bline;
- bline = List->value[i];
+ bline = List->id[i];
G_debug(3, " bline = %d", bline);
/* Check category */
@@ -227,7 +229,7 @@
for (i = 0; i < List->n_values; i++) {
int barea;
- barea = List->value[i];
+ barea = List->id[i];
G_debug(3, " barea = %d", barea);
if (Vect_get_area_cat(&(In[1]), barea, ifield[1]) < 0) {
@@ -299,7 +301,7 @@
for (i = 0; i < List->n_values; i++) {
int bline;
- bline = List->value[i];
+ bline = List->id[i];
if (!flag.cat->answer && Vect_get_line_cat(&(In[1]), bline, ifield[1]) < 0) {
nskipped++;
@@ -332,11 +334,11 @@
/* List of areas B */
/* Make a list of features forming area A */
- Vect_reset_list(List);
+ Vect_reset_list(LList);
Vect_get_area_boundaries(&(In[0]), aarea, BoundList);
for (i = 0; i < BoundList->n_values; i++) {
- Vect_list_append(List, abs(BoundList->value[i]));
+ Vect_list_append(LList, abs(BoundList->value[i]));
}
naisles = Vect_get_area_num_isles(&(In[0]), aarea);
@@ -348,21 +350,21 @@
Vect_get_isle_boundaries(&(In[0]), aisle, BoundList);
for (j = 0; j < BoundList->n_values; j++) {
- Vect_list_append(List, BoundList->value[j]);
+ Vect_list_append(LList, BoundList->value[j]);
}
}
Vect_select_areas_by_box(&(In[1]), &abox, TmpList);
- for (i = 0; i < List->n_values; i++) {
+ for (i = 0; i < LList->n_values; i++) {
int j, aline;
- aline = abs(List->value[i]);
+ aline = abs(LList->value[i]);
for (j = 0; j < TmpList->n_values; j++) {
int barea, bcentroid;
- barea = TmpList->value[j];
+ barea = TmpList->id[j];
G_debug(3, " barea = %d", barea);
if (Vect_get_area_cat(&(In[1]), barea, ifield[1]) < 0) {
More information about the grass-commit
mailing list