瀏覽代碼

v.segment: Work with features with multiple cats (merge from https://trac.osgeo.org/grass/changeset/60468)

git-svn-id: https://svn.osgeo.org/grass/grass/branches/releasebranch_7_0@60469 15284696-431f-4ddb-bdfa-cd5b030d7da7
Huidae Cho 11 年之前
父節點
當前提交
7683d5fbd3
共有 1 個文件被更改,包括 10 次插入3 次删除
  1. 10 3
      vector/v.segment/main.c

+ 10 - 3
vector/v.segment/main.c

@@ -368,22 +368,29 @@ int read_line_input(char *buf, char *stype, int *id, int *lcat,
 /* 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;
 }