[GRASS-SVN] r65175 - grass/branches/releasebranch_7_0/raster/r.carve
svn_grass at osgeo.org
svn_grass at osgeo.org
Sat May 2 14:27:12 PDT 2015
Author: hcho
Date: 2015-05-02 14:27:12 -0700 (Sat, 02 May 2015)
New Revision: 65175
Modified:
grass/branches/releasebranch_7_0/raster/r.carve/enforce_ds.c
Log:
r.carve: Backport r65165, r65165, r65166
Modified: grass/branches/releasebranch_7_0/raster/r.carve/enforce_ds.c
===================================================================
--- grass/branches/releasebranch_7_0/raster/r.carve/enforce_ds.c 2015-05-02 21:19:02 UTC (rev 65174)
+++ grass/branches/releasebranch_7_0/raster/r.carve/enforce_ds.c 2015-05-02 21:27:12 UTC (rev 65175)
@@ -453,7 +453,7 @@
prevrow = Rast_northing_to_row(pgxypts[0][1], &wind);
prevcol = Rast_easting_to_col(pgxypts[0][0], &wind);
- for (i = 1; i < (npts - 1); i++) {
+ for (i = 1; i < npts; i++) {
int c, r;
int row = Rast_northing_to_row(pgxypts[i][1], &wind);
@@ -465,10 +465,12 @@
col1 = MAX(0, MIN(col, prevcol) - coloff);
col2 = MIN(Rast_window_cols() - 1, MAX(col, prevcol) + coloff);
- for (r = row1; r < row2; r++) {
+ for (r = row1; r <= row2; r++) {
cy = Rast_row_to_northing(r + 0.5, &wind);
- for (c = col1; c < col2; c++) {
+ for (c = col1; c <= col2; c++) {
+ double distance;
+
cellx = Rast_col_to_easting(c + 0.5, &wind);
celly = cy; /* gets written over in distance2... */
@@ -479,38 +481,36 @@
* Here we use a bitmap and only change cells once
* on the way down */
- if (dig_distance2_point_to_line(cellx, celly, 0,
+ distance = sqrt(dig_distance2_point_to_line(cellx, celly, 0,
pgxypts[i - 1][0],
pgxypts[i - 1][1], 0,
pgxypts[i][0], pgxypts[i][1],
0, 0, &cellx, &celly, NULL,
- NULL, NULL)) {
- if (!BM_get(bm, c, r)) {
- double dist, elev;
+ NULL, NULL));
- Vect_reset_line(points);
+ if (distance <= parm->swidth && !BM_get(bm, c, r)) {
+ double dist, elev;
- dist = G_distance(pgxypts[i][0], pgxypts[i][1],
- cellx, celly);
+ Vect_reset_line(points);
- elev = LINTERP(pgpts[i][1], pgpts[i - 1][1],
- (dist /
- (pgpts[i][0] - pgpts[i - 1][0])));
+ dist = G_distance(pgxypts[i][0], pgxypts[i][1],
+ cellx, celly);
- BM_set(bm, c, r, 1);
+ elev = LINTERP(pgpts[i][1], pgpts[i - 1][1],
+ (dist / (pgpts[i][0] - pgpts[i - 1][0])));
- /* TODO - may want to use a function for the
- * cross section of stream */
- set_min_point(rbuf, c, r, elev, parm->sdepth,
- parm->raster_type);
+ BM_set(bm, c, r, 1);
- /* Add point to output vector map */
- if (parm->outvect->answer) {
- Vect_append_point(points, pgxypts[i][0],
- pgxypts[i][1],
- elev - parm->sdepth);
- Vect_write_line(outMap, GV_POINT, points, cats);
- }
+ /* TODO - may want to use a function for the
+ * cross section of stream */
+ set_min_point(rbuf, c, r, elev, parm->sdepth,
+ parm->raster_type);
+
+ /* Add point to output vector map */
+ if (parm->outvect->answer) {
+ Vect_append_point(points, cellx, celly,
+ elev - parm->sdepth);
+ Vect_write_line(outMap, GV_POINT, points, cats);
}
}
}
More information about the grass-commit
mailing list