Get nearest pixel(s) with value (not NODATA) to specified pixel. 
 1382         int extent[4] = {0};
 
 1383         int max_extent[4] = {0};
 
 1386         uint32_t _d[2] = {0};
 
 1401         assert(NULL != 
band);
 
 1402         assert(NULL != npixels);
 
 1419                 exclude_nodata_value && (
 
 1420                         (x < 0 || x > 
band->width) ||
 
 1421                         (y < 0 || y > 
band->height)
 
 1428                         else if (
x > 
band->width)
 
 1433                         else if (
y > 
band->height)
 
 1446                         RASTER_DEBUG(4, 
"No nearest pixels possible for provided pixel and distances");
 
 1452         if (!
band->hasnodata)
 
 1453                 exclude_nodata_value = 
FALSE;
 
 1455         else if (exclude_nodata_value && 
band->isnodata) {
 
 1456                 RASTER_DEBUG(4, 
"No nearest pixels possible as band is NODATA and excluding NODATA values");
 
 1466                 b = abs(
x - 
band->width);
 
 1475                 b = abs(
y - 
band->height);
 
 1499                 max_extent[0], max_extent[1], max_extent[2], max_extent[3]);
 
 1507                 extent[0] = 
x - (int)_d[0]; 
 
 1508                 extent[1] = 
y - (int)_d[1]; 
 
 1509                 extent[2] = 
x + (int)_d[0]; 
 
 1510                 extent[3] = 
y + (int)_d[1]; 
 
 1512                 RASTER_DEBUGF(4, 
"Processing distances: %d x %d", _d[0], _d[1]);
 
 1514                         extent[0], extent[1], extent[2], extent[3]);
 
 1516                 for (i = 0; i < 2; i++) {
 
 1520                                 _max = extent[2] - extent[0] + 1;
 
 1523                                 _max = extent[3] - extent[1] + 1;
 
 1526                         for (j = 0; j < 2; j++) {
 
 1555                                 for (k = 0; k < (uint32_t) _max; k++) {
 
 1558                                                 _x < max_extent[0] || _x > max_extent[2] ||
 
 1559                                                 _y < max_extent[1] || _y > max_extent[3]
 
 1567                                                 (_x < 0 || _x >= 
band->width) ||
 
 1568                                                 (_y < 0 || _y >= 
band->height)
 
 1571                                                 if (!
band->hasnodata)
 
 1576                                                 RASTER_DEBUGF(4, 
"NODATA pixel outside band extent: (x, y, val) = (%d, %d, %f)", _x, _y, 
pixval);
 
 1587                                                         rterror(
"rt_band_get_nearest_pixel: Could not get pixel value");
 
 1596                                         if (!exclude_nodata_value || (exclude_nodata_value && !isnodata)) {
 
 1598                                                 RASTER_DEBUGF(4, 
"Adding pixel to set of nearest pixels: (x, y, val) = (%d, %d, %f)", _x, _y, 
pixval);
 
 1601                                                 if (*npixels == NULL)
 
 1605                                                 if (*npixels == NULL) {
 
 1606                                                         rterror(
"rt_band_get_nearest_pixel: Could not allocate memory for nearest pixel(s)");
 
 1610                                                 npixel = &((*npixels)[
count - 1]);
 
 1616                                                 if (!inextent && !
band->hasnodata)
 
 1630                 else if (d0 && 
count)
 
void rterror(const char *fmt,...)
Wrappers used for reporting errors and info.
void * rtalloc(size_t size)
Wrappers used for managing memory.
#define RASTER_DEBUG(level, msg)
#define RASTER_DEBUGF(level, msg,...)
double rt_pixtype_get_min_value(rt_pixtype pixtype)
Return minimum value possible for pixel type.
struct rt_pixel_t * rt_pixel
void * rtrealloc(void *mem, size_t size)
const char * rt_pixtype_name(rt_pixtype pixtype)
void rtdealloc(void *mem)
static double distance(double x1, double y1, double x2, double y2)
rt_errorstate rt_band_get_pixel(rt_band band, int x, int y, double *value, int *nodata)
Get pixel value.