[GRASS-SVN] r67237 - grass-addons/grass7/raster/r.hydrodem
svn_grass at osgeo.org
svn_grass at osgeo.org
Fri Dec 18 13:13:57 PST 2015
Author: mmetz
Date: 2015-12-18 13:13:57 -0800 (Fri, 18 Dec 2015)
New Revision: 67237
Modified:
grass-addons/grass7/raster/r.hydrodem/bseg.c
grass-addons/grass7/raster/r.hydrodem/cseg.c
grass-addons/grass7/raster/r.hydrodem/do_astar.c
grass-addons/grass7/raster/r.hydrodem/dseg.c
grass-addons/grass7/raster/r.hydrodem/hydro_con.c
grass-addons/grass7/raster/r.hydrodem/init_search.c
grass-addons/grass7/raster/r.hydrodem/load.c
grass-addons/grass7/raster/r.hydrodem/local_proto.h
grass-addons/grass7/raster/r.hydrodem/main.c
grass-addons/grass7/raster/r.hydrodem/seg.c
grass-addons/grass7/raster/r.hydrodem/seg.h
Log:
r.hydrodem: sync to r.watershed
Modified: grass-addons/grass7/raster/r.hydrodem/bseg.c
===================================================================
--- grass-addons/grass7/raster/r.hydrodem/bseg.c 2015-12-18 21:09:49 UTC (rev 67236)
+++ grass-addons/grass7/raster/r.hydrodem/bseg.c 2015-12-18 21:13:57 UTC (rev 67237)
@@ -2,7 +2,7 @@
#include <fcntl.h>
#include <grass/segment.h>
#include <grass/glocale.h>
-#include "seg.h"
+#include "local_proto.h"
int bseg_open(BSEG *bseg, int srows, int scols, int nsegs_in_memory)
{
@@ -73,7 +73,7 @@
return 0;
}
-int bseg_put(BSEG *bseg, char *value, int row, int col)
+int bseg_put(BSEG *bseg, char *value, GW_LARGE_INT row, GW_LARGE_INT col)
{
if (Segment_put(&(bseg->seg), value, row, col) < 0) {
G_warning(_("Unable to write segment file"));
@@ -82,7 +82,7 @@
return 0;
}
-int bseg_put_row(BSEG *bseg, char *value, int row)
+int bseg_put_row(BSEG *bseg, char *value, GW_LARGE_INT row)
{
if (Segment_put_row(&(bseg->seg), value, row) < 0) {
G_warning(_("Unable to write segment file"));
@@ -91,7 +91,7 @@
return 0;
}
-int bseg_get(BSEG *bseg, char *value, int row, int col)
+int bseg_get(BSEG *bseg, char *value, GW_LARGE_INT row, GW_LARGE_INT col)
{
if (Segment_get(&(bseg->seg), value, row, col) < 0) {
G_warning(_("Unable to read segment file"));
Modified: grass-addons/grass7/raster/r.hydrodem/cseg.c
===================================================================
--- grass-addons/grass7/raster/r.hydrodem/cseg.c 2015-12-18 21:09:49 UTC (rev 67236)
+++ grass-addons/grass7/raster/r.hydrodem/cseg.c 2015-12-18 21:13:57 UTC (rev 67237)
@@ -2,7 +2,7 @@
#include <fcntl.h>
#include <grass/segment.h>
#include <grass/glocale.h>
-#include "seg.h"
+#include "local_proto.h"
int cseg_open(CSEG *cseg, int srows, int scols, int nsegs_in_memory)
{
@@ -74,7 +74,7 @@
return 0;
}
-int cseg_put(CSEG *cseg, CELL *value, int row, int col)
+int cseg_put(CSEG *cseg, CELL *value, GW_LARGE_INT row, GW_LARGE_INT col)
{
if (Segment_put(&(cseg->seg), value, row, col) < 0) {
G_warning(_("Unable to write segment file"));
@@ -83,7 +83,7 @@
return 0;
}
-int cseg_put_row(CSEG *cseg, CELL *value, int row)
+int cseg_put_row(CSEG *cseg, CELL *value, GW_LARGE_INT row)
{
if (Segment_put_row(&(cseg->seg), value, row) < 0) {
G_warning(_("Unable to write segment file"));
@@ -92,7 +92,7 @@
return 0;
}
-int cseg_get(CSEG *cseg, CELL *value, int row, int col)
+int cseg_get(CSEG *cseg, CELL *value, GW_LARGE_INT row, GW_LARGE_INT col)
{
if (Segment_get(&(cseg->seg), value, row, col) < 0) {
G_warning(_("Unabel to read segment file"));
Modified: grass-addons/grass7/raster/r.hydrodem/do_astar.c
===================================================================
--- grass-addons/grass7/raster/r.hydrodem/do_astar.c 2015-12-18 21:09:49 UTC (rev 67236)
+++ grass-addons/grass7/raster/r.hydrodem/do_astar.c 2015-12-18 21:13:57 UTC (rev 67237)
@@ -4,8 +4,8 @@
#include <grass/glocale.h>
#include "local_proto.h"
-#define GET_PARENT(c) ((unsigned int)(((c) - 2) >> 2) + 1)
-#define GET_CHILD(p) ((unsigned int)((p) << 2) - 2)
+#define GET_PARENT(c) ((((GW_LARGE_INT)(c) - 2) >> 2) + 1)
+#define GET_CHILD(p) (((GW_LARGE_INT)(p) << 2) - 2)
#define HEAP_CMP(a, b) (((a)->ele < (b)->ele) ? 1 : \
(((a)->ele > (b)->ele) ? 0 : \
@@ -19,7 +19,7 @@
int do_astar(void)
{
int r, c, r_nbr, c_nbr, ct_dir;
- unsigned int count;
+ GW_LARGE_INT count;
int nextdr[8] = { 1, -1, 0, 0, -1, 1, 1, -1 };
int nextdc[8] = { 0, 0, -1, 1, 1, -1, 1, -1 };
int asp_r[9] = { 0, -1, -1, -1, 0, 1, 1, 1, 0 };
@@ -70,13 +70,13 @@
while (heap_size > 0) {
G_percent(count++, n_points, 1);
if (count > n_points)
- G_fatal_error(_("BUG in A* Search: %d surplus points"),
- heap_size);
+ G_fatal_error(_("BUG in A* Search: %lld surplus points"),
+ (long long int)heap_size);
if (heap_size > n_points)
G_fatal_error
- (_("BUG in A* Search: too many points in heap %d, should be %d"),
- heap_size, n_points);
+ (_("BUG in A* Search: too many points in heap %lld, should be %lld"),
+ (long long int)heap_size, (long long int)n_points);
heap_p = heap_drop();
@@ -104,7 +104,8 @@
/* get r, c (r_nbr, c_nbr) for neighbours */
r_nbr = r + nextdr[ct_dir];
c_nbr = c + nextdc[ct_dir];
- slope[ct_dir] = ele_nbr[ct_dir] = 0;
+ slope[ct_dir] = -1;
+ ele_nbr[ct_dir] = 0;
/* check that neighbour is within region */
if (r_nbr < 0 || r_nbr >= nrows || c_nbr < 0 || c_nbr >= ncols)
@@ -122,15 +123,15 @@
dist_to_nbr[ct_dir]);
}
- if (!is_in_list) {
- if (ct_dir > 3 && slope[ct_dir] > 0) {
- if (slope[nbr_ew[ct_dir]] > 0) {
+ if (!is_worked) {
+ if (ct_dir > 3 && slope[ct_dir] >= 0) {
+ if (slope[nbr_ew[ct_dir]] >= 0) {
/* slope to ew nbr > slope to center */
if (slope[ct_dir] < get_slope(ele_nbr[nbr_ew[ct_dir]],
ele_nbr[ct_dir], ew_res))
skip_diag = 1;
}
- if (!skip_diag && slope[nbr_ns[ct_dir]] > 0) {
+ if (!skip_diag && slope[nbr_ns[ct_dir]] >= 0) {
/* slope to ns nbr > slope to center */
if (slope[ct_dir] < get_slope(ele_nbr[nbr_ns[ct_dir]],
ele_nbr[ct_dir], ns_res))
@@ -210,7 +211,7 @@
G_percent(n_points, n_points, 1); /* finish it */
if (first_cum)
- G_warning(_("processed points mismatch of %u"), first_cum);
+ G_warning(_("processed points mismatch of %lld"), (long long int)first_cum);
return 1;
}
@@ -231,9 +232,9 @@
return 0;
}
-int sift_up(unsigned int start, struct heap_point child_p)
+int sift_up(GW_LARGE_INT start, struct heap_point child_p)
{
- unsigned int parent, child;
+ GW_LARGE_INT parent, child;
struct heap_point heap_p;
child = start;
@@ -263,7 +264,7 @@
* add item to heap
* returns heap_size
*/
-unsigned int heap_add(int r, int c, CELL ele)
+GW_LARGE_INT heap_add(int r, int c, CELL ele)
{
struct heap_point heap_p;
Modified: grass-addons/grass7/raster/r.hydrodem/dseg.c
===================================================================
--- grass-addons/grass7/raster/r.hydrodem/dseg.c 2015-12-18 21:09:49 UTC (rev 67236)
+++ grass-addons/grass7/raster/r.hydrodem/dseg.c 2015-12-18 21:13:57 UTC (rev 67237)
@@ -2,7 +2,7 @@
#include <fcntl.h>
#include <grass/segment.h>
#include <grass/glocale.h>
-#include "seg.h"
+#include "local_proto.h"
int dseg_open(DSEG *dseg, int srows, int scols, int nsegs_in_memory)
{
@@ -74,7 +74,7 @@
return 0;
}
-int dseg_put(DSEG *dseg, DCELL *value, int row, int col)
+int dseg_put(DSEG *dseg, DCELL *value, GW_LARGE_INT row, GW_LARGE_INT col)
{
if (Segment_put(&(dseg->seg), (DCELL *) value, row, col) < 0) {
G_warning(_("Unable to write segment file"));
@@ -83,7 +83,7 @@
return 0;
}
-int dseg_put_row(DSEG *dseg, DCELL *value, int row)
+int dseg_put_row(DSEG *dseg, DCELL *value, GW_LARGE_INT row)
{
if (Segment_put_row(&(dseg->seg), (DCELL *) value, row) < 0) {
G_warning(_("Unable to write segment file"));
@@ -92,7 +92,7 @@
return 0;
}
-int dseg_get(DSEG *dseg, DCELL *value, int row, int col)
+int dseg_get(DSEG *dseg, DCELL *value, GW_LARGE_INT row, GW_LARGE_INT col)
{
if (Segment_get(&(dseg->seg), (DCELL *) value, row, col) < 0) {
G_warning(_("Unable to read segment file"));
@@ -133,7 +133,7 @@
return 0;
}
-int dseg_write_cellfile(DSEG *dseg, char *map_name)
+int dseg_write_raster(DSEG *dseg, char *map_name)
{
int map_fd;
int row, nrows;
Modified: grass-addons/grass7/raster/r.hydrodem/hydro_con.c
===================================================================
--- grass-addons/grass7/raster/r.hydrodem/hydro_con.c 2015-12-18 21:09:49 UTC (rev 67236)
+++ grass-addons/grass7/raster/r.hydrodem/hydro_con.c 2015-12-18 21:13:57 UTC (rev 67237)
@@ -27,7 +27,7 @@
CELL *next_ele)
{
int r, c, r_nbr, c_nbr, ct_dir;
- CELL ele_val, ele_nbr;
+ CELL ele_nbr;
int n_to_fill;
int top, done;
struct dir_flag df;
@@ -35,7 +35,6 @@
/* go upstream from spill point */
r = peak_r;
c = peak_c;
- ele_val = peak_ele;
*n_splits = 0;
n_to_fill = 0;
/* post-order traversal */
@@ -776,9 +775,9 @@
int ct_dir;
int skipme;
CELL ele_min, ele_max, ele_this, ele_nbr;
- unsigned int n_pits = 0;
- unsigned int n_peaks = 0;
- unsigned int counter = 0;
+ GW_LARGE_INT n_pits = 0;
+ GW_LARGE_INT n_peaks = 0;
+ GW_LARGE_INT counter = 0;
double sumofsquares, mean, stddev, upperci, lowerci;
int n_valid;
@@ -871,9 +870,9 @@
}
G_percent(nrows, nrows, 1); /* finish it */
- G_verbose_message("%u cells checked", counter);
- G_verbose_message("%u one-cell peaks removed", n_peaks);
- G_verbose_message("%u one-cell pits removed", n_pits);
+ G_verbose_message("%lld cells checked", (long long int)counter);
+ G_verbose_message("%lld one-cell peaks removed", (long long int)n_peaks);
+ G_verbose_message("%lld one-cell pits removed", (long long int)n_pits);
return 1;
}
Modified: grass-addons/grass7/raster/r.hydrodem/init_search.c
===================================================================
--- grass-addons/grass7/raster/r.hydrodem/init_search.c 2015-12-18 21:09:49 UTC (rev 67236)
+++ grass-addons/grass7/raster/r.hydrodem/init_search.c 2015-12-18 21:13:57 UTC (rev 67237)
@@ -11,8 +11,8 @@
int nextdc[8] = { 0, 0, -1, 1, 1, -1, 1, -1 };
char asp_value, is_null;
struct dir_flag df, df_nbr;
- unsigned int n_depr_cells = 0;
- unsigned int n_null_cells = nrows * ncols - n_points;
+ GW_LARGE_INT n_depr_cells = 0;
+ GW_LARGE_INT n_null_cells = (GW_LARGE_INT) nrows * ncols - n_points;
int depr_map_type, depr_size;
nxt_avail_pt = heap_size = 0;
@@ -141,9 +141,9 @@
G_free(depr_buf);
}
- G_debug(1, "%d edge cells", heap_size - n_depr_cells);
+ G_debug(1, "%lld edge cells", (long long int) (heap_size - n_depr_cells));
if (n_depr_cells)
- G_debug(1, "%d cells in depressions", n_depr_cells);
+ G_debug(1, "%lld cells in depressions", (long long int) n_depr_cells);
return 1;
}
Modified: grass-addons/grass7/raster/r.hydrodem/load.c
===================================================================
--- grass-addons/grass7/raster/r.hydrodem/load.c 2015-12-18 21:09:49 UTC (rev 67236)
+++ grass-addons/grass7/raster/r.hydrodem/load.c 2015-12-18 21:13:57 UTC (rev 67237)
@@ -92,7 +92,7 @@
Rast_close(ele_fd);
G_free(ele_buf);
- G_debug(1, "%d non-NULL cells", n_points);
+ G_debug(1, "%lld non-NULL cells", (long long int)n_points);
return 1;
}
Modified: grass-addons/grass7/raster/r.hydrodem/local_proto.h
===================================================================
--- grass-addons/grass7/raster/r.hydrodem/local_proto.h 2015-12-18 21:09:49 UTC (rev 67236)
+++ grass-addons/grass7/raster/r.hydrodem/local_proto.h 2015-12-18 21:13:57 UTC (rev 67237)
@@ -4,10 +4,14 @@
#include <grass/gis.h>
#include <grass/raster.h>
+
+/* for grids with more than 2^31 - 1 cells */
+#define GW_LARGE_INT off_t
+
#include "seg.h"
#include "flag.h"
-#define INDEX(r, c) ((r) * ncols + (c))
+#define INDEX(r, c) ((GW_LARGE_INT)(r) * ncols + (c))
#define MAXDEPTH 1000 /* maximum supported tree depth of stream network */
struct ddir
@@ -22,7 +26,7 @@
};
struct heap_point {
- unsigned int added;
+ GW_LARGE_INT added;
CELL ele;
int r, c;
};
@@ -53,17 +57,17 @@
extern struct snode *stream_node;
extern int nrows, ncols;
-extern unsigned int n_search_points, n_points, nxt_avail_pt;
-extern unsigned int heap_size;
-extern unsigned int n_sinks;
+extern GW_LARGE_INT n_search_points, n_points, nxt_avail_pt;
+extern GW_LARGE_INT heap_size;
+extern int n_sinks;
extern int n_mod_max, size_max;
extern int do_all, keep_nat, nat_thresh;
-extern unsigned int n_stream_nodes, n_alloc_nodes;
+extern GW_LARGE_INT n_stream_nodes, n_alloc_nodes;
extern struct point *outlets;
extern struct sink_list *sinks, *first_sink;
-extern unsigned int n_outlets, n_alloc_outlets;
+extern GW_LARGE_INT n_outlets, n_alloc_outlets;
extern char drain[3][3];
-extern unsigned int first_cum;
+extern GW_LARGE_INT first_cum;
extern char sides;
extern int c_fac;
extern int ele_scale;
@@ -87,7 +91,7 @@
/* do_astar.c */
int do_astar(void);
-unsigned int heap_add(int, int, CELL);
+GW_LARGE_INT heap_add(int, int, CELL);
/* hydro_con.c */
int hydro_con(void);
Modified: grass-addons/grass7/raster/r.hydrodem/main.c
===================================================================
--- grass-addons/grass7/raster/r.hydrodem/main.c 2015-12-18 21:09:49 UTC (rev 67236)
+++ grass-addons/grass7/raster/r.hydrodem/main.c 2015-12-18 21:13:57 UTC (rev 67237)
@@ -22,19 +22,19 @@
struct snode *stream_node;
int nrows, ncols;
-unsigned int n_search_points, n_points, nxt_avail_pt;
-unsigned int heap_size;
-unsigned int n_sinks;
+GW_LARGE_INT n_search_points, n_points, nxt_avail_pt;
+GW_LARGE_INT heap_size;
+int n_sinks;
int n_mod_max, size_max;
int do_all, keep_nat, nat_thresh;
-unsigned int n_stream_nodes, n_alloc_nodes;
+GW_LARGE_INT n_stream_nodes, n_alloc_nodes;
struct point *outlets;
struct sink_list *sinks, *first_sink;
-unsigned int n_outlets, n_alloc_outlets;
+GW_LARGE_INT n_outlets, n_alloc_outlets;
char drain[3][3] = { {7, 6, 5}, {8, 0, 4}, {1, 2, 3} };
-unsigned int first_cum;
+GW_LARGE_INT first_cum;
char sides;
int c_fac;
int ele_scale;
Modified: grass-addons/grass7/raster/r.hydrodem/seg.c
===================================================================
--- grass-addons/grass7/raster/r.hydrodem/seg.c 2015-12-18 21:09:49 UTC (rev 67236)
+++ grass-addons/grass7/raster/r.hydrodem/seg.c 2015-12-18 21:13:57 UTC (rev 67237)
@@ -1,10 +1,10 @@
#include <unistd.h>
#include <fcntl.h>
#include <grass/glocale.h>
-#include "seg.h"
+#include "local_proto.h"
int
-seg_open(SSEG *sseg, int nrows, int ncols, int row_in_seg, int col_in_seg,
+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, int fill)
{
char *filename;
@@ -69,7 +69,7 @@
return 0;
}
-int seg_put(SSEG *sseg, char *value, int row, int col)
+int seg_put(SSEG *sseg, char *value, GW_LARGE_INT row, GW_LARGE_INT col)
{
if (Segment_put(&(sseg->seg), value, row, col) < 0) {
G_warning(_("Unable to write segment file"));
@@ -78,7 +78,7 @@
return 0;
}
-int seg_put_row(SSEG *sseg, char *value, int row)
+int seg_put_row(SSEG *sseg, char *value, GW_LARGE_INT row)
{
if (Segment_put_row(&(sseg->seg), value, row) < 0) {
G_warning(_("seg_put_row(): could not write segment file"));
@@ -87,7 +87,7 @@
return 0;
}
-int seg_get(SSEG *sseg, char *value, int row, int col)
+int seg_get(SSEG *sseg, char *value, GW_LARGE_INT row, GW_LARGE_INT col)
{
if (Segment_get(&(sseg->seg), value, row, col) < 0) {
G_warning(_("Unable to read segment file"));
@@ -96,7 +96,7 @@
return 0;
}
-int seg_get_row(SSEG *sseg, char *value, int row)
+int seg_get_row(SSEG *sseg, char *value, GW_LARGE_INT row)
{
if (Segment_get_row(&(sseg->seg), value, row) < 0) {
G_warning(_("Unable to read segment file"));
Modified: grass-addons/grass7/raster/r.hydrodem/seg.h
===================================================================
--- grass-addons/grass7/raster/r.hydrodem/seg.h 2015-12-18 21:09:49 UTC (rev 67236)
+++ grass-addons/grass7/raster/r.hydrodem/seg.h 2015-12-18 21:13:57 UTC (rev 67237)
@@ -40,39 +40,38 @@
/* bseg.c */
int bseg_close(BSEG *);
-int bseg_get(BSEG *, char *, int, int);
+int bseg_get(BSEG *, char *, GW_LARGE_INT, GW_LARGE_INT);
int bseg_open(BSEG *, int, int, int);
-int bseg_put(BSEG *, char *, int, int);
-int bseg_put_row(BSEG *, char *, int);
+int bseg_put(BSEG *, char *, GW_LARGE_INT, GW_LARGE_INT);
+int bseg_put_row(BSEG *, char *, GW_LARGE_INT);
int bseg_read_raster(BSEG *, char *, char *);
int bseg_write_raster(BSEG *, char *);
/* cseg.c */
int cseg_close(CSEG *);
-int cseg_get(CSEG *, CELL *, int, int);
+int cseg_get(CSEG *, CELL *, GW_LARGE_INT, GW_LARGE_INT);
int cseg_open(CSEG *, int, int, int);
-int cseg_put(CSEG *, CELL *, int, int);
-int cseg_put_row(CSEG *, CELL *, int);
+int cseg_put(CSEG *, CELL *, GW_LARGE_INT, GW_LARGE_INT);
+int cseg_put_row(CSEG *, CELL *, GW_LARGE_INT);
int cseg_read_raster(CSEG *, char *, char *);
int cseg_write_raster(CSEG *, char *);
/* dseg.c */
int dseg_close(DSEG *);
-int dseg_get(DSEG *, double *, int, int);
+int dseg_get(DSEG *, double *, GW_LARGE_INT, GW_LARGE_INT);
int dseg_open(DSEG *, int, int, int);
-int dseg_put(DSEG *, double *, int, int);
-int dseg_put_row(DSEG *, double *, int);
+int dseg_put(DSEG *, double *, GW_LARGE_INT, GW_LARGE_INT);
+int dseg_put_row(DSEG *, double *, GW_LARGE_INT);
int dseg_read_raster(DSEG *, char *, char *);
int dseg_write_raster(DSEG *, char *);
/* seg.c */
int seg_close(SSEG *);
-int seg_get(SSEG *, char *, int, int);
-int seg_open(SSEG *, int, int, int, int, int, int, int);
-int seg_put(SSEG *, char *, int, int);
-int seg_put_row(SSEG *, char *, int);
-int seg_get(SSEG *, char *, int, int);
-int seg_get_row(SSEG *, char *, int);
+int seg_get(SSEG *, char *, GW_LARGE_INT, GW_LARGE_INT);
+int seg_open(SSEG *, GW_LARGE_INT, GW_LARGE_INT, int, int, int, int, int);
+int seg_put(SSEG *, char *, GW_LARGE_INT, GW_LARGE_INT);
+int seg_put_row(SSEG *, char *, GW_LARGE_INT);
+int seg_get_row(SSEG *, char *, GW_LARGE_INT);
int seg_flush(SSEG *);
#endif /* __SEG_H__ */
More information about the grass-commit
mailing list