73
74
/* allocate and clear memory for entire raster */
75
G_calloc(G_window_rows() * G_window_cols(),
76
G_raster_size(parm->raster_type));
76
G_calloc(Rast_window_rows() * Rast_window_cols(),
77
Rast_cell_size(parm->raster_type));
78
79
/* first read whole elevation file into buf */
79
80
read_raster(rbuf, infd, parm->raster_type);
132
133
for (i = 0; i < points->n_points; i++) {
135
int row = G_northing_to_row(points->y[i], &wind);
136
int col = G_easting_to_col(points->x[i], &wind);
136
int row = Rast_northing_to_row(points->y[i], &wind);
137
int col = Rast_easting_to_col(points->x[i], &wind);
138
139
/* rough clipping */
139
if (row < 0 || row > G_window_rows() - 1 ||
140
col < 0 || col > G_window_cols() - 1) {
140
if (row < 0 || row > Rast_window_rows() - 1 ||
141
col < 0 || col > Rast_window_cols() - 1) {
141
142
if (first_in != -1)
278
279
CELL *cbuf = data;
280
cbuf[row * G_window_cols() + col] =
281
MIN(cbuf[row * G_window_cols() + col], elev) - (int)depth;
281
cbuf[row * Rast_window_cols() + col] =
282
MIN(cbuf[row * Rast_window_cols() + col], elev) - (int)depth;
286
287
FCELL *fbuf = data;
288
fbuf[row * G_window_cols() + col] =
289
MIN(fbuf[row * G_window_cols() + col], elev) - depth;
289
fbuf[row * Rast_window_cols() + col] =
290
MIN(fbuf[row * Rast_window_cols() + col], elev) - depth;
294
295
DCELL *dbuf = data;
296
dbuf[row * G_window_cols() + col] =
297
MIN(dbuf[row * G_window_cols() + col], elev) - depth;
297
dbuf[row * Rast_window_cols() + col] =
298
MIN(dbuf[row * Rast_window_cols() + col], elev) - depth;
312
313
struct Cell_head wind;
314
315
G_get_window(&wind);
315
rastrows = G_window_rows();
316
rastcols = G_window_cols();
316
rastrows = Rast_window_rows();
317
rastcols = Rast_window_cols();
318
G_set_d_null_value(&min, 1);
319
Rast_set_d_null_value(&min, 1);
320
321
/* kludge - fix for lat_lon */
321
322
rowoff = rad / wind.ns_res;
322
323
coloff = rad / wind.ew_res;
324
row = G_northing_to_row(py, &wind);
325
col = G_easting_to_col(px, &wind);
325
row = Rast_northing_to_row(py, &wind);
326
col = Rast_easting_to_col(px, &wind);
327
328
/* get bounding box of line segment */
328
329
row1 = MAX(0, row - rowoff);
352
353
DCELL *dbuf = data;
354
if (!(G_is_d_null_value(&dbuf[row1 * rastcols + col1])))
355
if (!(Rast_is_d_null_value(&dbuf[row1 * rastcols + col1])))
355
356
min = dbuf[row1 * rastcols + col1];
360
361
for (r = row1; r < row2; r++) {
361
double cy = G_row_to_northing(r + 0.5, &wind);
362
double cy = Rast_row_to_northing(r + 0.5, &wind);
364
365
for (c = col1; c < col2; c++) {
365
double cx = G_col_to_easting(c + 0.5, &wind);
366
double cx = Rast_col_to_easting(c + 0.5, &wind);
367
368
if (G_distance(px, py, cx, cy) <= SQR(rad)) {
371
372
CELL *cbuf = data;
373
if (G_is_d_null_value(&min)) {
374
if (!(G_is_c_null_value(&cbuf[r * rastcols + c])))
374
if (Rast_is_d_null_value(&min)) {
375
if (!(Rast_is_c_null_value(&cbuf[r * rastcols + c])))
375
376
min = cbuf[r * rastcols + c];
378
if (!(G_is_c_null_value(&cbuf[r * rastcols + c])))
379
if (!(Rast_is_c_null_value(&cbuf[r * rastcols + c])))
379
380
if (cbuf[r * rastcols + c] < min)
380
381
min = cbuf[r * rastcols + c];
386
387
FCELL *fbuf = data;
388
if (G_is_d_null_value(&min)) {
389
if (!(G_is_f_null_value(&fbuf[r * rastcols + c])))
389
if (Rast_is_d_null_value(&min)) {
390
if (!(Rast_is_f_null_value(&fbuf[r * rastcols + c])))
390
391
min = fbuf[r * rastcols + c];
393
if (!(G_is_f_null_value(&fbuf[r * rastcols + c])))
394
if (!(Rast_is_f_null_value(&fbuf[r * rastcols + c])))
394
395
if (fbuf[r * rastcols + c] < min)
395
396
min = fbuf[r * rastcols + c];
401
402
DCELL *dbuf = data;
403
if (G_is_d_null_value(&min)) {
404
if (!(G_is_d_null_value(&dbuf[r * rastcols + c])))
404
if (Rast_is_d_null_value(&min)) {
405
if (!(Rast_is_d_null_value(&dbuf[r * rastcols + c])))
405
406
min = dbuf[r * rastcols + c];
408
if (!(G_is_d_null_value(&dbuf[r * rastcols + c])))
409
if (!(Rast_is_d_null_value(&dbuf[r * rastcols + c])))
409
410
if (dbuf[r * rastcols + c] < min)
410
411
min = dbuf[r * rastcols + c];
449
450
coloff = parm->swidth / wind.ew_res;
451
452
/* get prevrow and prevcol for iteration 0 of following loop */
452
prevrow = G_northing_to_row(pgxypts[0][1], &wind);
453
prevcol = G_easting_to_col(pgxypts[0][0], &wind);
453
prevrow = Rast_northing_to_row(pgxypts[0][1], &wind);
454
prevcol = Rast_easting_to_col(pgxypts[0][0], &wind);
455
456
for (i = 1; i < (npts - 1); i++) {
458
int row = G_northing_to_row(pgxypts[i][1], &wind);
459
int col = G_easting_to_col(pgxypts[i][0], &wind);
459
int row = Rast_northing_to_row(pgxypts[i][1], &wind);
460
int col = Rast_easting_to_col(pgxypts[i][0], &wind);
461
462
/* get bounding box of line segment */
462
463
row1 = MAX(0, MIN(row, prevrow) - rowoff);
463
row2 = MIN(G_window_rows() - 1, MAX(row, prevrow) + rowoff);
464
row2 = MIN(Rast_window_rows() - 1, MAX(row, prevrow) + rowoff);
464
465
col1 = MAX(0, MIN(col, prevcol) - coloff);
465
col2 = MIN(G_window_cols() - 1, MAX(col, prevcol) + coloff);
466
col2 = MIN(Rast_window_cols() - 1, MAX(col, prevcol) + coloff);
467
468
for (r = row1; r < row2; r++) {
468
cy = G_row_to_northing(r + 0.5, &wind);
469
cy = Rast_row_to_northing(r + 0.5, &wind);
470
471
for (c = col1; c < col2; c++) {
471
cellx = G_col_to_easting(c + 0.5, &wind);
472
cellx = Rast_col_to_easting(c + 0.5, &wind);
472
473
celly = cy; /* gets written over in distance2... */
474
475
/* Thought about not going past endpoints (use