[GRASS-SVN] r60469 - grass/branches/releasebranch_7_0/vector/v.segment

svn_grass at osgeo.org svn_grass at osgeo.org
Sat May 24 22:32:04 PDT 2014


Author: hcho
Date: 2014-05-24 22:32:04 -0700 (Sat, 24 May 2014)
New Revision: 60469

Modified:
   grass/branches/releasebranch_7_0/vector/v.segment/main.c
Log:
v.segment: Work with features with multiple cats (merge from r60468)

Modified: grass/branches/releasebranch_7_0/vector/v.segment/main.c
===================================================================
--- grass/branches/releasebranch_7_0/vector/v.segment/main.c	2014-05-25 05:29:36 UTC (rev 60468)
+++ grass/branches/releasebranch_7_0/vector/v.segment/main.c	2014-05-25 05:32:04 UTC (rev 60469)
@@ -368,22 +368,29 @@
 /* Find line by cat, returns 0 if not found */
 int find_line(struct Map_info *Map, int lfield, int lcat)
 {
-    int i, nlines, type, cat;
+    int i, nlines, type;
     struct line_cats *Cats;
+    struct ilist *cats;
 
     G_debug(2, "find_line(): llayer = %d lcat = %d", lfield, lcat);
     Cats = Vect_new_cats_struct();
+    cats = Vect_new_list();
 
     nlines = Vect_get_num_lines(Map);
     for (i = 1; i <= nlines; i++) {
 	type = Vect_read_line(Map, NULL, Cats, i);
 	if (!(type & GV_LINE))
 	    continue;
-	Vect_cat_get(Cats, lfield, &cat);
-	if (cat == lcat)
+
+	Vect_field_cat_get(Cats, lfield, cats);
+	if (Vect_val_in_list(cats, lcat)) {
+            Vect_destroy_list(cats);
 	    return i;
+	}
     }
 
+    Vect_destroy_list(cats);
+
     return 0;
 }
 



More information about the grass-commit mailing list