[GRASS-SVN] r62559 - grass-addons/grass7/raster/r.stream.distance

svn_grass at osgeo.org svn_grass at osgeo.org
Sun Nov 2 14:16:26 PST 2014


Author: neteler
Date: 2014-11-02 14:16:25 -0800 (Sun, 02 Nov 2014)
New Revision: 62559

Modified:
   grass-addons/grass7/raster/r.stream.distance/distance_calc.c
   grass-addons/grass7/raster/r.stream.distance/distance_init.c
   grass-addons/grass7/raster/r.stream.distance/local_proto.h
   grass-addons/grass7/raster/r.stream.distance/local_vars.h
   grass-addons/grass7/raster/r.stream.distance/main.c
   grass-addons/grass7/raster/r.stream.distance/r.stream.distance.html
Log:
Addons: r.stream.distance: sync to trunk (r61206, r61261, r61262, r61263, r61556)

Modified: grass-addons/grass7/raster/r.stream.distance/distance_calc.c
===================================================================
--- grass-addons/grass7/raster/r.stream.distance/distance_calc.c	2014-11-02 22:13:05 UTC (rev 62558)
+++ grass-addons/grass7/raster/r.stream.distance/distance_calc.c	2014-11-02 22:16:25 UTC (rev 62559)
@@ -27,18 +27,18 @@
 }
 
 
-int ram_calculate_downstream(CELL ** dirs, FCELL ** distance,
-			     FCELL ** elevation, OUTLET outlet, int outs)
+int ram_calculate_downstream(CELL ** dirs, DCELL ** distance,
+			     DCELL ** elevation, OUTLET outlet, int outs)
 {
 
     int r, c, i, j;
     int next_r, next_c;
     POINT n_cell;
-    float cur_dist = 0;
-    float tmp_dist = 0;
-    float target_elev;		/* eleavation at stream or outlet */
-    float easting, northing;
-    float cell_easting, cell_northing;
+    double cur_dist = 0;
+    double tmp_dist = 0;
+    double target_elev;		/* eleavation at stream or outlet */
+    double easting, northing;
+    double cell_easting, cell_northing;
     struct Cell_head window;
 
     Rast_get_window(&window);
@@ -134,14 +134,14 @@
     int r, c, i, j;
     int next_r, next_c;
     POINT n_cell;
-    float cur_dist = 0;
-    float tmp_dist = 0;
-    float target_elev;		/* eleavation at stream or outlet */
-    float easting, northing;
-    float cell_easting, cell_northing;
+    double cur_dist = 0;
+    double tmp_dist = 0;
+    double target_elev;		/* eleavation at stream or outlet */
+    double easting, northing;
+    double cell_easting, cell_northing;
     CELL dirs_cell;
-    FCELL distance_cell, elevation_cell;
-    FCELL zero_cell = 0;
+    DCELL distance_cell, elevation_cell;
+    DCELL zero_cell = 0;
     struct Cell_head window;
 
     Rast_get_window(&window);
@@ -235,12 +235,12 @@
     return 0;
 }
 
-int ram_fill_basins(OUTLET outlet, FCELL ** distance, CELL ** dirs)
+int ram_fill_basins(OUTLET outlet, DCELL ** distance, CELL ** dirs)
 {
     /* fill empty spaces with zeros but leave -1 as a markers of NULL */
     int r, c, i, j;
     int next_r, next_c;
-    float stop, val;
+    double stop, val;
     POINT n_cell;
 
     tail = 0;
@@ -285,10 +285,10 @@
     /* fill empty spaces with zeros but leave -1 as a markers of NULL */
     int r, c, i, j;
     int next_r, next_c;
-    float stop, val;
+    double stop, val;
     POINT n_cell;
     CELL dirs_cell;
-    FCELL distance_cell;
+    DCELL distance_cell;
 
     tail = 0;
     head = -1;
@@ -331,29 +331,29 @@
     return 0;
 }
 
-int ram_calculate_upstream(FCELL ** distance, CELL ** dirs,
-			   FCELL ** elevation, FCELL ** tmp_elevation,
+int ram_calculate_upstream(DCELL ** distance, CELL ** dirs,
+			   DCELL ** elevation, DCELL ** tmp_elevation,
 			   int near)
 {
     int r, c;
     int next_r, next_c;
-    float easting, northing;
-    float cell_easting, cell_northing;
+    double easting, northing;
+    double cell_easting, cell_northing;
     int i, j, k, d;
     int done;
     int counter;
     int n_inits = 0;
-    float cur_dist;
+    double cur_dist;
     POINT *d_inits;
-    float tmp_dist = 0;
-    float target_elev = 0;
+    double tmp_dist = 0;
+    double target_elev = 0;
     size_t elevation_data_size;
     struct Cell_head window;
 
     Rast_get_window(&window);
 
     if (elevation) {
-	elevation_data_size = Rast_cell_size(FCELL_TYPE);
+	elevation_data_size = Rast_cell_size(DCELL_TYPE);
 	for (r = 0; r < nrows; ++r)
 	    memcpy(tmp_elevation[r], elevation[r],
 		   ncols * elevation_data_size);
@@ -472,27 +472,27 @@
 {
     int r, c;
     int next_r, next_c;
-    float easting, northing;
-    float cell_easting, cell_northing;
+    double easting, northing;
+    double cell_easting, cell_northing;
     int i, j, k, d, d_next;
-    FCELL minus_one_cell = -1;
-    FCELL zero_cell = 0;
+    DCELL minus_one_cell = -1;
+    DCELL zero_cell = 0;
     int done;
     int counter;
     int n_inits = 0;
-    float cur_dist;
+    double cur_dist;
     POINT *d_inits;
-    float tmp_dist = 0;
-    float target_elev = 0;
+    double tmp_dist = 0;
+    double target_elev = 0;
     CELL dirs_cell;
-    FCELL distance_cell, elevation_cell, tmp_elevation_cell;
+    DCELL distance_cell, elevation_cell, tmp_elevation_cell;
     /* size_t elevation_data_size; */
     struct Cell_head window;
 
     Rast_get_window(&window);
 
     if (elevation) {
-        /* elevation_data_size = Rast_cell_size(FCELL_TYPE); */
+        /* elevation_data_size = Rast_cell_size(DCELL_TYPE); */
 	for (r = 0; r < nrows; ++r)
 	    for (c = 0; c < ncols; ++c) {
 		Segment_get(elevation, &elevation_cell, r, c);

Modified: grass-addons/grass7/raster/r.stream.distance/distance_init.c
===================================================================
--- grass-addons/grass7/raster/r.stream.distance/distance_init.c	2014-11-02 22:13:05 UTC (rev 62558)
+++ grass-addons/grass7/raster/r.stream.distance/distance_init.c	2014-11-02 22:16:25 UTC (rev 62559)
@@ -126,13 +126,13 @@
     return outlets_num;
 }
 
-int ram_init_distance(CELL ** streams, FCELL ** distance, int outlets_num,
+int ram_init_distance(CELL ** streams, DCELL ** distance, int outlets_num,
 		      int outs)
 {
     int r, c, i;
     /* size_t data_size; 
 
-    data_size = Rast_cell_size(FCELL_TYPE);
+    data_size = Rast_cell_size(DCELL_TYPE);
     */
 
     if (!outs) {		/* stream mode */
@@ -157,9 +157,9 @@
 {
     int r, c, i;
     CELL streams_cell;
-    FCELL distance_cell;
-    FCELL minus_one_cell = -1;
-    FCELL zero_cell = 0;
+    DCELL distance_cell;
+    DCELL minus_one_cell = -1;
+    DCELL zero_cell = 0;
 
     if (!outs) {		/* stream mode */
 	for (r = 0; r < nrows; ++r)
@@ -180,7 +180,7 @@
     return 0;
 }
 
-int ram_prep_null_elevation(FCELL ** distance, FCELL ** elevation)
+int ram_prep_null_elevation(DCELL ** distance, DCELL ** elevation)
 {
 
     int r, c;
@@ -198,7 +198,7 @@
 int seg_prep_null_elevation(SEGMENT * distance, SEGMENT * elevation)
 {
     int r, c;
-    FCELL distance_cell;
+    DCELL distance_cell;
 
     for (r = 0; r < nrows; ++r)
 	for (c = 0; c < ncols; ++c) {

Modified: grass-addons/grass7/raster/r.stream.distance/local_proto.h
===================================================================
--- grass-addons/grass7/raster/r.stream.distance/local_proto.h	2014-11-02 22:13:05 UTC (rev 62558)
+++ grass-addons/grass7/raster/r.stream.distance/local_proto.h	2014-11-02 22:16:25 UTC (rev 62559)
@@ -3,17 +3,17 @@
 
 /* inits */
 int ram_find_outlets(CELL **streams, int number_of_streams, CELL **dirs, int subs, int outs);
-int ram_init_distance(CELL **streams, FCELL **distance, int outlets_num, int outs);
-int ram_prep_null_elevation(FCELL **distance, FCELL **elevation);
+int ram_init_distance(CELL **streams, DCELL **distance, int outlets_num, int outs);
+int ram_prep_null_elevation(DCELL **distance, DCELL **elevation);
 
 int seg_find_outlets(SEGMENT *streams, int number_of_streams, SEGMENT *dirs, int subs, int outs);
 int seg_prep_null_elevation(SEGMENT *distance, SEGMENT *elevation);
 int seg_init_distance(SEGMENT *streams, SEGMENT *distance, int outlets_num, int outs);
 
 /* calculate */
-int ram_calculate_downstream(CELL **dirs, FCELL **distance, FCELL **elevation, OUTLET outlet, int outs);
-int ram_fill_basins(OUTLET outlet, FCELL **distance, CELL **dirs);
-int ram_calculate_upstream(FCELL **distance, CELL **dirs, FCELL **elevation, FCELL **tmp_elevation, int near);
+int ram_calculate_downstream(CELL **dirs, DCELL **distance, DCELL **elevation, OUTLET outlet, int outs);
+int ram_fill_basins(OUTLET outlet, DCELL **distance, CELL **dirs);
+int ram_calculate_upstream(DCELL **distance, CELL **dirs, DCELL **elevation, DCELL **tmp_elevation, int near);
 
 int seg_calculate_downstream (SEGMENT *dirs, SEGMENT *distance, SEGMENT *elevation, OUTLET outlet, int outs);
 int seg_fill_basins(OUTLET outlet, SEGMENT *distance, SEGMENT *dirs);

Modified: grass-addons/grass7/raster/r.stream.distance/local_vars.h
===================================================================
--- grass-addons/grass7/raster/r.stream.distance/local_vars.h	2014-11-02 22:13:05 UTC (rev 62558)
+++ grass-addons/grass7/raster/r.stream.distance/local_vars.h	2014-11-02 22:16:25 UTC (rev 62559)
@@ -22,8 +22,8 @@
 
 typedef struct {
 	int r,c;
-  float cur_dist;
-  float target_elev;
+  double cur_dist;
+  double target_elev;
 } POINT;
 
 GLOBAL int nextr[9];

Modified: grass-addons/grass7/raster/r.stream.distance/main.c
===================================================================
--- grass-addons/grass7/raster/r.stream.distance/main.c	2014-11-02 22:13:05 UTC (rev 62558)
+++ grass-addons/grass7/raster/r.stream.distance/main.c	2014-11-02 22:16:25 UTC (rev 62559)
@@ -138,7 +138,7 @@
     ncols = Rast_window_cols();
     G_begin_distance_calculations();
 
-    fifo_max = 4 * nrows * ncols;
+    fifo_max = 4 * (nrows + ncols);
     fifo_points = (POINT *) G_malloc((fifo_max + 1) * sizeof(POINT));
 
     if (!segmentation) {
@@ -147,19 +147,19 @@
 	MAP map_dirs, map_streams, map_distance, map_elevation,
 	    map_tmp_elevation;
 	CELL **streams, **dirs;
-	FCELL **distance;
-	FCELL **elevation = NULL;
-	FCELL **tmp_elevation = NULL;
+	DCELL **distance;
+	DCELL **elevation = NULL;
+	DCELL **tmp_elevation = NULL;
 
 	ram_create_map(&map_streams, CELL_TYPE);
 	ram_read_map(&map_streams, in_stm_opt->answer, 1, CELL_TYPE);
 	ram_create_map(&map_dirs, CELL_TYPE);
 	ram_read_map(&map_dirs, in_dir_opt->answer, 1, CELL_TYPE);
-	ram_create_map(&map_distance, FCELL_TYPE);
+	ram_create_map(&map_distance, DCELL_TYPE);
 
 	streams = (CELL **) map_streams.map;
 	dirs = (CELL **) map_dirs.map;
-	distance = (FCELL **) map_distance.map;
+	distance = (DCELL **) map_distance.map;
 	number_of_streams = (int)map_streams.max + 1;
 
 	outlets_num =
@@ -168,9 +168,9 @@
 	ram_release_map(&map_streams);
 
 	if (in_elev_opt->answer) {
-	    ram_create_map(&map_elevation, FCELL_TYPE);
+	    ram_create_map(&map_elevation, DCELL_TYPE);
 	    ram_read_map(&map_elevation, in_elev_opt->answer, 0, -1);
-	    elevation = (FCELL **) map_elevation.map;
+	    elevation = (DCELL **) map_elevation.map;
 	}			/* map elevation will be replaced by elevation difference map */
 
 
@@ -187,8 +187,8 @@
 	else if (method == UPSTREAM) {
 
 	    if (out_diff_opt->answer) {
-		ram_create_map(&map_tmp_elevation, FCELL_TYPE);
-		tmp_elevation = (FCELL **) map_tmp_elevation.map;
+		ram_create_map(&map_tmp_elevation, DCELL_TYPE);
+		tmp_elevation = (DCELL **) map_tmp_elevation.map;
 	    }
 
 	    for (j = 0; j < outlets_num; ++j)
@@ -203,12 +203,12 @@
 
 	if (out_diff_opt->answer) {
 	    ram_prep_null_elevation(distance, elevation);
-	    ram_write_map(&map_elevation, out_diff_opt->answer, FCELL_TYPE, 1,
+	    ram_write_map(&map_elevation, out_diff_opt->answer, DCELL_TYPE, 1,
 			  -1);
 	}
 
 	if (out_dist_opt->answer)
-	    ram_write_map(&map_distance, out_dist_opt->answer, FCELL_TYPE, 1,
+	    ram_write_map(&map_distance, out_dist_opt->answer, DCELL_TYPE, 1,
 			  -1);
 
 	ram_release_map(&map_dirs);
@@ -240,7 +240,7 @@
 	seg_create_map(&map_dirs, SROWS, SCOLS, number_of_segs, CELL_TYPE);
 	seg_read_map(&map_dirs, in_dir_opt->answer, 1, CELL_TYPE);
 	seg_create_map(&map_distance, SROWS, SCOLS, number_of_segs,
-		       FCELL_TYPE);
+		       DCELL_TYPE);
 
 	streams = &map_streams.seg;
 	dirs = &map_dirs.seg;
@@ -254,7 +254,7 @@
 
 	if (in_elev_opt->answer) {
 	    seg_create_map(&map_elevation, SROWS, SCOLS, number_of_segs,
-			   FCELL_TYPE);
+			   DCELL_TYPE);
 	    seg_read_map(&map_elevation, in_elev_opt->answer, 0, -1);
 	    elevation = &map_elevation.seg;
 	}			/* map elevation will be replaced by elevation difference map */
@@ -273,7 +273,7 @@
 
 	    if (out_diff_opt->answer) {
 		seg_create_map(&map_tmp_elevation, SROWS, SCOLS,
-			       number_of_segs, FCELL_TYPE);
+			       number_of_segs, DCELL_TYPE);
 		tmp_elevation = &map_tmp_elevation.seg;
 	    }
 
@@ -288,12 +288,12 @@
 	}			/* end methods */
 
 	if (out_dist_opt->answer)
-	    seg_write_map(&map_distance, out_dist_opt->answer, FCELL_TYPE, 1,
+	    seg_write_map(&map_distance, out_dist_opt->answer, DCELL_TYPE, 1,
 			  -1);
 
 	if (out_diff_opt->answer) {
 	    seg_prep_null_elevation(distance, elevation);
-	    seg_write_map(&map_elevation, out_diff_opt->answer, FCELL_TYPE, 1,
+	    seg_write_map(&map_elevation, out_diff_opt->answer, DCELL_TYPE, 1,
 			  -1);
 	}
 

Modified: grass-addons/grass7/raster/r.stream.distance/r.stream.distance.html
===================================================================
--- grass-addons/grass7/raster/r.stream.distance/r.stream.distance.html	2014-11-02 22:13:05 UTC (rev 62558)
+++ grass-addons/grass7/raster/r.stream.distance/r.stream.distance.html	2014-11-02 22:16:25 UTC (rev 62559)
@@ -86,11 +86,11 @@
 
 <dt><b>difference</b></dt>
 <dd>Name of output map of elevation difference to the target (outlet, node, 
-stream, divide, maximum) along watercoures. The map is of FCELL type.</dd>
+stream, divide, maximum) along watercoures. The map is of DCELL type.</dd>
 
 <dt><b>distance</b></dt>
 <dd>Name of output map of distance to the target (outlet, node, stream, 
-divide, maximum) along watercoures. The map is of FCELL type.</dd>
+divide, maximum) along watercoures. The map is of DCELL type.</dd>
 </dl>
 
 <h2>NOTES</h2>
@@ -190,5 +190,6 @@
 Jarek Jasiewicz, Adam Mickiewicz University, Geoecology and Geoinformation
 Institute.
 
-<p><i>Last changed: $Date$</i>
+<p>
+<i>Last changed: $Date$</i>
 



More information about the grass-commit mailing list