[GRASS-SVN] r43753 -
grass-addons/grass7/raster/r.stream/r.stream.stats
svn_grass at osgeo.org
svn_grass at osgeo.org
Fri Oct 1 07:14:01 EDT 2010
Author: jarekj71
Date: 2010-10-01 11:14:01 +0000 (Fri, 01 Oct 2010)
New Revision: 43753
Modified:
grass-addons/grass7/raster/r.stream/r.stream.stats/main.c
grass-addons/grass7/raster/r.stream/r.stream.stats/stats_prepare.c
grass-addons/grass7/raster/r.stream/r.stream.stats/stats_print.c
Log:
update
Modified: grass-addons/grass7/raster/r.stream/r.stream.stats/main.c
===================================================================
--- grass-addons/grass7/raster/r.stream/r.stream.stats/main.c 2010-10-01 11:09:46 UTC (rev 43752)
+++ grass-addons/grass7/raster/r.stream/r.stream.stats/main.c 2010-10-01 11:14:01 UTC (rev 43753)
@@ -53,7 +53,6 @@
/* initialize module */
module = G_define_module();
- G_add_keyword("Horton statisctics");
module->description =
_("Calculate Horton's statistics for Strahler and Horton ordered networks created with r.stream.");
G_add_keyword("Horton's statistics");
Modified: grass-addons/grass7/raster/r.stream/r.stream.stats/stats_prepare.c
===================================================================
--- grass-addons/grass7/raster/r.stream/r.stream.stats/stats_prepare.c 2010-10-01 11:09:46 UTC (rev 43752)
+++ grass-addons/grass7/raster/r.stream/r.stream.stats/stats_prepare.c 2010-10-01 11:14:01 UTC (rev 43753)
@@ -40,13 +40,10 @@
for (r = 0; r < nrows; ++r)
for (c = 0; c < ncols; ++c)
if (streams[r][c] > 0) {
-
- if (outlets_num > 2 * (out_max - 1))
- G_fatal_error(_
- ("Stream and direction maps probably do not match"));
- if (outlets_num > (out_max - 1))
- outlets = (POINT *)G_realloc(outlets,out_max*2*sizeof(POINT));
-
+ if (outlets_num > (out_max - 1)) {
+ out_max *= 2;
+ outlets = (POINT *) G_realloc(outlets, out_max * sizeof(POINT));
+ }
d = abs(dirs[r][c]);
if (NOT_IN_REGION(d))
next_stream = -1; /* border */
@@ -95,8 +92,8 @@
G_free(outlets);
return 0;
}
+/////
-
int seg_init_streams(SEGMENT* streams, SEGMENT* dirs, SEGMENT* elevation)
{
int d, i, j; /* d: direction, i: iteration */
@@ -113,12 +110,11 @@
for (r = 0; r < nrows; ++r)
for (c = 0; c < ncols; ++c) {
segment_get(streams,&streams_cell,r,c);
-
- if (outlets_num > 2 * (out_max - 1))
- G_fatal_error(_
- ("Stream and direction maps probably do not match"));
- if (outlets_num > (out_max - 1))
- outlets = (POINT *)G_realloc(outlets,out_max*2*sizeof(POINT));
+ if (streams_cell > 0) {
+ if (outlets_num > (out_max - 1)) {
+ out_max *= 2;
+ outlets = (POINT *) G_realloc(outlets, out_max * sizeof(POINT));
+ }
segment_get(dirs,&dirs_cell,r,c);
d = abs(dirs_cell);
@@ -145,9 +141,10 @@
outlets_num++;
+
}
} /* end if streams */
-
+ }
stat_streams = (STREAM *) G_malloc((outlets_num) * sizeof(STREAM));
Modified: grass-addons/grass7/raster/r.stream/r.stream.stats/stats_print.c
===================================================================
--- grass-addons/grass7/raster/r.stream/r.stream.stats/stats_print.c 2010-10-01 11:09:46 UTC (rev 43752)
+++ grass-addons/grass7/raster/r.stream/r.stream.stats/stats_print.c 2010-10-01 11:14:01 UTC (rev 43753)
@@ -4,7 +4,7 @@
{
int i;
-
+ fflush(stdout);
/* summary statistics */
fprintf(stdout, "\n");
fprintf(stdout, "Summary:\n");
@@ -95,9 +95,12 @@
ord_stats[i].drainage_density * 1000,
ord_stats[i].stream_frequency * 1000000);
}
+ fflush(stdout);
+ return 0;
}
int print_stats_total(void) {
+ fflush(stdout);
fprintf(stdout,"Catchment's characteristics (based on regresion): \n");
fprintf(stdout,"Max order: %d \n",stats_total.order);
fprintf(stdout,"Total number of streams: %d \n",stats_total.stream_num);
@@ -110,12 +113,14 @@
fprintf(stdout,"Area ratio: %2.4f \n",stats_total.reg_area_ratio);
fprintf(stdout,"Slope ratio: %2.4f \n",stats_total.reg_slope_ratio);
fprintf(stdout,"Gradient ratio: %2.4f \n",stats_total.reg_gradient_ratio);
+ fflush(stdout);
return 0;
}
int print_stats_orders(int order_max) {
int i;
+ fflush(stdout);
fprintf(stdout,"Order's summary: \n");
fprintf(stdout,"order,num_of_streams,avg_length,avg_area,avg_slope,avg_grad,avg_elev.diff,sum_length,sum_area\n");
@@ -131,5 +136,6 @@
ord_stats[i].sum_length / 1000,
ord_stats[i].sum_area / 1000000);
}
+ fflush(stdout);
return 0;
}
More information about the grass-commit
mailing list