Skip to content

Commit

Permalink
v.to.rast (#259)
Browse files Browse the repository at this point in the history
* fix where selection
  • Loading branch information
metzm committed Dec 16, 2019
1 parent 2c42a0b commit 48e807e
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 6 deletions.
21 changes: 17 additions & 4 deletions vector/v.to.rast/do_areas.c
Original file line number Diff line number Diff line change
Expand Up @@ -120,12 +120,25 @@ int sort_areas(struct Map_info *Map, struct line_pnts *Points,
else {
Vect_read_line(Map, NULL, Cats, centroid);
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 {
G_debug(2, _("Area centroid without category"));
Vect_cat_get(Cats, field, &cat);
if (cat < 0)
SETNULL(&cat);
}

if (!ISNULL(&cat)) {
nareas_selected++;
}
}
else {
Expand Down
11 changes: 10 additions & 1 deletion vector/v.to.rast/do_lines.c
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,16 @@ int do_lines(struct Map_info *Map, struct line_pnts *Points,
type = Vect_read_line(Map, Points, Cats, index);
cat = -1;
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);
}
}
Expand Down
2 changes: 1 addition & 1 deletion vector/v.to.rast/vect2rast.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 */

if ((nrec =
db_select_CatValArray(Driver, Fi->table, Fi->key, column, NULL,
db_select_CatValArray(Driver, Fi->table, Fi->key, column, where,
&cvarr)) == -1)
G_fatal_error(_("Column <%s> not found"), column);
G_debug(3, "nrec = %d", nrec);
Expand Down

0 comments on commit 48e807e

Please sign in to comment.