[GRASS-SVN] r53805 - grass/trunk/vector/v.distance

svn_grass at osgeo.org svn_grass at osgeo.org
Wed Nov 14 06:58:01 PST 2012


Author: mmetz
Date: 2012-11-14 06:58:01 -0800 (Wed, 14 Nov 2012)
New Revision: 53805

Modified:
   grass/trunk/vector/v.distance/main.c
Log:
v.distance: uniform category handling

Modified: grass/trunk/vector/v.distance/main.c
===================================================================
--- grass/trunk/vector/v.distance/main.c	2012-11-14 14:48:16 UTC (rev 53804)
+++ grass/trunk/vector/v.distance/main.c	2012-11-14 14:58:01 UTC (rev 53805)
@@ -665,7 +665,6 @@
 		G_debug(3, "  %d lines in box", lList->n_values);
 
 		for (i = 0; i < lList->n_values; i++) {
-		    tmp_tcat = -1;
 		    ttype = Vect_read_line(&To, TPoints, TCats, lList->id[i]);
 
 		    line2line(FPoints, ftype, TPoints, ttype,
@@ -676,8 +675,16 @@
 		    if (tmp_dist > max || tmp_dist < min)
 			continue;	/* not in threshold */
 
-		    /* TODO: more cats of the same field */
-		    Vect_cat_get(TCats, to_field, &tmp_tcat);
+		    tmp_tcat = -1;
+		    /* TODO: all cats of given field ? */
+		    for (j = 0; j < TCats->n_cats; j++) {
+			if (TCats->field[j] == to_field) {
+			    if (tmp_tcat >= 0)
+				G_warning(_("More cats found in to_layer (line=%d)"),
+					  lList->id[i]);
+			    tmp_tcat = TCats->cat[j];
+			}
+		    }
 
 		    G_debug(4, "  tmp_dist = %f tmp_tcat = %d", tmp_dist,
 			    tmp_tcat);
@@ -734,8 +741,6 @@
 		    if (Vect_get_area_centroid(&To, aList->id[i]) == 0)
 			continue;
 
-		    tmp_tcat = -1;
-
 		    line2area(&To, FPoints, ftype, aList->id[i], &aList->box[i],
 		              &tmp_fx, &tmp_fy, &tmp_fz, &tmp_falong, &tmp_fangle,
 		              &tmp_tx, &tmp_ty, &tmp_tz, &tmp_talong, &tmp_tangle,
@@ -746,8 +751,18 @@
 
 		    /* TODO: more cats of the same field */
 		    Vect_get_area_cats(&To, aList->id[i], TCats);
-		    Vect_cat_get(TCats, to_field, &tmp_tcat);
+		    tmp_tcat = -1;
 
+		    /* TODO: all cats of given field ? */
+		    for (j = 0; j < TCats->n_cats; j++) {
+			if (TCats->field[j] == to_field) {
+			    if (tmp_tcat >= 0)
+				G_warning(_("More cats found in to_layer (area=%d)"),
+					  aList->id[i]);
+			    tmp_tcat = TCats->cat[j];
+			}
+		    }
+
 		    G_debug(4, "  tmp_dist = %f tmp_tcat = %d", tmp_dist,
 			    tmp_tcat);
 
@@ -922,7 +937,6 @@
 		G_debug(3, "  %d lines in box", lList->n_values);
 
 		for (i = 0; i < lList->n_values; i++) {
-		    tmp_tcat = -1;
 		    ttype = Vect_read_line(&To, TPoints, TCats, lList->id[i]);
 
 		    /* area to line */
@@ -934,8 +948,16 @@
 		    if (tmp_dist > max || tmp_dist < min)
 			continue;	/* not in threshold */
 
-		    /* TODO: more cats of the same field */
-		    Vect_cat_get(TCats, to_field, &tmp_tcat);
+		    tmp_tcat = -1;
+		    /* TODO: all cats of given field ? */
+		    for (j = 0; j < TCats->n_cats; j++) {
+			if (TCats->field[j] == to_field) {
+			    if (tmp_tcat >= 0)
+				G_warning(_("More cats found in to_layer (line=%d)"),
+					  lList->id[i]);
+			    tmp_tcat = TCats->cat[j];
+			}
+		    }
 
 		    G_debug(4, "  tmp_dist = %f tmp_tcat = %d", tmp_dist,
 			    tmp_tcat);
@@ -1079,7 +1101,7 @@
 			if (TCats->field[j] == to_field) {
 			    if (tmp_tcat >= 0)
 				G_warning(_("More cats found in to_layer (area=%d)"),
-					  area);
+					  tarea);
 			    tmp_tcat = TCats->cat[j];
 			}
 		    }



More information about the grass-commit mailing list