[GRASS-SVN] r33373 -
grass/branches/develbranch_6/raster/wildfire/r.spread
svn_grass at osgeo.org
svn_grass at osgeo.org
Wed Sep 10 07:04:25 EDT 2008
Author: hamish
Date: 2008-09-10 07:04:25 -0400 (Wed, 10 Sep 2008)
New Revision: 33373
Modified:
grass/branches/develbranch_6/raster/wildfire/r.spread/collect_ori.c
grass/branches/develbranch_6/raster/wildfire/r.spread/main.c
grass/branches/develbranch_6/raster/wildfire/r.spread/select_linksB.c
grass/branches/develbranch_6/raster/wildfire/r.spread/spot.c
Log:
DEBUG to G_debug, fix broken % literal
Modified: grass/branches/develbranch_6/raster/wildfire/r.spread/collect_ori.c
===================================================================
--- grass/branches/develbranch_6/raster/wildfire/r.spread/collect_ori.c 2008-09-10 10:33:37 UTC (rev 33372)
+++ grass/branches/develbranch_6/raster/wildfire/r.spread/collect_ori.c 2008-09-10 11:04:25 UTC (rev 33373)
@@ -80,7 +80,7 @@
DATA(map_x_out, row, col) = col;
if (y_out)
DATA(map_y_out, row, col) = row;
- /*DEBUG printf("\norigin: row=%d col=%d\n", row, col); */
+ G_debug(4, "origin: row=%d col=%d", row, col);
if (display)
draw_a_burning_cell(row, col);
}
Modified: grass/branches/develbranch_6/raster/wildfire/r.spread/main.c
===================================================================
--- grass/branches/develbranch_6/raster/wildfire/r.spread/main.c 2008-09-10 10:33:37 UTC (rev 33372)
+++ grass/branches/develbranch_6/raster/wildfire/r.spread/main.c 2008-09-10 11:04:25 UTC (rev 33373)
@@ -39,8 +39,6 @@
#define DATA(map, r, c) (map)[(r) * ncols + (c)]
-/*#define DEBUG */
-
CELL range_min, range_max;
CELL *cell;
CELL *x_cell;
@@ -572,23 +570,15 @@
heap_len = 0;
G_message(_("Reading %s..."), start_layer);
-#ifdef DEBUG
- printf("Collecting origins...");
-#endif
+ G_debug(1, "Collecting origins...");
collect_ori(start_fd);
-#ifdef DEBUG
- printf("Done\n");
-#endif
+ G_debug(1, "Done");
/* Major computation of spread time */
-#ifdef DEBUG
- printf("Spreading...");
-#endif
+ G_debug(1, "Spreading...");
spread();
-#ifdef DEBUG
- printf("Done\n");
-#endif
+ G_debug(1, "Done");
/* Open cumulative cost layer (and x, y direction layers) for writing */
Modified: grass/branches/develbranch_6/raster/wildfire/r.spread/select_linksB.c
===================================================================
--- grass/branches/develbranch_6/raster/wildfire/r.spread/select_linksB.c 2008-09-10 10:33:37 UTC (rev 33372)
+++ grass/branches/develbranch_6/raster/wildfire/r.spread/select_linksB.c 2008-09-10 11:04:25 UTC (rev 33373)
@@ -118,70 +118,52 @@
continue;
for (col = pres_cell->col - w; col <= pres_cell->col + e; col++) {
-#ifdef DEBUG
- printf
- ("(%d, %d) max=%d base=%d dir=%d least=%d n=%d s=%d e=%d w=%d base=%d BARRIER=%d\n",
+
+ G_debug(4,
+ "(%d, %d) max=%d base=%d dir=%d least=%d n=%d s=%d e=%d w=%d base=%d BARRIER=%d",
row, col, ros_max, ros_base, dir, least, n, s, e, w,
DATA(map_base, row, col), BARRIER);
-#endif
if (col < 0 || col >= ncols) /*outside e,w */
continue;
-#ifdef DEBUG
- printf
- ("(%d, %d) max=%d base=%d dir=%d least=%d n=%d s=%d e=%d w=%d base=%d BARRIER=%d\n",
+
+ G_debug(4,
+ "(%d, %d) max=%d base=%d dir=%d least=%d n=%d s=%d e=%d w=%d base=%d BARRIER=%d",
row, col, ros_max, ros_base, dir, least, n, s, e, w,
DATA(map_base, row, col), BARRIER);
-#endif
if (row == pres_cell->row && col == pres_cell->col)
continue; /*spread cell */
-#ifdef DEBUG
- printf
- ("(%d, %d) max=%d base=%d dir=%d least=%d n=%d s=%d e=%d w=%d base=%d BARRIER=%d\n",
+
+ G_debug(4,
+ "(%d, %d) max=%d base=%d dir=%d least=%d n=%d s=%d e=%d w=%d base=%d BARRIER=%d",
row, col, ros_max, ros_base, dir, least, n, s, e, w,
DATA(map_base, row, col), BARRIER);
-#endif
if (DATA(map_visit, row, col)) /*visited? */
continue;
-#ifdef DEBUG
- printf
- ("(%d, %d) max=%d base=%d dir=%d least=%d n=%d s=%d e=%d w=%d base=%d BARRIER=%d\n",
+
+ G_debug(4,
+ "(%d, %d) max=%d base=%d dir=%d least=%d n=%d s=%d e=%d w=%d base=%d BARRIER=%d",
row, col, ros_max, ros_base, dir, least, n, s, e, w,
DATA(map_base, row, col), BARRIER);
-#endif
if (DATA(map_base, row, col) == BARRIER) /*barriers */
continue;
-#ifdef DEBUG
- printf
- ("(%d, %d) max=%d base=%d dir=%d least=%d n=%d s=%d e=%d w=%d\n",
+ G_debug(4,
+ "(%d, %d) max=%d base=%d dir=%d least=%d n=%d s=%d e=%d w=%d",
row, col, ros_max, ros_base, dir, least, n, s, e, w);
-#endif
angle =
atan2((double)(col - pres_cell->col),
(double)(pres_cell->row - row));
/*the polar (square) distance of enlarged ellipse */
polar_len =
- (1 /
- (1 -
- (1 - ros_base / (float)ros_max) * cos(angle -
- dir_angle))) * (1 /
- (1 -
- (1 -
- ros_base
- /
- (float)
- ros_max)
- *
- cos
- (angle
- -
- dir_angle)))
- + 2 * least * least;
+ (1 / (1 - (1 - ros_base / (float)ros_max)
+ * cos(angle - dir_angle))) *
+ (1 / (1 - (1 - ros_base / (float)ros_max) *
+ cos(angle - dir_angle))) + 2 * least * least;
/*the (square) distance to this cell */
distance =
Modified: grass/branches/develbranch_6/raster/wildfire/r.spread/spot.c
===================================================================
--- grass/branches/develbranch_6/raster/wildfire/r.spread/spot.c 2008-09-10 10:33:37 UTC (rev 33372)
+++ grass/branches/develbranch_6/raster/wildfire/r.spread/spot.c 2008-09-10 11:04:25 UTC (rev 33373)
@@ -54,7 +54,6 @@
#endif
#define DATA(map, r, c) (map)[(r) * ncols + (c)]
-/*#define DEBUG */
void spot(struct costHa *pres_cell, int dir /* direction of forward ROS */ )
{
@@ -77,10 +76,10 @@
/* Find the (cell) location spotting might reach */
land_dist = pick_dist(DATA(map_spotdist, pres_cell->row, pres_cell->col));
-#ifdef DEBUG
- printf("pres_cell(%d, %d): land_dist=%d\n", pres_cell->row,
+
+ G_debug(1, "pres_cell(%d, %d): land_dist=%d", pres_cell->row,
pres_cell->col, land_dist);
-#endif
+
land_distc = land_dist / (window.ns_res / 100); /* 100 fac due to cm */
if (land_distc < 2) /* no need for adjacent cells */
@@ -98,17 +97,17 @@
if (DATA(map_mois, row, col) > 17) /* too wet */
return;
-#ifdef DEBUG
- printf
- (" pre pick_ignite(): land_distc(%d, %d)=%d dir=%d PI=%.2f (dir\%360)*PI/180=%.2f\n",
- row, col, land_distc, dir, PI, (dir % 360) * PI / 180);
-#endif
+
+ G_debug(1,
+ " pre pick_ignite(): land_distc(%d, %d)=%d dir=%d PI=%.2f (dir%%360)*PI/180=%.2f",
+ row, col, land_distc, dir, PI, (dir % 360) * PI / 180);
+
if (pick_ignite(DATA(map_mois, row, col)) == 0) /* not success */
return;
-#ifdef DEBUG
- printf(" post pick_ignite(): land_distc(%d, %d)=%d \n", row, col,
- land_distc);
-#endif
+
+ G_debug(1, " post pick_ignite(): land_distc(%d, %d)=%d ",
+ row, col, land_distc);
+
/* travel time by spotting */
U = 0.305 * DATA(map_velocity, pres_cell->row, pres_cell->col);
@@ -124,10 +123,8 @@
min_cost = pres_cell->min_cost + spot_cost + Te;
/* update it to the to_cell */
-#ifdef DEBUG
- printf(" min_cost=%.2f: pres=%.2f spot=%.2f Te=%.2f\n",
+ G_debug(1, " min_cost=%.2f: pres=%.2f spot=%.2f Te=%.2f",
min_cost, pres_cell->min_cost, spot_cost, Te);
-#endif
update(pres_cell, row, col, (double)dir, min_cost);
}
More information about the grass-commit
mailing list