[GRASS-SVN] r73061 - in grass/trunk/raster/r.watershed: front ram seg
svn_grass at osgeo.org
svn_grass at osgeo.org
Tue Aug 7 14:29:35 PDT 2018
Author: mmetz
Date: 2018-08-07 14:29:35 -0700 (Tue, 07 Aug 2018)
New Revision: 73061
Modified:
grass/trunk/raster/r.watershed/front/main.c
grass/trunk/raster/r.watershed/ram/close_maps.c
grass/trunk/raster/r.watershed/ram/close_maps2.c
grass/trunk/raster/r.watershed/ram/def_basin.c
grass/trunk/raster/r.watershed/ram/do_astar.c
grass/trunk/raster/r.watershed/ram/do_cum.c
grass/trunk/raster/r.watershed/ram/do_flatarea.c
grass/trunk/raster/r.watershed/ram/find_pour.c
grass/trunk/raster/r.watershed/ram/init_vars.c
grass/trunk/raster/r.watershed/ram/main.c
grass/trunk/raster/r.watershed/ram/no_stream.c
grass/trunk/raster/r.watershed/ram/over_cells.c
grass/trunk/raster/r.watershed/ram/split_str.c
grass/trunk/raster/r.watershed/seg/bseg_get.c
grass/trunk/raster/r.watershed/seg/bseg_read.c
grass/trunk/raster/r.watershed/seg/bseg_write.c
grass/trunk/raster/r.watershed/seg/close_maps.c
grass/trunk/raster/r.watershed/seg/close_maps2.c
grass/trunk/raster/r.watershed/seg/cseg_open.c
grass/trunk/raster/r.watershed/seg/cseg_read.c
grass/trunk/raster/r.watershed/seg/cseg_write.c
grass/trunk/raster/r.watershed/seg/def_basin.c
grass/trunk/raster/r.watershed/seg/do_astar.c
grass/trunk/raster/r.watershed/seg/do_cum.c
grass/trunk/raster/r.watershed/seg/dseg_open.c
grass/trunk/raster/r.watershed/seg/dseg_read.c
grass/trunk/raster/r.watershed/seg/dseg_write.c
grass/trunk/raster/r.watershed/seg/find_pour.c
grass/trunk/raster/r.watershed/seg/init_vars.c
grass/trunk/raster/r.watershed/seg/main.c
grass/trunk/raster/r.watershed/seg/no_stream.c
grass/trunk/raster/r.watershed/seg/over_cells.c
grass/trunk/raster/r.watershed/seg/sg_factor.c
grass/trunk/raster/r.watershed/seg/slope_len.c
grass/trunk/raster/r.watershed/seg/split_str.c
grass/trunk/raster/r.watershed/seg/sseg_open.c
Log:
r.watershed: indent again
Modified: grass/trunk/raster/r.watershed/front/main.c
===================================================================
--- grass/trunk/raster/r.watershed/front/main.c 2018-08-07 21:10:33 UTC (rev 73060)
+++ grass/trunk/raster/r.watershed/front/main.c 2018-08-07 21:29:35 UTC (rev 73061)
@@ -30,6 +30,7 @@
static void do_opt(const struct Option *opt)
{
char *buf;
+
if (!opt->answer)
return;
buf = G_malloc(strlen(opt->key) + 1 + strlen(opt->answer) + 1);
@@ -78,7 +79,8 @@
G_add_keyword(_("stream network"));
G_add_keyword(_("stream power index"));
G_add_keyword(_("topographic index"));
- module->description = _("Calculates hydrological parameters and RUSLE factors.");
+ module->description =
+ _("Calculates hydrological parameters and RUSLE factors.");
opt1 = G_define_standard_option(G_OPT_R_ELEV);
opt1->guisection = _("Inputs");
@@ -86,13 +88,15 @@
opt2 = G_define_standard_option(G_OPT_R_INPUT);
opt2->key = "depression";
opt2->label = _("Name of input depressions raster map");
- opt2->description = _("All non-NULL and non-zero cells are considered as real depressions");
+ opt2->description =
+ _("All non-NULL and non-zero cells are considered as real depressions");
opt2->required = NO;
opt2->guisection = _("Inputs");
opt3 = G_define_standard_option(G_OPT_R_INPUT);
opt3->key = "flow";
- opt3->description = _("Name of input raster representing amount of overland flow per cell");
+ opt3->description =
+ _("Name of input raster representing amount of overland flow per cell");
opt3->required = NO;
opt3->guisection = _("Inputs");
@@ -114,8 +118,7 @@
opt6 = G_define_option();
opt6->key = "threshold";
- opt6->description =
- _("Minimum size of exterior watershed basin");
+ opt6->description = _("Minimum size of exterior watershed basin");
opt6->required = NO;
opt6->type = TYPE_INTEGER;
opt6->guisection = _("Inputs");
@@ -122,8 +125,7 @@
opt7 = G_define_option();
opt7->key = "max_slope_length";
- opt7->label =
- _("Maximum length of surface flow in map units");
+ opt7->label = _("Maximum length of surface flow in map units");
opt7->description = _("For USLE");
opt7->required = NO;
opt7->type = TYPE_DOUBLE;
@@ -131,10 +133,8 @@
opt8 = G_define_standard_option(G_OPT_R_OUTPUT);
opt8->key = "accumulation";
- opt8->label =
- _("Name for output accumulation raster map");
- opt8->description =
- _("Number of cells that drain through each cell");
+ opt8->label = _("Name for output accumulation raster map");
+ opt8->description = _("Number of cells that drain through each cell");
opt8->required = NO;
opt8->guisection = _("Outputs");
@@ -147,8 +147,7 @@
opt18 = G_define_standard_option(G_OPT_R_OUTPUT);
opt18->key = "spi";
- opt18->label =
- _("Stream power index a * tan(b)");
+ opt18->label = _("Stream power index a * tan(b)");
opt18->required = NO;
opt18->guisection = _("Outputs");
@@ -174,8 +173,7 @@
opt12 = G_define_standard_option(G_OPT_R_OUTPUT);
opt12->key = "half_basin";
opt12->label = _("Name for output half basins raster map");
- opt12->description =
- _("Each half-basin is given a unique value");
+ opt12->description = _("Each half-basin is given a unique value");
opt12->required = NO;
opt12->guisection = _("Outputs");
@@ -182,8 +180,7 @@
opt13 = G_define_standard_option(G_OPT_R_OUTPUT);
opt13->key = "length_slope";
opt13->label = _("Name for output slope length raster map");
- opt13->description =
- _("Slope length and steepness (LS) factor for USLE");
+ opt13->description = _("Slope length and steepness (LS) factor for USLE");
opt13->required = NO;
opt13->guisection = _("Outputs");
@@ -223,8 +220,7 @@
flag_seg = G_define_flag();
flag_seg->key = 'm';
- flag_seg->label =
- _("Enable disk swap memory option: Operation is slow");
+ flag_seg->label = _("Enable disk swap memory option: Operation is slow");
flag_seg->description =
_("Only needed if memory requirements exceed available RAM; see manual on how to calculate memory requirements");
@@ -237,8 +233,7 @@
flag_flat = G_define_flag();
flag_flat->key = 'b';
- flag_flat->label =
- _("Beautify flat areas");
+ flag_flat->label = _("Beautify flat areas");
flag_flat->description =
_("Flow direction in flat areas is modified to look prettier");
@@ -288,8 +283,7 @@
/* Build command line */
sprintf(command, "%s/etc/r.watershed/%s",
- G_gisbase(),
- flag_seg->answer ? "seg" : "ram");
+ G_gisbase(), flag_seg->answer ? "seg" : "ram");
new_argv[new_argc++] = command;
if (flag_sfd->answer)
@@ -329,9 +323,10 @@
new_argv[new_argc++] = NULL;
G_debug(1, "Mode: %s", flag_seg->answer ? "Segmented" : "All in RAM");
-/* if (flag_seg->answer)
- G_message(_("Using memory cache size: %.1f MB"), atof(opt16->answer));
-*/
+ /*
+ if (flag_seg->answer)
+ G_message(_("Using memory cache size: %.1f MB"), atof(opt16->answer));
+ */
ret = G_vspawn_ex(new_argv[0], new_argv);
if (ret != EXIT_SUCCESS)
@@ -356,7 +351,7 @@
opt1->answer, flag_seg->answer, flag_sfd->answer);
if (opt10->answer)
write_hist(opt10->answer,
- "Watershed basins", opt1->answer, flag_seg->answer,
+ "Watershed basins", opt1->answer, flag_seg->answer,
flag_sfd->answer);
if (opt11->answer)
write_hist(opt11->answer,
@@ -364,7 +359,7 @@
flag_seg->answer, flag_sfd->answer);
if (opt12->answer)
write_hist(opt12->answer,
- "Watershed half-basins", opt1->answer, flag_seg->answer,
+ "Watershed half-basins", opt1->answer, flag_seg->answer,
flag_sfd->answer);
if (opt13->answer)
write_hist(opt13->answer,
@@ -379,7 +374,8 @@
}
/* record map history info */
-static void write_hist(char *map_name, char *title, char *source_name, int mode, int sfd)
+static void write_hist(char *map_name, char *title, char *source_name,
+ int mode, int sfd)
{
struct History history;
@@ -387,10 +383,10 @@
Rast_short_history(map_name, "raster", &history);
Rast_set_history(&history, HIST_DATSRC_1, source_name);
- Rast_append_format_history(
- &history, "Processing mode: %s", sfd ? "SFD (D8)" : "MFD");
- Rast_append_format_history(
- &history, "Memory mode: %s", mode ? "Segmented" : "All in RAM");
+ Rast_append_format_history(&history, "Processing mode: %s",
+ sfd ? "SFD (D8)" : "MFD");
+ Rast_append_format_history(&history, "Memory mode: %s",
+ mode ? "Segmented" : "All in RAM");
Rast_command_history(&history);
Rast_write_history(map_name, &history);
Modified: grass/trunk/raster/r.watershed/ram/close_maps.c
===================================================================
--- grass/trunk/raster/r.watershed/ram/close_maps.c 2018-08-07 21:10:33 UTC (rev 73060)
+++ grass/trunk/raster/r.watershed/ram/close_maps.c 2018-08-07 21:29:35 UTC (rev 73061)
@@ -29,7 +29,8 @@
fd = Rast_open_new(wat_name, DCELL_TYPE);
if (abs_acc) {
G_message("Writing out only positive flow accumulation values.");
- G_message("Cells with a likely underestimate for flow accumulation can no longer be identified.");
+ G_message
+ ("Cells with a likely underestimate for flow accumulation can no longer be identified.");
for (r = 0; r < nrows; r++) {
Rast_set_d_null_value(dbuf, ncols); /* reset row to all NULL */
for (c = 0; c < ncols; c++) {
@@ -61,8 +62,7 @@
}
Rast_close(fd);
- stddev =
- sqrt((sum_sqr - (sum + sum / do_points)) / (do_points - 1));
+ stddev = sqrt((sum_sqr - (sum + sum / do_points)) / (do_points - 1));
G_debug(1, "stddev: %f", stddev);
/* set nice color rules: yellow, green, cyan, blue, black */
@@ -80,51 +80,51 @@
clr_min = min - 1;
clr_max = -stddev - 1;
Rast_add_d_color_rule(&clr_min, 0, 0, 0, &clr_max, 0,
- 0, 0, &colors);
+ 0, 0, &colors);
}
clr_min = -stddev - 1.;
clr_max = -1. * exp(lstddev * 0.75);
Rast_add_d_color_rule(&clr_min, 0, 0, 0, &clr_max, 0,
- 0, 255, &colors);
+ 0, 255, &colors);
clr_min = clr_max;
clr_max = -1. * exp(lstddev * 0.5);
Rast_add_d_color_rule(&clr_min, 0, 0, 255, &clr_max, 0,
- 255, 255, &colors);
+ 255, 255, &colors);
clr_min = clr_max;
clr_max = -1. * exp(lstddev * 0.35);
Rast_add_d_color_rule(&clr_min, 0, 255, 255, &clr_max, 0,
- 255, 0, &colors);
+ 255, 0, &colors);
clr_min = clr_max;
clr_max = -1.;
Rast_add_d_color_rule(&clr_min, 0, 255, 0, &clr_max, 255,
- 255, 0, &colors);
+ 255, 0, &colors);
}
clr_min = -1.;
clr_max = 1.;
Rast_add_d_color_rule(&clr_min, 255, 255, 0, &clr_max, 255,
- 255, 0, &colors);
+ 255, 0, &colors);
clr_min = 1;
clr_max = exp(lstddev * 0.35);
Rast_add_d_color_rule(&clr_min, 255, 255, 0, &clr_max, 0,
- 255, 0, &colors);
+ 255, 0, &colors);
clr_min = clr_max;
clr_max = exp(lstddev * 0.5);
Rast_add_d_color_rule(&clr_min, 0, 255, 0, &clr_max, 0,
- 255, 255, &colors);
+ 255, 255, &colors);
clr_min = clr_max;
clr_max = exp(lstddev * 0.75);
Rast_add_d_color_rule(&clr_min, 0, 255, 255, &clr_max, 0,
- 0, 255, &colors);
+ 0, 255, &colors);
clr_min = clr_max;
clr_max = stddev + 1.;
Rast_add_d_color_rule(&clr_min, 0, 0, 255, &clr_max, 0, 0,
- 0, &colors);
+ 0, &colors);
if (max > 0 && max > stddev + 1) {
clr_min = stddev + 1;
clr_max = max + 1;
Rast_add_d_color_rule(&clr_min, 0, 0, 0, &clr_max, 0, 0,
- 0, &colors);
+ 0, &colors);
}
Rast_write_colors(wat_name, this_mapset, &colors);
}
@@ -139,8 +139,8 @@
Rast_set_d_null_value(dbuf, ncols); /* reset row to all NULL */
for (c = 0; c < ncols; c++) {
if (!Rast_is_d_null_value(&tanb[SEG_INDEX(wat_seg, r, c)])) {
- dvalue = log(sca[SEG_INDEX(wat_seg, r, c)] /
- tanb[SEG_INDEX(wat_seg, r, c)]);
+ dvalue = log(sca[SEG_INDEX(wat_seg, r, c)] /
+ tanb[SEG_INDEX(wat_seg, r, c)]);
dbuf[c] = dvalue;
sum += dvalue;
sum_sqr += dvalue * dvalue;
@@ -151,8 +151,7 @@
Rast_close(fd);
mean = sum / do_points;
- stddev =
- sqrt((sum_sqr - (sum + sum / do_points)) / (do_points - 1));
+ stddev = sqrt((sum_sqr - (sum + sum / do_points)) / (do_points - 1));
G_debug(1, "stddev: %f", stddev);
/* set nice color rules: yellow, green, cyan, blue, black */
@@ -169,31 +168,31 @@
clr_min = min - 1;
clr_max = mean - 0.5 * stddev;
Rast_add_d_color_rule(&clr_min, 255, 255, 0, &clr_max, 255,
- 255, 0, &colors);
+ 255, 0, &colors);
}
clr_min = mean - 0.5 * stddev;
clr_max = mean - 0.2 * stddev;
Rast_add_d_color_rule(&clr_min, 255, 255, 0, &clr_max, 0,
- 255, 0, &colors);
+ 255, 0, &colors);
clr_min = clr_max;
clr_max = mean + 0.2 * stddev;
Rast_add_d_color_rule(&clr_min, 0, 255, 0, &clr_max, 0,
- 255, 255, &colors);
+ 255, 255, &colors);
clr_min = clr_max;
clr_max = mean + 0.6 * stddev;
Rast_add_d_color_rule(&clr_min, 0, 255, 255, &clr_max, 0,
- 0, 255, &colors);
+ 0, 255, &colors);
clr_min = clr_max;
clr_max = mean + 1. * stddev;
Rast_add_d_color_rule(&clr_min, 0, 0, 255, &clr_max, 0, 0,
- 0, &colors);
+ 0, &colors);
if (max > 0 && max > clr_max) {
clr_min = clr_max;
clr_max = max + 1;
Rast_add_d_color_rule(&clr_min, 0, 0, 0, &clr_max, 0, 0,
- 0, &colors);
+ 0, &colors);
}
Rast_write_colors(tci_name, this_mapset, &colors);
}
@@ -208,7 +207,9 @@
Rast_set_d_null_value(dbuf, ncols); /* reset row to all NULL */
for (c = 0; c < ncols; c++) {
if (!Rast_is_d_null_value(&tanb[SEG_INDEX(wat_seg, r, c)])) {
- dvalue = sca[SEG_INDEX(wat_seg, r, c)] * tanb[SEG_INDEX(wat_seg, r, c)];
+ dvalue =
+ sca[SEG_INDEX(wat_seg, r, c)] *
+ tanb[SEG_INDEX(wat_seg, r, c)];
dbuf[c] = dvalue;
sum += dvalue;
sum_sqr += dvalue * dvalue;
@@ -219,8 +220,7 @@
Rast_close(fd);
mean = sum / do_points;
- stddev =
- sqrt((sum_sqr - (sum + sum / do_points)) / (do_points - 1));
+ stddev = sqrt((sum_sqr - (sum + sum / do_points)) / (do_points - 1));
G_debug(1, "stddev: %f", stddev);
/* set nice color rules: yellow, green, cyan, blue, black */
@@ -237,31 +237,31 @@
clr_min = min - 1;
clr_max = mean - 0.5 * stddev;
Rast_add_d_color_rule(&clr_min, 255, 255, 0, &clr_max, 255,
- 255, 0, &colors);
+ 255, 0, &colors);
}
clr_min = mean - 0.5 * stddev;
clr_max = mean - 0.2 * stddev;
Rast_add_d_color_rule(&clr_min, 255, 255, 0, &clr_max, 0,
- 255, 0, &colors);
+ 255, 0, &colors);
clr_min = clr_max;
clr_max = mean + 0.2 * stddev;
Rast_add_d_color_rule(&clr_min, 0, 255, 0, &clr_max, 0,
- 255, 255, &colors);
+ 255, 255, &colors);
clr_min = clr_max;
clr_max = mean + 0.6 * stddev;
Rast_add_d_color_rule(&clr_min, 0, 255, 255, &clr_max, 0,
- 0, 255, &colors);
+ 0, 255, &colors);
clr_min = clr_max;
clr_max = mean + 1. * stddev;
Rast_add_d_color_rule(&clr_min, 0, 0, 255, &clr_max, 0, 0,
- 0, &colors);
+ 0, &colors);
if (max > 0 && max > clr_max) {
clr_min = clr_max;
clr_max = max + 1;
Rast_add_d_color_rule(&clr_min, 0, 0, 0, &clr_max, 0, 0,
- 0, &colors);
+ 0, &colors);
}
Rast_write_colors(spi_name, this_mapset, &colors);
}
Modified: grass/trunk/raster/r.watershed/ram/close_maps2.c
===================================================================
--- grass/trunk/raster/r.watershed/ram/close_maps2.c 2018-08-07 21:10:33 UTC (rev 73060)
+++ grass/trunk/raster/r.watershed/ram/close_maps2.c 2018-08-07 21:29:35 UTC (rev 73061)
@@ -46,7 +46,8 @@
for (bl = 90 + incr; bl <= 255; bl += 40) {
flag = 1;
while (flag) {
- Rast_get_c_color(&r, &red, &green, &blue, &colors);
+ Rast_get_c_color(&r, &red, &green, &blue,
+ &colors);
/* if existing rule is too dark then append a new
rule to override it */
if ((blue * .11 + red * .30 + green * .59) <
Modified: grass/trunk/raster/r.watershed/ram/def_basin.c
===================================================================
--- grass/trunk/raster/r.watershed/ram/def_basin.c 2018-08-07 21:10:33 UTC (rev 73060)
+++ grass/trunk/raster/r.watershed/ram/def_basin.c 2018-08-07 21:29:35 UTC (rev 73061)
@@ -51,8 +51,7 @@
direction = asp[SEG_INDEX(asp_seg, r, c)];
if (direction == drain[rr][cc]) {
thisdir = updrain[rr][cc];
- switch (haf_basin_side
- (oldupdir, downdir, thisdir)) {
+ switch (haf_basin_side(oldupdir, downdir, thisdir)) {
case LEFT:
overland_cells(r, c, basin_num, basin_num - 1,
&new_elev);
Modified: grass/trunk/raster/r.watershed/ram/do_astar.c
===================================================================
--- grass/trunk/raster/r.watershed/ram/do_astar.c 2018-08-07 21:10:33 UTC (rev 73060)
+++ grass/trunk/raster/r.watershed/ram/do_astar.c 2018-08-07 21:29:35 UTC (rev 73061)
@@ -12,6 +12,7 @@
CELL alt_val, alt_nbr[8];
CELL is_in_list, is_worked, flat_is_done, nbr_flat_is_done;
int index_doer, index_up;
+
/* sides
* |7|1|4|
* |2| |3|
@@ -47,7 +48,8 @@
if (flat_flag) {
alt_bak =
- (CELL *) G_malloc(sizeof(CELL) * size_array(&alt_seg, nrows, ncols));
+ (CELL *) G_malloc(sizeof(CELL) *
+ size_array(&alt_seg, nrows, ncols));
flat_done = flag_create(nrows, ncols);
flat_is_done = 0;
@@ -103,7 +105,7 @@
is_in_list = FLAG_GET(in_list, upr, upc);
is_worked = FLAG_GET(worked, upr, upc);
skip_diag = 0;
-
+
alt_nbr[ct_dir] = alt[index_up];
if (flat_flag && !is_in_list && !is_worked) {
alt_val = alt_bak[index_doer];
@@ -126,7 +128,7 @@
alt_nbr[ct_dir] = alt[index_up];
}
}
-
+
/* avoid diagonal flow direction bias */
if (!is_worked) {
slope[ct_dir] =
@@ -174,8 +176,8 @@
}
}
}
- } /* end if in region */
- } /* end sides */
+ } /* end if in region */
+ } /* end sides */
FLAG_SET(worked, r, c);
}
G_percent(count, do_points, 1); /* finish it */
@@ -317,8 +319,7 @@
return 0;
}
-double
-get_slope(int r, int c, int downr, int downc, CELL ele, CELL downe)
+double get_slope(int r, int c, int downr, int downc, CELL ele, CELL downe)
{
double slope;
Modified: grass/trunk/raster/r.watershed/ram/do_cum.c
===================================================================
--- grass/trunk/raster/r.watershed/ram/do_cum.c 2018-08-07 21:10:33 UTC (rev 73060)
+++ grass/trunk/raster/r.watershed/ram/do_cum.c 2018-08-07 21:29:35 UTC (rev 73061)
@@ -16,22 +16,23 @@
/* EW Dist at North edge */
ew_dist1 = G_distance(window.east, window.north,
- window.west, window.north);
+ window.west, window.north);
/* EW Dist at Center */
ew_dist2 = G_distance(window.east, (window.north + window.south) / 2.,
- window.west, (window.north + window.south) / 2.);
+ window.west,
+ (window.north + window.south) / 2.);
/* EW Dist at South Edge */
ew_dist3 = G_distance(window.east, window.south,
- window.west, window.south);
+ window.west, window.south);
/* NS Dist at East edge */
ns_dist1 = G_distance(window.east, window.north,
- window.east, window.south);
+ window.east, window.south);
/* NS Dist at Center */
ns_dist2 = G_distance((window.west + window.east) / 2., window.north,
- (window.west + window.east) / 2., window.south);
+ (window.west + window.east) / 2., window.south);
/* NS Dist at West edge */
ns_dist3 = G_distance(window.west, window.north,
- window.west, window.south);
+ window.west, window.south);
ew_res = (ew_dist1 + ew_dist2 + ew_dist3) / (3 * window.cols);
ns_res = (ns_dist1 + ns_dist2 + ns_dist3) / (3 * window.rows);
@@ -40,7 +41,7 @@
ns_res = window.ns_res;
ew_res = window.ew_res;
}
-
+
for (ct_dir = 0; ct_dir < sides; ct_dir++) {
/* get r, c (r_nbr, c_nbr) for neighbours */
r_nbr = nextdr[ct_dir];
@@ -78,7 +79,8 @@
G_debug(1, "ew contour: %.4f", contour[2]);
contour[4] = (ew_res - contour[0]);
contour[5] = (ns_res - contour[2]);
- contour[7] = sqrt(contour[4] * contour[4] + contour[5] * contour[5]) / 2.;
+ contour[7] =
+ sqrt(contour[4] * contour[4] + contour[5] * contour[5]) / 2.;
G_debug(1, "diag contour: %.4f", contour[7]);
contour[4] = contour[5] = contour[6] = contour[7];
}
@@ -135,7 +137,7 @@
/* skip user-defined depressions */
else
dr = dc = -1;
- if (dr >= 0 && dr < nrows && dc >= 0 && dc < ncols) { /* if ((dr = astar_pts[killer].downr) > -1) { */
+ if (dr >= 0 && dr < nrows && dc >= 0 && dc < ncols) { /* if ((dr = astar_pts[killer].downr) > -1) { */
down_index = SEG_INDEX(wat_seg, dr, dc);
value = wat[this_index];
if (fabs(value) >= threshold)
@@ -196,9 +198,9 @@
* stream power index a * tan(beta) */
if (atanb_flag) {
sca[this_index] = fabs(wat[this_index]) *
- (cell_size / contour[np_side]);
+ (cell_size / contour[np_side]);
tanb[this_index] = get_slope_tci(alt[this_index],
- alt[down_index],
+ alt[down_index],
dist_to_nbr[np_side]);
}
@@ -286,7 +288,7 @@
*/
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);
@@ -294,7 +296,7 @@
dist_to_nbr = (double *)G_malloc(sides * sizeof(double));
weight = (double *)G_malloc(sides * sizeof(double));
contour = (double *)G_malloc(sides * sizeof(double));
-
+
cell_size = get_dist(dist_to_nbr, contour);
flag_clear_all(worked);
@@ -317,7 +319,7 @@
}
else
dr = dc = -1;
- if (dr >= 0 && dr < nrows && dc >= 0 && dc < ncols) { /* if ((dr = astar_pts[killer].downr) > -1) { */
+ if (dr >= 0 && dr < nrows && dc >= 0 && dc < ncols) { /* if ((dr = astar_pts[killer].downr) > -1) { */
value = wat[this_index];
down_index = SEG_INDEX(wat_seg, dr, dc);
@@ -431,8 +433,8 @@
if (atanb_flag) {
sum_contour += contour[ct_dir];
tci_div += get_slope_tci(ele, alt[nbr_index],
- dist_to_nbr[ct_dir]) *
- weight[ct_dir];
+ dist_to_nbr[ct_dir])
+ * weight[ct_dir];
}
valued = wat[nbr_index];
@@ -481,7 +483,7 @@
if (atanb_flag) {
sum_contour = contour[np_side];
tci_div = get_slope_tci(ele, alt[down_index],
- dist_to_nbr[np_side]);
+ dist_to_nbr[np_side]);
}
}
/* topographic wetness index ln(a / tan(beta)) and
@@ -488,16 +490,16 @@
* stream power index a * tan(beta) */
if (atanb_flag) {
sca[this_index] = fabs(wat[this_index]) *
- (cell_size / sum_contour);
+ (cell_size / sum_contour);
tanb[this_index] = tci_div;
}
}
}
if (workedon)
- G_warning(n_("MFD: A * path already processed when distributing flow: %d of %d cell",
- "MFD: A * path already processed when distributing flow: %d of %d cells",
- do_points),
- workedon, do_points);
+ G_warning(n_
+ ("MFD: A * path already processed when distributing flow: %d of %d cell",
+ "MFD: A * path already processed when distributing flow: %d of %d cells",
+ do_points), workedon, do_points);
G_message(_("SECTION 3b: Adjusting drainage directions."));
@@ -514,7 +516,7 @@
}
else
dr = dc = -1;
- if (dr >= 0 && dr < nrows && dc >= 0 && dc < ncols) { /* if ((dr = astar_pts[killer].downr) > -1) { */
+ if (dr >= 0 && dr < nrows && dc >= 0 && dc < ncols) { /* if ((dr = astar_pts[killer].downr) > -1) { */
value = wat[this_index];
down_index = SEG_INDEX(wat_seg, dr, dc);
@@ -548,8 +550,7 @@
valued = wat[nbr_index];
ele_nbr = alt[nbr_index];
edge = Rast_is_c_null_value(&ele_nbr);
- if ((ABS(valued) + 0.5) >= threshold &&
- ele_nbr > ele)
+ if ((ABS(valued) + 0.5) >= threshold && ele_nbr > ele)
stream_cells++;
is_worked = !(FLAG_GET(worked, r_nbr, c_nbr));
@@ -579,7 +580,7 @@
}
continue;
}
-
+
/* update asp */
if (dr != r_max || dc != c_max) {
aspect = drain[r - r_max + 1][c - c_max + 1];
Modified: grass/trunk/raster/r.watershed/ram/do_flatarea.c
===================================================================
--- grass/trunk/raster/r.watershed/ram/do_flatarea.c 2018-08-07 21:10:33 UTC (rev 73060)
+++ grass/trunk/raster/r.watershed/ram/do_flatarea.c 2018-08-07 21:29:35 UTC (rev 73061)
@@ -1,3 +1,4 @@
+
/**********************************************************************
*
* flat area beautification after Garbrecht and Martz (1997)
@@ -56,7 +57,8 @@
G_fatal_error(_("Beautify flat areas: priority queue error"));
}
- struct pq_node *n = (struct pq_node *) G_malloc(sizeof(struct pq_node));
+ struct pq_node *n = (struct pq_node *)G_malloc(sizeof(struct pq_node));
+
n->next = NULL;
n->idx = -1;
q->last->next = n;
@@ -100,7 +102,8 @@
return 0;
}
-struct orders {
+struct orders
+{
int index, uphill, downhill;
char flag;
};
@@ -109,14 +112,15 @@
{
struct orders *oa = (struct orders *)a;
struct orders *ob = (struct orders *)b;
-
+
return (oa->index < ob->index ? -1 : (oa->index > ob->index));
}
+
/*
* return 0 if nothing was modidied
* return 1 if elevation was modified
*/
-int do_flatarea(int index, CELL ele, CELL *alt_org, CELL *alt_new)
+int do_flatarea(int index, CELL ele, CELL * alt_org, CELL * alt_new)
{
int upr, upc, r, c, ct_dir;
CELL is_in_list, is_worked, this_in_list;
@@ -130,7 +134,8 @@
struct pq *down_pq = pq_create();
struct orders inc_order, *order_found, *nbr_order_found;
- struct RB_TREE *order_tree = rbtree_create(cmp_orders, sizeof(struct orders));
+ struct RB_TREE *order_tree =
+ rbtree_create(cmp_orders, sizeof(struct orders));
pq_add(index, down_pq);
pq_add(index, up_pq);
@@ -175,7 +180,8 @@
inc_order.index = index_up;
inc_order.flag = 0;
/* not yet added to queue */
- if ((order_found = rbtree_find(order_tree, &inc_order)) == NULL) {
+ if ((order_found =
+ rbtree_find(order_tree, &inc_order)) == NULL) {
n_flat_cells++;
/* add to down queue if not yet in there */
@@ -203,9 +209,9 @@
return 0;
}
-
+
G_debug(2, "%d flat cells, %d cells in tree, %d start cells",
- n_flat_cells, (int)order_tree->count, counter);
+ n_flat_cells, (int)order_tree->count, counter);
pq_destroy(down_pq);
down_pq = pq_create();
@@ -233,7 +239,7 @@
if (last_order > uphill_order)
G_warning(_("queue error: last uphill order %d > current uphill order %d"),
- last_order, uphill_order);
+ last_order, uphill_order);
/* debug */
if (uphill_order == -1)
@@ -262,7 +268,8 @@
if (ele_nbr == ele && !is_worked) {
inc_order.index = index_up;
- if ((nbr_order_found = rbtree_find(order_tree, &inc_order)) == NULL) {
+ if ((nbr_order_found =
+ rbtree_find(order_tree, &inc_order)) == NULL) {
G_fatal_error(_("flat cell escaped in uphill correction"));
}
@@ -314,7 +321,7 @@
if (last_order > downhill_order)
G_warning(_("queue error: last downhill order %d > current downhill order %d"),
- last_order, downhill_order);
+ last_order, downhill_order);
/* debug */
if (downhill_order == -1)
@@ -340,12 +347,13 @@
if (ele_nbr == ele && !is_worked) {
inc_order.index = index_up;
- if ((nbr_order_found = rbtree_find(order_tree, &inc_order)) == NULL)
+ if ((nbr_order_found =
+ rbtree_find(order_tree, &inc_order)) == NULL)
G_fatal_error(_("flat cell escaped in downhill correction"));
/* not yet added to queue */
if (nbr_order_found->downhill == -1) {
-
+
/* add to down queue */
pq_add(index_up, down_pq);
/* set nbr downhill order = current downhill order + 1 */
@@ -396,7 +404,9 @@
uphill_order = 0;
}
alt_new[index_doer] +=
- (uphill_order + (double)(max_downhill_order - downhill_order) / 2.0 + 0.5) / 2.0 + 0.5;
+ (uphill_order +
+ (double)(max_downhill_order - downhill_order) / 2.0 +
+ 0.5) / 2.0 + 0.5;
/* check all neighbours, breadth first search */
for (ct_dir = 0; ct_dir < sides; ct_dir++) {
@@ -413,13 +423,15 @@
if (ele_nbr == ele && !is_worked) {
inc_order.index = index_up;
- if ((nbr_order_found = rbtree_find(order_tree, &inc_order)) == NULL)
+ if ((nbr_order_found =
+ rbtree_find(order_tree, &inc_order)) == NULL)
G_fatal_error(_("flat cell escaped in adjustment"));
/* not yet added to queue */
if (nbr_order_found->flag == 0) {
if (is_in_list)
- G_warning("adjustment: in_list cell should be in queue");
+ G_warning
+ ("adjustment: in_list cell should be in queue");
/* add to up queue */
pq_add(index_up, up_pq);
nbr_order_found->flag = 1;
@@ -433,6 +445,6 @@
pq_destroy(up_pq);
pq_destroy(down_pq);
rbtree_destroy(order_tree);
-
+
return 1;
}
Modified: grass/trunk/raster/r.watershed/ram/find_pour.c
===================================================================
--- grass/trunk/raster/r.watershed/ram/find_pour.c 2018-08-07 21:10:33 UTC (rev 73060)
+++ grass/trunk/raster/r.watershed/ram/find_pour.c 2018-08-07 21:29:35 UTC (rev 73061)
@@ -7,7 +7,7 @@
CELL old_elev, basin_num;
ocs_alloced = 2 * bas_thres;
- ocs = (OC_STACK *)G_malloc(ocs_alloced * sizeof(OC_STACK));
+ ocs = (OC_STACK *) G_malloc(ocs_alloced * sizeof(OC_STACK));
basin_num = 0;
stream_length = old_elev = 0;
Modified: grass/trunk/raster/r.watershed/ram/init_vars.c
===================================================================
--- grass/trunk/raster/r.watershed/ram/init_vars.c 2018-08-07 21:10:33 UTC (rev 73060)
+++ grass/trunk/raster/r.watershed/ram/init_vars.c 2018-08-07 21:29:35 UTC (rev 73061)
@@ -70,8 +70,8 @@
else if (sscanf(argv[r], "ar=%s", arm_name) == 1)
arm_flag++;
/* slope length
- else if (sscanf(argv[r], "sl=%[^\n]", sl_name) == 1)
- sl_flag++; */
+ else if (sscanf(argv[r], "sl=%[^\n]", sl_name) == 1)
+ sl_flag++; */
else if (sscanf(argv[r], "length_slope=%s", ls_name) == 1)
ls_flag++;
else if (sscanf(argv[r], "slope_steepness=%s", sg_name) == 1)
@@ -85,7 +85,7 @@
}
}
/* slope deposition
- else if (sscanf (argv[r], "sd=%[^\n]", dep_name) == 1) dep_flag++; */
+ else if (sscanf (argv[r], "sd=%[^\n]", dep_name) == 1) dep_flag++; */
else if (sscanf(argv[r], "-%d", &sides) == 1) {
if (sides != 4)
usage(argv[0]);
@@ -150,14 +150,14 @@
wat =
(DCELL *) G_malloc(sizeof(DCELL) *
size_array(&wat_seg, nrows, ncols));
-
+
sca = tanb = NULL;
atanb_flag = 0;
if (tci_flag || spi_flag) {
sca = (DCELL *) G_malloc(sizeof(DCELL) *
- size_array(&wat_seg, nrows, ncols));
+ size_array(&wat_seg, nrows, ncols));
tanb = (DCELL *) G_malloc(sizeof(DCELL) *
- size_array(&wat_seg, nrows, ncols));
+ size_array(&wat_seg, nrows, ncols));
atanb_flag = 1;
}
@@ -166,7 +166,8 @@
if (er_flag) {
r_h =
- (CELL *) G_malloc(sizeof(CELL) * size_array(&r_h_seg, nrows, ncols));
+ (CELL *) G_malloc(sizeof(CELL) *
+ size_array(&r_h_seg, nrows, ncols));
}
swale = flag_create(nrows, ncols);
@@ -181,7 +182,7 @@
elebuf = Rast_allocate_buf(ele_map_type);
if (ele_map_type == FCELL_TYPE || ele_map_type == DCELL_TYPE)
- ele_scale = 1000; /* should be enough to do the trick */
+ ele_scale = 1000; /* should be enough to do the trick */
if (flat_flag)
ele_scale = 10000;
@@ -210,16 +211,16 @@
}
else {
if (ele_map_type == CELL_TYPE) {
- alt_value = *((CELL *)ptr);
+ alt_value = *((CELL *) ptr);
alt_value *= ele_scale;
}
else if (ele_map_type == FCELL_TYPE) {
- dvalue = *((FCELL *)ptr);
+ dvalue = *((FCELL *) ptr);
dvalue *= ele_scale;
alt_value = ele_round(dvalue);
}
else if (ele_map_type == DCELL_TYPE) {
- dvalue = *((DCELL *)ptr);
+ dvalue = *((DCELL *) ptr);
dvalue *= ele_scale;
alt_value = ele_round(dvalue);
}
@@ -302,7 +303,7 @@
sizeof(double));
}
- astar_pts = (int *) G_malloc((do_points + 1) * sizeof(int));
+ astar_pts = (int *)G_malloc((do_points + 1) * sizeof(int));
/* heap_index will track astar_pts in ternary min-heap */
/* heap_index is one-based */
@@ -330,8 +331,7 @@
asp_value = asp[seg_idx];
if (er_flag)
s_l[seg_idx] = half_res;
- if (r == 0 || c == 0 || r == nrows - 1 ||
- c == ncols - 1) {
+ if (r == 0 || c == 0 || r == nrows - 1 || c == ncols - 1) {
wat_value = wat[seg_idx];
if (wat_value > 0)
wat[seg_idx] = -wat_value;
Modified: grass/trunk/raster/r.watershed/ram/main.c
===================================================================
--- grass/trunk/raster/r.watershed/ram/main.c 2018-08-07 21:10:33 UTC (rev 73060)
+++ grass/trunk/raster/r.watershed/ram/main.c 2018-08-07 21:29:35 UTC (rev 73061)
@@ -49,6 +49,7 @@
int updrain[3][3] = { {3, 2, 1}, {4, 0, 8}, {5, 6, 7} };
int nextdr[8] = { 1, -1, 0, 0, -1, 1, 1, -1 };
int nextdc[8] = { 0, 0, -1, 1, 1, -1, 1, -1 };
+
char ele_name[GNAME_MAX], pit_name[GNAME_MAX];
char run_name[GNAME_MAX], ob_name[GNAME_MAX];
char ril_name[GNAME_MAX], dep_name[GNAME_MAX];
@@ -57,7 +58,8 @@
thr_name[8];
char ls_name[GNAME_MAX], st_name[GNAME_MAX], sl_name[GNAME_MAX],
sg_name[GNAME_MAX];
-char wat_name[GNAME_MAX], asp_name[GNAME_MAX], tci_name[GNAME_MAX], spi_name[GNAME_MAX];
+char wat_name[GNAME_MAX], asp_name[GNAME_MAX], tci_name[GNAME_MAX],
+ spi_name[GNAME_MAX];
char arm_name[GNAME_MAX], dis_name[GNAME_MAX];
char ele_flag, pit_flag, run_flag, dis_flag, ob_flag, flat_flag;
char wat_flag, asp_flag, arm_flag, ril_flag, dep_flag;
Modified: grass/trunk/raster/r.watershed/ram/no_stream.c
===================================================================
--- grass/trunk/raster/r.watershed/ram/no_stream.c 2018-08-07 21:10:33 UTC (rev 73060)
+++ grass/trunk/raster/r.watershed/ram/no_stream.c 2018-08-07 21:29:35 UTC (rev 73061)
@@ -53,7 +53,7 @@
else
stream_length += diag;
}
- else { /* downdir == 4,8 */
+ else { /* downdir == 4,8 */
if (asp_value == 4 || asp_value == 8)
stream_length += window.ew_res;
else
@@ -69,7 +69,7 @@
if (aspect == drain[rr][cc]) {
thisdir = updrain[rr][cc];
switch (haf_basin_side
- (updir, (int) downdir, thisdir)) {
+ (updir, (int)downdir, thisdir)) {
case LEFT:
overland_cells(r, c, basin_num, basin_num - 1,
&new_ele);
Modified: grass/trunk/raster/r.watershed/ram/over_cells.c
===================================================================
--- grass/trunk/raster/r.watershed/ram/over_cells.c 2018-08-07 21:10:33 UTC (rev 73060)
+++ grass/trunk/raster/r.watershed/ram/over_cells.c 2018-08-07 21:29:35 UTC (rev 73061)
@@ -2,7 +2,8 @@
#define BIGNEG -9999999
int
-overland_cells_recursive(int row, int col, CELL basin_num, CELL haf_num, CELL * hih_ele)
+overland_cells_recursive(int row, int col, CELL basin_num, CELL haf_num,
+ CELL * hih_ele)
{
int r, rr, c, cc;
CELL new_ele, new_max_ele, value;
@@ -23,15 +24,15 @@
}
}
/*
- if (arm_flag) {
- if (new_max_ele == BIGNEG) {
- *hih_ele = alt[SEG_INDEX(alt_seg, row, col)];
- }
- else {
- *hih_ele = new_max_ele;
- }
- }
- */
+ if (arm_flag) {
+ if (new_max_ele == BIGNEG) {
+ *hih_ele = alt[SEG_INDEX(alt_seg, row, col)];
+ }
+ else {
+ *hih_ele = new_max_ele;
+ }
+ }
+ */
return 0;
}
@@ -66,13 +67,16 @@
if (asp[idx] == drain[rr][cc]) {
if (top >= ocs_alloced) {
ocs_alloced += bas_thres;
- ocs = (OC_STACK *)G_realloc(ocs, ocs_alloced * sizeof(OC_STACK));
+ ocs =
+ (OC_STACK *) G_realloc(ocs,
+ ocs_alloced *
+ sizeof(OC_STACK));
}
ocs[top].row = r;
ocs[top].col = c;
bas[idx] = basin_num;
haf[idx] = haf_num;
-
+
top++;
}
}
@@ -81,15 +85,15 @@
}
/*
- if (arm_flag) {
- if (new_max_ele == BIGNEG) {
- cseg_get(&alt, hih_ele, row, col);
- }
- else {
- *hih_ele = new_max_ele;
- }
- }
- */
+ if (arm_flag) {
+ if (new_max_ele == BIGNEG) {
+ cseg_get(&alt, hih_ele, row, col);
+ }
+ else {
+ *hih_ele = new_max_ele;
+ }
+ }
+ */
return 0;
}
Modified: grass/trunk/raster/r.watershed/ram/split_str.c
===================================================================
--- grass/trunk/raster/r.watershed/ram/split_str.c 2018-08-07 21:10:33 UTC (rev 73060)
+++ grass/trunk/raster/r.watershed/ram/split_str.c 2018-08-07 21:29:35 UTC (rev 73061)
@@ -36,8 +36,7 @@
}
if (doit) {
thisdir = updrain[rr][cc];
- switch (haf_basin_side
- (updir, (int) downdir, thisdir)) {
+ switch (haf_basin_side(updir, (int)downdir, thisdir)) {
case LEFT:
overland_cells(r, c, basin_num, basin_num - 1,
&new_elev);
Modified: grass/trunk/raster/r.watershed/seg/bseg_get.c
===================================================================
--- grass/trunk/raster/r.watershed/seg/bseg_get.c 2018-08-07 21:10:33 UTC (rev 73060)
+++ grass/trunk/raster/r.watershed/seg/bseg_get.c 2018-08-07 21:29:35 UTC (rev 73061)
@@ -11,7 +11,7 @@
return 0;
}
-int bseg_get_old(BSEG * bseg, CELL *value, int row, int col)
+int bseg_get_old(BSEG * bseg, CELL * value, int row, int col)
{
CELL x;
Modified: grass/trunk/raster/r.watershed/seg/bseg_read.c
===================================================================
--- grass/trunk/raster/r.watershed/seg/bseg_read.c 2018-08-07 21:10:33 UTC (rev 73060)
+++ grass/trunk/raster/r.watershed/seg/bseg_read.c 2018-08-07 21:29:35 UTC (rev 73061)
@@ -21,7 +21,7 @@
for (row = 0; row < nrows; row++) {
Rast_get_c_row(map_fd, buffer, row);
for (col = ncols; col >= 0; col--) {
- cbuf = (char) buffer[col];
+ cbuf = (char)buffer[col];
bseg_put(bseg, &cbuf, row, col);
}
}
Modified: grass/trunk/raster/r.watershed/seg/bseg_write.c
===================================================================
--- grass/trunk/raster/r.watershed/seg/bseg_write.c 2018-08-07 21:10:33 UTC (rev 73060)
+++ grass/trunk/raster/r.watershed/seg/bseg_write.c 2018-08-07 21:29:35 UTC (rev 73061)
@@ -22,7 +22,7 @@
}
Rast_put_row(map_fd, buffer, CELL_TYPE);
}
- G_percent(row, nrows, 1); /* finish it */
+ G_percent(row, nrows, 1); /* finish it */
G_free(buffer);
Rast_close(map_fd);
return 0;
Modified: grass/trunk/raster/r.watershed/seg/close_maps.c
===================================================================
--- grass/trunk/raster/r.watershed/seg/close_maps.c 2018-08-07 21:10:33 UTC (rev 73060)
+++ grass/trunk/raster/r.watershed/seg/close_maps.c 2018-08-07 21:29:35 UTC (rev 73061)
@@ -24,7 +24,8 @@
seg_flush(&watalt);
if (abs_acc) {
G_message("Writing out only positive flow accumulation values.");
- G_message("Cells with a likely underestimate for flow accumulation can no longer be identified.");
+ G_message
+ ("Cells with a likely underestimate for flow accumulation can no longer be identified.");
}
fd = Rast_open_new(wat_name, DCELL_TYPE);
@@ -50,7 +51,7 @@
}
Rast_put_row(fd, dbuf, DCELL_TYPE);
}
- G_percent(r, nrows, 1); /* finish it */
+ G_percent(r, nrows, 1); /* finish it */
Rast_close(fd);
G_free(wabuf);
@@ -75,51 +76,51 @@
clr_min = min - 1;
clr_max = -stddev - 1;
Rast_add_d_color_rule(&clr_min, 0, 0, 0, &clr_max, 0,
- 0, 0, &colors);
+ 0, 0, &colors);
}
clr_min = -stddev - 1.;
clr_max = -1. * exp(lstddev * 0.75);
Rast_add_d_color_rule(&clr_min, 0, 0, 0, &clr_max, 0,
- 0, 255, &colors);
+ 0, 255, &colors);
clr_min = clr_max;
clr_max = -1. * exp(lstddev * 0.5);
Rast_add_d_color_rule(&clr_min, 0, 0, 255, &clr_max, 0,
- 255, 255, &colors);
+ 255, 255, &colors);
clr_min = clr_max;
clr_max = -1. * exp(lstddev * 0.35);
Rast_add_d_color_rule(&clr_min, 0, 255, 255, &clr_max, 0,
- 255, 0, &colors);
+ 255, 0, &colors);
clr_min = clr_max;
clr_max = -1.;
Rast_add_d_color_rule(&clr_min, 0, 255, 0, &clr_max, 255,
- 255, 0, &colors);
+ 255, 0, &colors);
}
clr_min = -1.;
clr_max = 1.;
Rast_add_d_color_rule(&clr_min, 255, 255, 0, &clr_max, 255,
- 255, 0, &colors);
+ 255, 0, &colors);
clr_min = 1;
clr_max = exp(lstddev * 0.35);
Rast_add_d_color_rule(&clr_min, 255, 255, 0, &clr_max, 0,
- 255, 0, &colors);
+ 255, 0, &colors);
clr_min = clr_max;
clr_max = exp(lstddev * 0.5);
Rast_add_d_color_rule(&clr_min, 0, 255, 0, &clr_max, 0,
- 255, 255, &colors);
+ 255, 255, &colors);
clr_min = clr_max;
clr_max = exp(lstddev * 0.75);
Rast_add_d_color_rule(&clr_min, 0, 255, 255, &clr_max, 0,
- 0, 255, &colors);
+ 0, 255, &colors);
clr_min = clr_max;
clr_max = stddev + 1.;
Rast_add_d_color_rule(&clr_min, 0, 0, 255, &clr_max, 0, 0,
- 0, &colors);
+ 0, &colors);
if (max > 0 && max > stddev + 1) {
clr_min = stddev + 1;
clr_max = max + 1;
Rast_add_d_color_rule(&clr_min, 0, 0, 0, &clr_max, 0, 0, 0,
- &colors);
+ &colors);
}
Rast_write_colors(wat_name, this_mapset, &colors);
}
@@ -166,7 +167,7 @@
for (c = 0; c < ncols; c++) {
seg_get(&atanb, (char *)&sca_tanb, r, c);
if (!Rast_is_d_null_value(&sca_tanb.tanb)) {
-
+
if (tci_flag) {
dvalue = log(sca_tanb.sca / sca_tanb.tanb);
dbuf[c] = dvalue;
@@ -186,7 +187,7 @@
if (spi_flag)
Rast_put_row(fd2, dbuf2, DCELL_TYPE);
}
- G_percent(r, nrows, 1); /* finish it */
+ G_percent(r, nrows, 1); /* finish it */
G_free(wabuf);
seg_close(&atanb);
@@ -196,7 +197,8 @@
G_free(dbuf);
mean = sum / do_points;
- stddev = sqrt((sum_sqr - (sum + sum / do_points)) / (do_points - 1));
+ stddev =
+ sqrt((sum_sqr - (sum + sum / do_points)) / (do_points - 1));
G_debug(1, "stddev: %f", stddev);
/* set nice color rules: yellow, green, cyan, blue, black */
@@ -214,31 +216,31 @@
clr_min = min - 1;
clr_max = mean - 0.5 * stddev;
Rast_add_d_color_rule(&clr_min, 255, 255, 0, &clr_max, 255,
- 255, 0, &colors);
+ 255, 0, &colors);
}
clr_min = mean - 0.5 * stddev;
clr_max = mean - 0.2 * stddev;
Rast_add_d_color_rule(&clr_min, 255, 255, 0, &clr_max, 0,
- 255, 0, &colors);
+ 255, 0, &colors);
clr_min = clr_max;
clr_max = mean + 0.2 * stddev;
Rast_add_d_color_rule(&clr_min, 0, 255, 0, &clr_max, 0,
- 255, 255, &colors);
+ 255, 255, &colors);
clr_min = clr_max;
clr_max = mean + 0.6 * stddev;
Rast_add_d_color_rule(&clr_min, 0, 255, 255, &clr_max, 0,
- 0, 255, &colors);
+ 0, 255, &colors);
clr_min = clr_max;
clr_max = mean + 1. * stddev;
Rast_add_d_color_rule(&clr_min, 0, 0, 255, &clr_max, 0, 0,
- 0, &colors);
+ 0, &colors);
if (max > 0 && max > clr_max) {
clr_min = clr_max;
clr_max = max + 1;
Rast_add_d_color_rule(&clr_min, 0, 0, 0, &clr_max, 0, 0,
- 0, &colors);
+ 0, &colors);
}
Rast_write_colors(tci_name, this_mapset, &colors);
}
@@ -247,7 +249,9 @@
G_free(dbuf2);
mean = sum2 / do_points;
- stddev = sqrt((sum_sqr2 - (sum2 + sum2 / do_points)) / (do_points - 1));
+ stddev =
+ sqrt((sum_sqr2 - (sum2 + sum2 / do_points)) / (do_points -
+ 1));
G_debug(1, "stddev: %f", stddev);
/* set nice color rules: yellow, green, cyan, blue, black */
@@ -265,31 +269,31 @@
clr_min = min - 1;
clr_max = mean - 0.5 * stddev;
Rast_add_d_color_rule(&clr_min, 255, 255, 0, &clr_max, 255,
- 255, 0, &colors);
+ 255, 0, &colors);
}
clr_min = mean - 0.5 * stddev;
clr_max = mean - 0.2 * stddev;
Rast_add_d_color_rule(&clr_min, 255, 255, 0, &clr_max, 0,
- 255, 0, &colors);
+ 255, 0, &colors);
clr_min = clr_max;
clr_max = mean + 0.2 * stddev;
Rast_add_d_color_rule(&clr_min, 0, 255, 0, &clr_max, 0,
- 255, 255, &colors);
+ 255, 255, &colors);
clr_min = clr_max;
clr_max = mean + 0.6 * stddev;
Rast_add_d_color_rule(&clr_min, 0, 255, 255, &clr_max, 0,
- 0, 255, &colors);
+ 0, 255, &colors);
clr_min = clr_max;
clr_max = mean + 1. * stddev;
Rast_add_d_color_rule(&clr_min, 0, 0, 255, &clr_max, 0, 0,
- 0, &colors);
+ 0, &colors);
if (max > 0 && max > clr_max) {
clr_min = clr_max;
clr_max = max + 1;
Rast_add_d_color_rule(&clr_min, 0, 0, 0, &clr_max, 0, 0,
- 0, &colors);
+ 0, &colors);
}
Rast_write_colors(spi_name, this_mapset, &colors);
}
@@ -338,7 +342,7 @@
dseg_put(&s_l, &max_length, r, c);
}
}
- G_percent(r, nrows, 1); /* finish it */
+ G_percent(r, nrows, 1); /* finish it */
dseg_write_cellfile(&s_l, sl_name);
}
if (sl_flag || ls_flag || sg_flag)
Modified: grass/trunk/raster/r.watershed/seg/close_maps2.c
===================================================================
--- grass/trunk/raster/r.watershed/seg/close_maps2.c 2018-08-07 21:10:33 UTC (rev 73060)
+++ grass/trunk/raster/r.watershed/seg/close_maps2.c 2018-08-07 21:29:35 UTC (rev 73061)
@@ -21,14 +21,14 @@
theseg = &haf;
max = -9;
/*
- for (r = 0; r < nrows; r++) {
- for (c = 0; c < ncols; c++) {
- cseg_get(theseg, &value, r, c);
- if (value > max)
- max = value;
- }
- }
- */
+ for (r = 0; r < nrows; r++) {
+ for (c = 0; c < ncols; c++) {
+ cseg_get(theseg, &value, r, c);
+ if (value > max)
+ max = value;
+ }
+ }
+ */
max = n_basins;
G_debug(1, "%d basins created", max);
Rast_init_colors(&colors);
@@ -50,7 +50,8 @@
for (bl = 90 + incr; bl <= 255; bl += 40) {
flag = 1;
while (flag) {
- Rast_get_c_color(&r, &red, &green, &blue, &colors);
+ Rast_get_c_color(&r, &red, &green, &blue,
+ &colors);
/* if existing rule is too dark then append a new
rule to override it */
if ((blue * .11 + red * .30 + green * .59) <
@@ -98,7 +99,7 @@
}
Rast_put_row(map_fd, cellrow, CELL_TYPE);
}
- G_percent(nrows, nrows, 1); /* finish it */
+ G_percent(nrows, nrows, 1); /* finish it */
G_free(cellrow);
Rast_close(map_fd);
Rast_write_colors(seg_name, this_mapset, &colors);
Modified: grass/trunk/raster/r.watershed/seg/cseg_open.c
===================================================================
--- grass/trunk/raster/r.watershed/seg/cseg_open.c 2018-08-07 21:10:33 UTC (rev 73060)
+++ grass/trunk/raster/r.watershed/seg/cseg_open.c 2018-08-07 21:29:35 UTC (rev 73061)
@@ -22,8 +22,8 @@
}
if (0 >
(errflag =
- Segment_format(fd, Rast_window_rows(), Rast_window_cols(), srows, scols,
- sizeof(CELL)))) {
+ Segment_format(fd, Rast_window_rows(), Rast_window_cols(), srows,
+ scols, sizeof(CELL)))) {
close(fd);
unlink(filename);
if (errflag == -1) {
Modified: grass/trunk/raster/r.watershed/seg/cseg_read.c
===================================================================
--- grass/trunk/raster/r.watershed/seg/cseg_read.c 2018-08-07 21:10:33 UTC (rev 73060)
+++ grass/trunk/raster/r.watershed/seg/cseg_read.c 2018-08-07 21:29:35 UTC (rev 73061)
@@ -23,7 +23,7 @@
G_free(buffer);
Rast_close(map_fd);
G_warning("%s(): unable to segment put row for [%s] in [%s]",
- me, map_name, mapset);
+ me, map_name, mapset);
return (-1);
}
}
Modified: grass/trunk/raster/r.watershed/seg/cseg_write.c
===================================================================
--- grass/trunk/raster/r.watershed/seg/cseg_write.c 2018-08-07 21:10:33 UTC (rev 73060)
+++ grass/trunk/raster/r.watershed/seg/cseg_write.c 2018-08-07 21:29:35 UTC (rev 73061)
@@ -18,7 +18,7 @@
Segment_get_row(&(cseg->seg), buffer, row);
Rast_put_row(map_fd, buffer, CELL_TYPE);
}
- G_percent(row, nrows, 1); /* finish it */
+ G_percent(row, nrows, 1); /* finish it */
G_free(buffer);
Rast_close(map_fd);
return 0;
Modified: grass/trunk/raster/r.watershed/seg/def_basin.c
===================================================================
--- grass/trunk/raster/r.watershed/seg/def_basin.c 2018-08-07 21:10:33 UTC (rev 73060)
+++ grass/trunk/raster/r.watershed/seg/def_basin.c 2018-08-07 21:29:35 UTC (rev 73061)
@@ -56,7 +56,7 @@
if (direction == drain[rr][cc]) {
thisdir = updrain[rr][cc];
switch (haf_basin_side
- (oldupdir, (int) downdir, thisdir)) {
+ (oldupdir, (int)downdir, thisdir)) {
case LEFT:
overland_cells(r, c, basin_num, basin_num - 1,
&new_elev);
@@ -88,7 +88,7 @@
else
stream_length += window.ew_res;
}
- else { /* sides == 4 */
+ else { /* sides == 4 */
seg_get(&aspflag, (char *)&af, row, col);
asp_value = af.asp;
Modified: grass/trunk/raster/r.watershed/seg/do_astar.c
===================================================================
--- grass/trunk/raster/r.watershed/seg/do_astar.c 2018-08-07 21:10:33 UTC (rev 73060)
+++ grass/trunk/raster/r.watershed/seg/do_astar.c 2018-08-07 21:29:35 UTC (rev 73061)
@@ -47,7 +47,8 @@
if (heap_size == 0)
G_fatal_error(_("No seeds for A* Search"));
- G_debug(1, "heap size %"PRI_OFF_T", points %"PRI_OFF_T, heap_size, do_points);
+ G_debug(1, "heap size %" PRI_OFF_T ", points %" PRI_OFF_T, heap_size,
+ do_points);
count = 0;
@@ -61,7 +62,7 @@
r = heap_p.pnt.r;
c = heap_p.pnt.c;
- G_debug(3, "heap size %"PRI_OFF_T", r %d, c %d", heap_size, r, c);
+ G_debug(3, "heap size %" PRI_OFF_T ", r %d, c %d", heap_size, r, c);
alt_val = heap_p.ele;
@@ -143,8 +144,9 @@
seg_put(&aspflag, (char *)&af, r, c);
}
if (doer != -1)
- G_fatal_error(_("bug in A* Search: doer %"PRI_OFF_T" heap size %"PRI_OFF_T" count %"PRI_OFF_T),
- doer, heap_size, count);
+ G_fatal_error(_("bug in A* Search: doer %" PRI_OFF_T " heap size %"
+ PRI_OFF_T " count %" PRI_OFF_T), doer, heap_size,
+ count);
seg_close(&search_heap);
@@ -263,8 +265,7 @@
return root_p;
}
-double get_slope(int r, int c, int downr, int downc, CELL ele,
- CELL downe)
+double get_slope(int r, int c, int downr, int downc, CELL ele, CELL downe)
{
double slope;
Modified: grass/trunk/raster/r.watershed/seg/do_cum.c
===================================================================
--- grass/trunk/raster/r.watershed/seg/do_cum.c 2018-08-07 21:10:33 UTC (rev 73060)
+++ grass/trunk/raster/r.watershed/seg/do_cum.c 2018-08-07 21:29:35 UTC (rev 73061)
@@ -17,22 +17,23 @@
/* EW Dist at North edge */
ew_dist1 = G_distance(window.east, window.north,
- window.west, window.north);
+ window.west, window.north);
/* EW Dist at Center */
ew_dist2 = G_distance(window.east, (window.north + window.south) / 2.,
- window.west, (window.north + window.south) / 2.);
+ window.west,
+ (window.north + window.south) / 2.);
/* EW Dist at South Edge */
ew_dist3 = G_distance(window.east, window.south,
- window.west, window.south);
+ window.west, window.south);
/* NS Dist at East edge */
ns_dist1 = G_distance(window.east, window.north,
- window.east, window.south);
+ window.east, window.south);
/* NS Dist at Center */
ns_dist2 = G_distance((window.west + window.east) / 2., window.north,
- (window.west + window.east) / 2., window.south);
+ (window.west + window.east) / 2., window.south);
/* NS Dist at West edge */
ns_dist3 = G_distance(window.west, window.north,
- window.west, window.south);
+ window.west, window.south);
ew_res = (ew_dist1 + ew_dist2 + ew_dist3) / (3 * window.cols);
ns_res = (ns_dist1 + ns_dist2 + ns_dist3) / (3 * window.rows);
@@ -41,7 +42,7 @@
ns_res = window.ns_res;
ew_res = window.ew_res;
}
-
+
for (ct_dir = 0; ct_dir < sides; ct_dir++) {
/* get r, c (r_nbr, c_nbr) for neighbours */
r_nbr = nextdr[ct_dir];
@@ -79,7 +80,8 @@
G_debug(1, "ew contour: %.4f", contour[2]);
contour[4] = (ew_res - contour[0]);
contour[5] = (ns_res - contour[2]);
- contour[7] = sqrt(contour[4] * contour[4] + contour[5] * contour[5]) / 2.;
+ contour[7] =
+ sqrt(contour[4] * contour[4] + contour[5] * contour[5]) / 2.;
G_debug(1, "diag contour: %.4f", contour[7]);
contour[4] = contour[5] = contour[6] = contour[7];
}
@@ -199,11 +201,10 @@
/* topographic wetness index ln(a / tan(beta)) and
* stream power index a * tan(beta) */
if (atanb_flag) {
- sca_tanb.sca = fabs(wa.wat) *
- (cell_size / contour[np_side]);
+ sca_tanb.sca = fabs(wa.wat) * (cell_size / contour[np_side]);
sca_tanb.tanb = get_slope_tci(wa.ele, wadown.ele,
- dist_to_nbr[np_side]);
+ dist_to_nbr[np_side]);
seg_put(&atanb, (char *)&sca_tanb, r, c);
}
@@ -216,7 +217,8 @@
}
else {
seg_get(&aspflag, (char *)&afdown, dr, dc);
- if (er_flag && !is_swale && !FLAG_GET(afdown.flag, RUSLEBLOCKFLAG))
+ if (er_flag && !is_swale &&
+ !FLAG_GET(afdown.flag, RUSLEBLOCKFLAG))
slope_length(r, c, dr, dc);
}
}
@@ -311,12 +313,12 @@
dist_to_nbr = (double *)G_malloc(sides * sizeof(double));
weight = (double *)G_malloc(sides * sizeof(double));
contour = (double *)G_malloc(sides * sizeof(double));
-
+
cell_size = get_dist(dist_to_nbr, contour);
flag_nbr = (char *)G_malloc(sides * sizeof(char));
- wat_nbr = (DCELL *)G_malloc(sides * sizeof(DCELL));
- ele_nbr = (CELL *)G_malloc(sides * sizeof(CELL));
+ wat_nbr = (DCELL *) G_malloc(sides * sizeof(DCELL));
+ ele_nbr = (CELL *) G_malloc(sides * sizeof(CELL));
workedon = 0;
@@ -342,7 +344,7 @@
/* WORKEDFLAG has been set during A* Search
* reversed meaning here: 0 = done, 1 = not yet done */
FLAG_UNSET(af.flag, WORKEDFLAG);
-
+
if (dr >= 0 && dr < nrows && dc >= 0 && dc < ncols) {
r_max = dr;
c_max = dc;
@@ -390,8 +392,8 @@
if (ele_nbr[ct_dir] < ele) {
weight[ct_dir] =
mfd_pow(((ele -
- ele_nbr[ct_dir]) / dist_to_nbr[ct_dir]),
- c_fac);
+ ele_nbr[ct_dir]) /
+ dist_to_nbr[ct_dir]), c_fac);
}
if (ele_nbr[ct_dir] == ele) {
weight[ct_dir] =
@@ -463,9 +465,10 @@
if (atanb_flag) {
sum_contour += contour[ct_dir];
- sca_tanb.tanb += get_slope_tci(ele, ele_nbr[ct_dir],
- dist_to_nbr[ct_dir]) *
- weight[ct_dir];
+ sca_tanb.tanb +=
+ get_slope_tci(ele, ele_nbr[ct_dir],
+ dist_to_nbr[ct_dir]) *
+ weight[ct_dir];
}
if (value > 0) {
@@ -478,7 +481,9 @@
if (wat_nbr[ct_dir] < 0)
wat_nbr[ct_dir] += value * weight[ct_dir];
else
- wat_nbr[ct_dir] = value * weight[ct_dir] - wat_nbr[ct_dir];
+ wat_nbr[ct_dir] =
+ value * weight[ct_dir] -
+ wat_nbr[ct_dir];
}
valued = wat_nbr[ct_dir];
wa.wat = valued;
@@ -494,10 +499,10 @@
/* adjust main drainage direction to A* path if possible */
/*if (fabs(wat_nbr[np_side]) >= max_acc) {
- max_acc = fabs(wat_nbr[np_side]);
- r_max = dr;
- c_max = dc;
- } */
+ max_acc = fabs(wat_nbr[np_side]);
+ r_max = dr;
+ c_max = dc;
+ } */
if (fabs(prop - 1.0) > 5E-6f) {
G_warning(_("MFD: cumulative proportion of flow distribution not 1.0 but %f"),
@@ -526,7 +531,7 @@
if (atanb_flag) {
sum_contour = contour[np_side];
sca_tanb.tanb = get_slope_tci(ele, ele_nbr[np_side],
- dist_to_nbr[np_side]);
+ dist_to_nbr[np_side]);
}
}
@@ -540,10 +545,10 @@
seg_put(&aspflag, (char *)&af, r, c);
}
G_percent(do_points, do_points, 1); /* finish it */
-
+
if (workedon)
- G_warning(_("MFD: A * path already processed when distributing flow: %d of %"PRI_OFF_T" cells"),
- workedon, do_points);
+ G_warning(_("MFD: A * path already processed when distributing flow: %d of %"
+ PRI_OFF_T " cells"), workedon, do_points);
G_message(_("SECTION 3b: Adjusting drainage directions."));
@@ -563,7 +568,7 @@
dr = dc = -1;
FLAG_SET(af.flag, WORKEDFLAG);
-
+
if (dr >= 0 && dr < nrows && dc >= 0 && dc < ncols) {
r_max = dr;
c_max = dc;
@@ -606,7 +611,7 @@
if (is_swale)
swale_cells++;
if ((ABS(wat_nbr[ct_dir]) + 0.5) >= threshold &&
- ele_nbr[ct_dir] > ele)
+ ele_nbr[ct_dir] > ele)
stream_cells++;
if (!(FLAG_GET(flag_nbr[ct_dir], WORKEDFLAG))) {
@@ -658,7 +663,8 @@
seg_put(&aspflag, (char *)&afdown, r_max, c_max);
}
else {
- if (er_flag && !is_swale && !FLAG_GET(af.flag, RUSLEBLOCKFLAG))
+ if (er_flag && !is_swale &&
+ !FLAG_GET(af.flag, RUSLEBLOCKFLAG))
slope_length(r, c, r_max, c_max);
}
}
@@ -666,7 +672,7 @@
}
seg_close(&astar_pts);
-
+
G_free(dist_to_nbr);
G_free(weight);
G_free(wat_nbr);
Modified: grass/trunk/raster/r.watershed/seg/dseg_open.c
===================================================================
--- grass/trunk/raster/r.watershed/seg/dseg_open.c 2018-08-07 21:10:33 UTC (rev 73060)
+++ grass/trunk/raster/r.watershed/seg/dseg_open.c 2018-08-07 21:29:35 UTC (rev 73061)
@@ -23,8 +23,8 @@
}
if (0 >
(errflag =
- Segment_format(fd, Rast_window_rows(), Rast_window_cols(), srows, scols,
- sizeof(double)))) {
+ Segment_format(fd, Rast_window_rows(), Rast_window_cols(), srows,
+ scols, sizeof(double)))) {
close(fd);
unlink(filename);
if (errflag == -1) {
Modified: grass/trunk/raster/r.watershed/seg/dseg_read.c
===================================================================
--- grass/trunk/raster/r.watershed/seg/dseg_read.c 2018-08-07 21:10:33 UTC (rev 73060)
+++ grass/trunk/raster/r.watershed/seg/dseg_read.c 2018-08-07 21:29:35 UTC (rev 73061)
@@ -24,7 +24,7 @@
G_free(dbuffer);
Rast_close(map_fd);
G_warning("%s(): unable to segment put row for [%s] in [%s]",
- me, map_name, mapset);
+ me, map_name, mapset);
return (-1);
}
}
Modified: grass/trunk/raster/r.watershed/seg/dseg_write.c
===================================================================
--- grass/trunk/raster/r.watershed/seg/dseg_write.c 2018-08-07 21:10:33 UTC (rev 73060)
+++ grass/trunk/raster/r.watershed/seg/dseg_write.c 2018-08-07 21:29:35 UTC (rev 73061)
@@ -19,7 +19,7 @@
Segment_get_row(&(dseg->seg), (DCELL *) dbuffer, row);
Rast_put_row(map_fd, dbuffer, DCELL_TYPE);
}
- G_percent(row, nrows, 1); /* finish it */
+ G_percent(row, nrows, 1); /* finish it */
G_free(dbuffer);
Rast_close(map_fd);
return 0;
Modified: grass/trunk/raster/r.watershed/seg/find_pour.c
===================================================================
--- grass/trunk/raster/r.watershed/seg/find_pour.c 2018-08-07 21:10:33 UTC (rev 73060)
+++ grass/trunk/raster/r.watershed/seg/find_pour.c 2018-08-07 21:29:35 UTC (rev 73061)
@@ -10,7 +10,7 @@
char is_swale;
ocs_alloced = 2 * bas_thres;
- ocs = (OC_STACK *)G_malloc(ocs_alloced * sizeof(OC_STACK));
+ ocs = (OC_STACK *) G_malloc(ocs_alloced * sizeof(OC_STACK));
basin_num = 0;
Rast_set_c_null_value(&no_basin, 1);
@@ -42,7 +42,7 @@
else {
stream_length = 0.0;
}
- seg_get(&watalt, (char *) &wa, row, col);
+ seg_get(&watalt, (char *)&wa, row, col);
old_elev = wa.ele;
}
basin_num =
Modified: grass/trunk/raster/r.watershed/seg/init_vars.c
===================================================================
--- grass/trunk/raster/r.watershed/seg/init_vars.c 2018-08-07 21:10:33 UTC (rev 73060)
+++ grass/trunk/raster/r.watershed/seg/init_vars.c 2018-08-07 21:29:35 UTC (rev 73061)
@@ -11,7 +11,8 @@
{
int r, c;
int ele_fd, wat_fd, fd = -1;
- int seg_rows, seg_cols, num_cseg_total, num_open_segs, num_open_array_segs;
+ int seg_rows, seg_cols, num_cseg_total, num_open_segs,
+ num_open_array_segs;
double memory_divisor, heap_mem, seg_factor, disk_space;
/* int page_block, num_cseg; */
@@ -80,8 +81,8 @@
else if (sscanf(argv[r], "ar=%s", arm_name) == 1)
arm_flag++;
/* slope length
- else if (sscanf(argv[r], "slope_length=%s", sl_name) == 1)
- sl_flag++; */
+ else if (sscanf(argv[r], "slope_length=%s", sl_name) == 1)
+ sl_flag++; */
else if (sscanf(argv[r], "slope_steepness=%s", sg_name) == 1)
sg_flag++;
else if (sscanf(argv[r], "length_slope=%s", ls_name) == 1)
@@ -96,7 +97,7 @@
}
}
/* slope deposition
- else if (sscanf (argv[r], "sd=%[^\n]", dep_name) == 1) dep_flag++; */
+ else if (sscanf (argv[r], "sd=%[^\n]", dep_name) == 1) dep_flag++; */
else if (sscanf(argv[r], "-%d", &sides) == 1) {
if (sides != 4)
usage(argv[0]);
@@ -136,10 +137,10 @@
if (tci_flag || spi_flag)
atanb_flag = 1;
- G_message(n_("SECTION 1 beginning: Initiating Variables. %d section total.",
- "SECTION 1 beginning: Initiating Variables. %d sections total.",
- tot_parts),
- tot_parts);
+ G_message(n_
+ ("SECTION 1 beginning: Initiating Variables. %d section total.",
+ "SECTION 1 beginning: Initiating Variables. %d sections total.",
+ tot_parts), tot_parts);
this_mapset = G_mapset();
/* for sd factor
@@ -173,7 +174,7 @@
if (segs_mb < 3.0) {
segs_mb = 3;
G_warning(_("Maximum memory to be used was smaller than 3 MB,"
- " set to 3 MB."));
+ " set to 3 MB."));
}
/* balance segment files */
@@ -219,7 +220,7 @@
disk_space += 8;
}
}
-
+
/* KB -> MB */
memory_divisor = memory_divisor * seg_factor / 1024.;
disk_space = disk_space * seg_factor / 1024.;
@@ -249,24 +250,28 @@
disk_space *= num_cseg_total;
if (disk_space < 1024.0)
- G_verbose_message(_("Will need up to %.2f MB of disk space"), disk_space);
+ G_verbose_message(_("Will need up to %.2f MB of disk space"),
+ disk_space);
else
G_verbose_message(_("Will need up to %.2f GB (%.0f MB) of disk space"),
- disk_space / 1024.0, disk_space);
+ disk_space / 1024.0, disk_space);
if (er_flag) {
cseg_open(&r_h, seg_rows, seg_cols, num_open_segs);
cseg_read_cell(&r_h, ele_name, "");
}
-
+
/* read elevation input and mark NULL/masked cells */
/* scattered access: alt, watalt, bitflags, asp */
- seg_open(&watalt, nrows, ncols, seg_rows, seg_cols, num_open_segs * 2, sizeof(WAT_ALT));
- seg_open(&aspflag, nrows, ncols, seg_rows, seg_cols, num_open_segs * 4, sizeof(ASP_FLAG));
+ seg_open(&watalt, nrows, ncols, seg_rows, seg_cols, num_open_segs * 2,
+ sizeof(WAT_ALT));
+ seg_open(&aspflag, nrows, ncols, seg_rows, seg_cols, num_open_segs * 4,
+ sizeof(ASP_FLAG));
if (atanb_flag) {
- seg_open(&atanb, nrows, ncols, seg_rows, seg_cols, num_open_segs, sizeof(A_TANB));
+ seg_open(&atanb, nrows, ncols, seg_rows, seg_cols, num_open_segs,
+ sizeof(A_TANB));
Rast_set_d_null_value(&sca_tanb.sca, 1);
Rast_set_d_null_value(&sca_tanb.tanb, 1);
}
@@ -280,7 +285,7 @@
afbuf = G_malloc(ncols * sizeof(ASP_FLAG));
if (ele_map_type == FCELL_TYPE || ele_map_type == DCELL_TYPE)
- ele_scale = 1000; /* should be enough to do the trick */
+ ele_scale = 1000; /* should be enough to do the trick */
/* initial flow accumulation */
if (run_flag) {
@@ -300,7 +305,8 @@
/* read elevation input and mark NULL/masked cells */
G_message("SECTION 1a: Mark masked and NULL cells");
MASK_flag = 0;
- do_points = (GW_LARGE_INT) nrows * ncols;
+ do_points = (GW_LARGE_INT) nrows *ncols;
+
for (r = 0; r < nrows; r++) {
G_percent(r, nrows, 1);
Rast_get_row(ele_fd, elebuf, r, ele_map_type);
@@ -310,7 +316,7 @@
Rast_get_row(wat_fd, watbuf, r, wat_map_type);
watptr = watbuf;
}
-
+
for (c = 0; c < ncols; c++) {
afbuf[c].flag = 0;
@@ -328,15 +334,15 @@
}
else {
if (ele_map_type == CELL_TYPE) {
- alt_value = *((CELL *)ptr);
+ alt_value = *((CELL *) ptr);
}
else if (ele_map_type == FCELL_TYPE) {
- dvalue = *((FCELL *)ptr);
+ dvalue = *((FCELL *) ptr);
dvalue *= ele_scale;
alt_value = ele_round(dvalue);
}
else if (ele_map_type == DCELL_TYPE) {
- dvalue = *((DCELL *)ptr);
+ dvalue = *((DCELL *) ptr);
dvalue *= ele_scale;
alt_value = ele_round(dvalue);
}
@@ -344,17 +350,17 @@
/* flow accumulation */
if (run_flag) {
if (Rast_is_null_value(watptr, wat_map_type)) {
- wat_value = 0; /* ok ? */
+ wat_value = 0; /* ok ? */
}
else {
if (wat_map_type == CELL_TYPE) {
- wat_value = *((CELL *)watptr);
+ wat_value = *((CELL *) watptr);
}
else if (wat_map_type == FCELL_TYPE) {
- wat_value = *((FCELL *)watptr);
+ wat_value = *((FCELL *) watptr);
}
else if (wat_map_type == DCELL_TYPE) {
- wat_value = *((DCELL *)watptr);
+ wat_value = *((DCELL *) watptr);
}
}
}
@@ -373,18 +379,18 @@
watptr = G_incr_void_ptr(watptr, wat_size);
}
}
- seg_put_row(&watalt, (char *) wabuf, r);
+ seg_put_row(&watalt, (char *)wabuf, r);
seg_put_row(&aspflag, (char *)afbuf, r);
-
+
if (er_flag) {
cseg_put_row(&r_h, alt_value_buf, r);
}
}
- G_percent(nrows, nrows, 1); /* finish it */
+ G_percent(nrows, nrows, 1); /* finish it */
Rast_close(ele_fd);
G_free(wabuf);
G_free(afbuf);
-
+
if (run_flag) {
Rast_close(wat_fd);
G_free(watbuf);
@@ -391,7 +397,7 @@
}
MASK_flag = (do_points < nrows * ncols);
-
+
/* do RUSLE */
if (er_flag) {
if (ob_flag) {
@@ -409,7 +415,7 @@
}
}
}
- G_percent(nrows, nrows, 1); /* finish it */
+ G_percent(nrows, nrows, 1); /* finish it */
Rast_close(fd);
G_free(buf);
}
@@ -418,7 +424,7 @@
dseg_open(&ril, seg_rows, seg_cols, num_open_segs);
dseg_read_cell(&ril, ril_name, "");
}
-
+
/* dseg_open(&slp, SROW, SCOL, num_open_segs); */
dseg_open(&s_l, seg_rows, seg_cols, num_open_segs);
@@ -440,7 +446,7 @@
num_open_array_segs = num_cseg_total;
if (num_open_array_segs < 1)
num_open_array_segs = 1;
-
+
seg_open(&astar_pts, 1, do_points, 1, seg_cols, num_open_array_segs,
sizeof(POINT));
@@ -454,7 +460,8 @@
if (do_points % seg_cols > 0)
num_cseg_total++;
/* no need to have more segments open than exist */
- num_open_array_segs = (1 << 20) * heap_mem / (seg_cols * sizeof(HEAP_PNT));
+ num_open_array_segs =
+ (1 << 20) * heap_mem / (seg_cols * sizeof(HEAP_PNT));
if (num_open_array_segs > num_cseg_total)
num_open_array_segs = num_cseg_total;
if (num_open_array_segs < 2)
@@ -461,7 +468,7 @@
num_open_array_segs = 2;
G_debug(1, "A* search heap open segments %d, total %d",
- num_open_array_segs, num_cseg_total);
+ num_open_array_segs, num_cseg_total);
/* the search heap will not hold more than 5% of all points at any given time ? */
/* chances are good that the heap will fit into one large segment */
seg_open(&search_heap, 1, do_points + 1, 1, seg_cols,
@@ -490,8 +497,7 @@
if (er_flag)
dseg_put(&s_l, &half_res, r, c);
asp_value = af.asp;
- if (r == 0 || c == 0 || r == nrows - 1 ||
- c == ncols - 1) {
+ if (r == 0 || c == 0 || r == nrows - 1 || c == ncols - 1) {
/* dseg_get(&wat, &wat_value, r, c); */
seg_get(&watalt, (char *)&wa, r, c);
wat_value = wa.wat;
@@ -558,8 +564,8 @@
}
}
- } /* end non-NULL cell */
- } /* end column */
+ } /* end non-NULL cell */
+ } /* end column */
}
G_percent(r, nrows, 1); /* finish it */
Modified: grass/trunk/raster/r.watershed/seg/main.c
===================================================================
--- grass/trunk/raster/r.watershed/seg/main.c 2018-08-07 21:10:33 UTC (rev 73060)
+++ grass/trunk/raster/r.watershed/seg/main.c 2018-08-07 21:29:35 UTC (rev 73061)
@@ -49,6 +49,7 @@
char updrain[3][3] = { {3, 2, 1}, {4, 0, 8}, {5, 6, 7} };
int nextdr[8] = { 1, -1, 0, 0, -1, 1, 1, -1 };
int nextdc[8] = { 0, 0, -1, 1, 1, -1, 1, -1 };
+
char ele_name[GNAME_MAX], pit_name[GNAME_MAX];
char run_name[GNAME_MAX], ob_name[GNAME_MAX];
char ril_name[GNAME_MAX], dep_name[GNAME_MAX];
@@ -71,7 +72,7 @@
int main(int argc, char *argv[])
{
int num_open_segs;
-
+
zero = 0;
one = 1;
d_zero = 0.0;
Modified: grass/trunk/raster/r.watershed/seg/no_stream.c
===================================================================
--- grass/trunk/raster/r.watershed/seg/no_stream.c 2018-08-07 21:10:33 UTC (rev 73060)
+++ grass/trunk/raster/r.watershed/seg/no_stream.c 2018-08-07 21:29:35 UTC (rev 73061)
@@ -62,7 +62,7 @@
else
stream_length += diag;
}
- else { /* downdir == 4,8 */
+ else { /* downdir == 4,8 */
if (asp_value == 4 || asp_value == 8)
stream_length += window.ew_res;
@@ -80,8 +80,7 @@
if (aspect == drain[rr][cc]) {
thisdir = updrain[rr][cc];
switch (haf_basin_side(updir,
- (int) downdir,
- thisdir)) {
+ (int)downdir, thisdir)) {
case RITE:
overland_cells(r, c, basin_num, basin_num,
&new_ele);
@@ -108,7 +107,7 @@
}
else {
if (arm_flag) {
- seg_get(&watalt, (char *) &wa, row, col);
+ seg_get(&watalt, (char *)&wa, row, col);
hih_ele = wa.ele;
slope = (hih_ele - old_elev) / stream_length;
if (slope < MIN_SLOPE)
Modified: grass/trunk/raster/r.watershed/seg/over_cells.c
===================================================================
--- grass/trunk/raster/r.watershed/seg/over_cells.c 2018-08-07 21:10:33 UTC (rev 73060)
+++ grass/trunk/raster/r.watershed/seg/over_cells.c 2018-08-07 21:29:35 UTC (rev 73061)
@@ -2,7 +2,8 @@
#define BIGNEG -9999999
int
-overland_cells_recursive(int row, int col, CELL basin_num, CELL haf_num, CELL * hih_ele)
+overland_cells_recursive(int row, int col, CELL basin_num, CELL haf_num,
+ CELL * hih_ele)
{
int r, rr, c, cc;
CELL new_ele, new_max_ele;
@@ -26,15 +27,15 @@
}
}
/*
- if (arm_flag) {
- if (new_max_ele == BIGNEG) {
- cseg_get(&alt, hih_ele, row, col);
- }
- else {
- *hih_ele = new_max_ele;
- }
- }
- */
+ if (arm_flag) {
+ if (new_max_ele == BIGNEG) {
+ cseg_get(&alt, hih_ele, row, col);
+ }
+ else {
+ *hih_ele = new_max_ele;
+ }
+ }
+ */
return 0;
}
@@ -72,7 +73,10 @@
if (aspect == drain[rr][cc]) {
if (top >= ocs_alloced) {
ocs_alloced += bas_thres;
- ocs = (OC_STACK *)G_realloc(ocs, ocs_alloced * sizeof(OC_STACK));
+ ocs =
+ (OC_STACK *) G_realloc(ocs,
+ ocs_alloced *
+ sizeof(OC_STACK));
}
ocs[top].row = r;
ocs[top].col = c;
@@ -83,19 +87,19 @@
}
}
}
-
+
}
/*
- if (arm_flag) {
- if (new_max_ele == BIGNEG) {
- cseg_get(&alt, hih_ele, row, col);
- }
- else {
- *hih_ele = new_max_ele;
- }
- }
- */
+ if (arm_flag) {
+ if (new_max_ele == BIGNEG) {
+ cseg_get(&alt, hih_ele, row, col);
+ }
+ else {
+ *hih_ele = new_max_ele;
+ }
+ }
+ */
return 0;
}
Modified: grass/trunk/raster/r.watershed/seg/sg_factor.c
===================================================================
--- grass/trunk/raster/r.watershed/seg/sg_factor.c 2018-08-07 21:10:33 UTC (rev 73060)
+++ grass/trunk/raster/r.watershed/seg/sg_factor.c 2018-08-07 21:29:35 UTC (rev 73061)
@@ -18,8 +18,8 @@
seg_get(&aspflag, (char *)&af, r, c);
if (FLAG_GET(af.flag, NULLFLAG))
continue;
-
- seg_get(&watalt, (char *) &wa, r, c);
+
+ seg_get(&watalt, (char *)&wa, r, c);
low_elev = wa.ele;
cseg_get(&r_h, &hih_elev, r, c);
dseg_get(&s_l, &length, r, c);
Modified: grass/trunk/raster/r.watershed/seg/slope_len.c
===================================================================
--- grass/trunk/raster/r.watershed/seg/slope_len.c 2018-08-07 21:10:33 UTC (rev 73060)
+++ grass/trunk/raster/r.watershed/seg/slope_len.c 2018-08-07 21:29:35 UTC (rev 73061)
@@ -20,9 +20,9 @@
else
top_ls += res;
dseg_put(&s_l, &top_ls, r, c);
- seg_get(&watalt, (char *) &wa, r, c);
+ seg_get(&watalt, (char *)&wa, r, c);
top_alt = wa.ele;
- seg_get(&watalt, (char *) &wa, dr, dc);
+ seg_get(&watalt, (char *)&wa, dr, dc);
bot_alt = wa.ele;
if (top_alt > bot_alt) {
dseg_get(&s_l, &bot_ls, dr, dc);
Modified: grass/trunk/raster/r.watershed/seg/split_str.c
===================================================================
--- grass/trunk/raster/r.watershed/seg/split_str.c 2018-08-07 21:10:33 UTC (rev 73060)
+++ grass/trunk/raster/r.watershed/seg/split_str.c 2018-08-07 21:29:35 UTC (rev 73061)
@@ -41,8 +41,7 @@
}
if (doit) {
thisdir = updrain[rr][cc];
- switch (haf_basin_side
- (updir, (int) downdir, thisdir)) {
+ switch (haf_basin_side(updir, (int)downdir, thisdir)) {
case LEFT:
overland_cells(r, c, basin_num, basin_num - 1,
&new_elev);
@@ -68,7 +67,7 @@
}
old_basin = basin_num;
if (arm_flag) {
- seg_get(&watalt, (char *) &wa, row, col);
+ seg_get(&watalt, (char *)&wa, row, col);
new_elev = wa.ele;
if ((slope = (new_elev - old_elev) / stream_length) < MIN_SLOPE)
slope = MIN_SLOPE;
Modified: grass/trunk/raster/r.watershed/seg/sseg_open.c
===================================================================
--- grass/trunk/raster/r.watershed/seg/sseg_open.c 2018-08-07 21:10:33 UTC (rev 73060)
+++ grass/trunk/raster/r.watershed/seg/sseg_open.c 2018-08-07 21:29:35 UTC (rev 73061)
@@ -5,8 +5,8 @@
#include "Gwater.h"
int
-seg_open(SSEG * sseg, GW_LARGE_INT nrows, GW_LARGE_INT ncols, int row_in_seg, int col_in_seg,
- int nsegs_in_memory, int size_struct)
+seg_open(SSEG * sseg, GW_LARGE_INT nrows, GW_LARGE_INT ncols, int row_in_seg,
+ int col_in_seg, int nsegs_in_memory, int size_struct)
{
char *filename;
int errflag;
More information about the grass-commit
mailing list