|
@@ -453,7 +453,7 @@ static void process_line_segment(const int npts, void *rbuf,
|
|
|
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 @@ static void process_line_segment(const int npts, void *rbuf,
|
|
|
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 @@ static void process_line_segment(const int npts, void *rbuf,
|
|
|
* 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);
|
|
|
}
|
|
|
}
|
|
|
}
|