[GRASS-SVN] r73060 - in grass/trunk/raster/r.watershed: ram seg

svn_grass at osgeo.org svn_grass at osgeo.org
Tue Aug 7 14:10:33 PDT 2018


Author: mmetz
Date: 2018-08-07 14:10:33 -0700 (Tue, 07 Aug 2018)
New Revision: 73060

Modified:
   grass/trunk/raster/r.watershed/ram/do_cum.c
   grass/trunk/raster/r.watershed/seg/do_cum.c
Log:
r.watershed: prepare for multiple bitmask encoded directions

Modified: grass/trunk/raster/r.watershed/ram/do_cum.c
===================================================================
--- grass/trunk/raster/r.watershed/ram/do_cum.c	2018-08-07 14:18:36 UTC (rev 73059)
+++ grass/trunk/raster/r.watershed/ram/do_cum.c	2018-08-07 21:10:33 UTC (rev 73060)
@@ -272,6 +272,20 @@
     int asp_r[9] = { 0, -1, -1, -1, 0, 1, 1, 1, 0 };
     int asp_c[9] = { 0, 1, 0, -1, -1, -1, 0, 1, 1 };
     int this_index, down_index, nbr_index;
+
+    /* drainage directions bitmask encoded CW from North
+     * drainage directions are set for each current cell
+     * 
+     * bit positions, zero-based
+     * 
+     *     X = current cell
+     * 
+     *       6   7   0
+     *       5   X   1
+     *       4   3   2
+     */
+    int nextmfd[8] = { 3, 7, 5, 1, 0, 4, 2, 6 };
+    int mfdir;
     
     G_message(_("SECTION 3a: Accumulating Surface Flow with MFD."));
     G_debug(1, "MFD convergence factor set to %d.", c_fac);
@@ -316,6 +330,7 @@
 	    ele = alt[this_index];
 	    is_null = 0;
 	    edge = 0;
+	    mfdir = 0;
 	    /* this loop is needed to get the sum of weights */
 	    for (ct_dir = 0; ct_dir < sides; ct_dir++) {
 		/* get r, c (r_nbr, c_nbr) for neighbours */
@@ -405,6 +420,8 @@
 			is_worked = FLAG_GET(worked, r_nbr, c_nbr);
 			if (is_worked == 0) {
 
+			    mfdir |= (1 << nextmfd[ct_dir]);
+
 			    nbr_index = SEG_INDEX(wat_seg, r_nbr, c_nbr);
 
 			    weight[ct_dir] = weight[ct_dir] / sum_weight;

Modified: grass/trunk/raster/r.watershed/seg/do_cum.c
===================================================================
--- grass/trunk/raster/r.watershed/seg/do_cum.c	2018-08-07 14:18:36 UTC (rev 73059)
+++ grass/trunk/raster/r.watershed/seg/do_cum.c	2018-08-07 21:10:33 UTC (rev 73060)
@@ -290,6 +290,20 @@
     int asp_r[9] = { 0, -1, -1, -1, 0, 1, 1, 1, 0 };
     int asp_c[9] = { 0, 1, 0, -1, -1, -1, 0, 1, 1 };
 
+    /* drainage directions bitmask encoded CW from North
+     * drainage directions are set for each current cell
+     * 
+     * bit positions, zero-based
+     * 
+     *     X = current cell
+     * 
+     *       6   7   0
+     *       5   X   1
+     *       4   3   2
+     */
+    int nextmfd[8] = { 3, 7, 5, 1, 0, 4, 2, 6 };
+    int mfdir;
+
     G_message(_("SECTION 3a: Accumulating Surface Flow with MFD."));
     G_debug(1, "MFD convergence factor set to %d.", c_fac);
 
@@ -441,6 +455,8 @@
 
 			if (FLAG_GET(flag_nbr[ct_dir], WORKEDFLAG)) {
 
+			    mfdir |= (1 << nextmfd[ct_dir]);
+
 			    weight[ct_dir] = weight[ct_dir] / sum_weight;
 			    /* check everything adds up to 1.0 */
 			    prop += weight[ct_dir];



More information about the grass-commit mailing list