|
3 | 3 | * MODULE: d.rast.arrow
|
4 | 4 | * AUTHOR(S): Chris Rewerts, Agricultural Engineering, Purdue University
|
5 | 5 | * PURPOSE: Draw arrows on slope/aspect maps.
|
6 |
| - * COPYRIGHT: (C) 2000, 2010 by the GRASS Development Team |
| 6 | + * COPYRIGHT: (C) 2000, 2010, 2023 by the GRASS Development Team |
7 | 7 | *
|
8 | 8 | * This program is free software under the GNU General Public
|
9 | 9 | * License (>=v2). Read the file COPYING that comes with GRASS
|
|
13 | 13 |
|
14 | 14 | /* some minor cleanup done by Andreas Lange, [email protected]
|
15 | 15 | * Update to handle NULLs and floating point aspect maps: Hamish Bowman, Aug
|
16 |
| - * 2004 Update for 360 degree arrows and magnitude scaling: Hamish Bowman, Oct |
17 |
| - * 2005 Align grids with raster cells: Huidae Cho, Apr 2009 Drainage aspect |
18 |
| - * type: Huidae Cho, Sep 2015 |
| 16 | + * 2004; Update for 360 degree arrows and magnitude scaling: Hamish Bowman, Oct |
| 17 | + * 2005; Align grids with raster cells: Huidae Cho, Apr 2009; Drainage aspect |
| 18 | + * type: Huidae Cho, Sep 2015; Terraflow type: Huidae Cho, May 2023 |
19 | 19 | */
|
20 | 20 |
|
21 | 21 | /*
|
@@ -107,7 +107,7 @@ int main(int argc, char **argv)
|
107 | 107 | opt2->type = TYPE_STRING;
|
108 | 108 | opt2->required = NO;
|
109 | 109 | opt2->answer = "grass";
|
110 |
| - opt2->options = "grass,compass,drainage,agnps,answers"; |
| 110 | + opt2->options = "grass,compass,drainage,agnps,answers,terraflow"; |
111 | 111 | opt2->description = _("Type of existing raster aspect map");
|
112 | 112 |
|
113 | 113 | opt3 = G_define_standard_option(G_OPT_C);
|
@@ -198,6 +198,8 @@ int main(int argc, char **argv)
|
198 | 198 | map_type = 4;
|
199 | 199 | else if (strcmp("drainage", opt2->answer) == 0)
|
200 | 200 | map_type = 5;
|
| 201 | + else if (strcmp("terraflow", opt2->answer) == 0) |
| 202 | + map_type = 6; |
201 | 203 |
|
202 | 204 | scale = atof(opt8->answer);
|
203 | 205 | if (scale <= 0.0)
|
@@ -377,7 +379,8 @@ int main(int argc, char **argv)
|
377 | 379 |
|
378 | 380 | /* treat AGNPS and ANSWERS data like old zero-as-null CELL */
|
379 | 381 | /* TODO: update models */
|
380 |
| - if (map_type == 2 || map_type == 3 || map_type == 5) { |
| 382 | + if (map_type == 2 || map_type == 3 || map_type == 5 || |
| 383 | + map_type == 6) { |
381 | 384 | if (Rast_is_null_value(ptr, raster_type))
|
382 | 385 | aspect_c = 0;
|
383 | 386 | else if (map_type == 5 && aspect_f < 0)
|
@@ -557,6 +560,53 @@ int main(int argc, char **argv)
|
557 | 560 | }
|
558 | 561 | }
|
559 | 562 |
|
| 563 | + /* case switch for r.terraflow direction type aspect map */ |
| 564 | + else if (map_type == 6) { |
| 565 | + D_use_color(arrow_color); |
| 566 | + switch (aspect_c) { |
| 567 | + case 0: |
| 568 | + /* only draw if x_color is not none (transparent) */ |
| 569 | + if (x_color > 0) { |
| 570 | + D_use_color(x_color); |
| 571 | + draw_x(); |
| 572 | + D_use_color(arrow_color); |
| 573 | + } |
| 574 | + break; |
| 575 | + case 1: |
| 576 | + arrow_e(); |
| 577 | + break; |
| 578 | + case 2: |
| 579 | + arrow_se(); |
| 580 | + break; |
| 581 | + case 4: |
| 582 | + arrow_s(); |
| 583 | + break; |
| 584 | + case 8: |
| 585 | + arrow_sw(); |
| 586 | + break; |
| 587 | + case 16: |
| 588 | + arrow_w(); |
| 589 | + break; |
| 590 | + case 32: |
| 591 | + arrow_nw(); |
| 592 | + break; |
| 593 | + case 64: |
| 594 | + arrow_n(); |
| 595 | + break; |
| 596 | + case 128: |
| 597 | + arrow_ne(); |
| 598 | + break; |
| 599 | + default: |
| 600 | + /* only draw if unknown_color is not none */ |
| 601 | + if (unknown_color > 0) { |
| 602 | + D_use_color(unknown_color); |
| 603 | + unknown_(); |
| 604 | + D_use_color(arrow_color); |
| 605 | + } |
| 606 | + break; |
| 607 | + } |
| 608 | + } |
| 609 | + |
560 | 610 | ptr = G_incr_void_ptr(ptr, Rast_cell_size(raster_type));
|
561 | 611 | if (opt7->answer)
|
562 | 612 | mag_ptr =
|
|
0 commit comments