| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
#include <math.h> |
| 7 |
#include "global.h" |
| 8 |
|
| 9 |
void p_nearest(struct cache *ibuffer, |
| 10 |
void *obufptr, |
| 11 |
int cell_type, |
| 12 |
double *row_idx, |
| 13 |
double *col_idx, |
| 14 |
struct Cell_head *cellhd |
| 15 |
) |
| 16 |
{ |
| 17 |
int row, col; |
| 18 |
DCELL *cellp; |
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
row = (int)floor(*row_idx); |
| 24 |
col = (int)floor(*col_idx); |
| 25 |
|
| 26 |
|
| 27 |
if (row < 0 || row >= cellhd->rows || col < 0 || col >= cellhd->cols) { |
| 28 |
Rast_set_null_value(obufptr, 1, cell_type); |
| 29 |
return; |
| 30 |
} |
| 31 |
|
| 32 |
cellp = CPTR(ibuffer, row, col); |
| 33 |
|
| 34 |
if (Rast_is_d_null_value(cellp)) { |
| 35 |
Rast_set_null_value(obufptr, 1, cell_type); |
| 36 |
return; |
| 37 |
} |
| 38 |
|
| 39 |
Rast_set_d_value(obufptr, *cellp, cell_type); |
| 40 |
} |