Jelajahi Sumber

v.to.rast (#259)

* fix where selection
Markus Metz 5 tahun lalu
induk
melakukan
b4f79f2f82
3 mengubah file dengan 28 tambahan dan 6 penghapusan
  1. 17 4
      vector/v.to.rast/do_areas.c
  2. 10 1
      vector/v.to.rast/do_lines.c
  3. 1 1
      vector/v.to.rast/vect2rast.c

+ 17 - 4
vector/v.to.rast/do_areas.c

@@ -120,12 +120,25 @@ int sort_areas(struct Map_info *Map, struct line_pnts *Points,
 	else {
 	else {
 	    Vect_read_line(Map, NULL, Cats, centroid);
 	    Vect_read_line(Map, NULL, Cats, centroid);
 	    if (field > 0) {
 	    if (field > 0) {
-		if (Vect_cats_in_constraint(Cats, field, cat_list)) {
-		    Vect_cat_get(Cats, field, &cat);
-		    nareas_selected++;
+		if (cat_list) {
+		    int j;
+
+		    for (j = 0; j < Cats->n_cats; j++) {
+			if (Cats->field[j] == field &&
+			    Vect_cat_in_cat_list(Cats->cat[j], cat_list)) {
+				cat = Cats->cat[j];
+				break;
+			}
+		    }
 		}
 		}
 		else {
 		else {
-		    G_debug(2, _("Area centroid without category"));
+		    Vect_cat_get(Cats, field, &cat);
+		    if (cat < 0)
+			SETNULL(&cat);
+		}
+
+		if (!ISNULL(&cat)) {
+		    nareas_selected++;
 		}
 		}
 	    }
 	    }
 	    else {
 	    else {

+ 10 - 1
vector/v.to.rast/do_lines.c

@@ -39,7 +39,16 @@ int do_lines(struct Map_info *Map, struct line_pnts *Points,
 	type = Vect_read_line(Map, Points, Cats, index);
 	type = Vect_read_line(Map, Points, Cats, index);
 	cat = -1;
 	cat = -1;
 	if (field > 0) {
 	if (field > 0) {
-	    if (Vect_cats_in_constraint(Cats, field, cat_list)) {
+	    if (cat_list) {
+		for (j = 0; j < Cats->n_cats; j++) {
+		    if (Cats->field[j] == field &&
+			Vect_cat_in_cat_list(Cats->cat[j], cat_list)) {
+			    cat = Cats->cat[j];
+			    break;
+		    }
+		}
+	    }
+	    else {
 		Vect_cat_get(Cats, field, &cat);
 		Vect_cat_get(Cats, field, &cat);
 	    }
 	    }
 	}
 	}

+ 1 - 1
vector/v.to.rast/vect2rast.c

@@ -64,7 +64,7 @@ int vect_to_rast(const char *vector_map, const char *raster_map, const char *fie
 	/* Note do not check if the column exists in the table because it may be expression */
 	/* Note do not check if the column exists in the table because it may be expression */
 
 
 	if ((nrec =
 	if ((nrec =
-	     db_select_CatValArray(Driver, Fi->table, Fi->key, column, NULL,
+	     db_select_CatValArray(Driver, Fi->table, Fi->key, column, where,
 				   &cvarr)) == -1)
 				   &cvarr)) == -1)
 	    G_fatal_error(_("Column <%s> not found"), column);
 	    G_fatal_error(_("Column <%s> not found"), column);
 	G_debug(3, "nrec = %d", nrec);
 	G_debug(3, "nrec = %d", nrec);