PostGIS  2.4.9dev-r@@SVN_REVISION@@

◆ quantile_llist_index_search()

static struct quantile_llist_element* quantile_llist_index_search ( struct quantile_llist qll,
double  value,
uint32_t index 
)
static

Definition at line 936 of file rt_statistics.c.

References quantile_llist_index::element, FLT_EQ, quantile_llist::head, quantile_llist::index, quantile_llist::index_max, RASTER_DEBUGF, and quantile_llist_element::value.

Referenced by rt_band_get_quantiles_stream().

940  {
941  uint32_t i = 0, j = 0;
942  RASTER_DEBUGF(5, "searching index for value %f", value);
943 
944  for (i = 0; i < qll->index_max; i++) {
945  if (NULL == qll->index[i].element) {
946  if (i < 1) break;
947  continue;
948  }
949  if (value > (qll->index[i]).element->value) continue;
950 
951  if (FLT_EQ(value, qll->index[i].element->value)) {
952  RASTER_DEBUGF(5, "using index value at %d = %f", i, qll->index[i].element->value);
953  *index = i * 100;
954  return qll->index[i].element;
955  }
956  else if (i > 0) {
957  for (j = 1; j < i; j++) {
958  if (NULL != qll->index[i - j].element) {
959  RASTER_DEBUGF(5, "using index value at %d = %f", i - j, qll->index[i - j].element->value);
960  *index = (i - j) * 100;
961  return qll->index[i - j].element;
962  }
963  }
964  }
965  }
966 
967  *index = 0;
968  return qll->head;
969 }
struct quantile_llist_element * element
Definition: librtcore.h:2369
#define FLT_EQ(x, y)
Definition: librtcore.h:2185
unsigned int uint32_t
Definition: uthash.h:78
uint32_t index_max
Definition: librtcore.h:2354
#define RASTER_DEBUGF(level, msg,...)
Definition: librtcore.h:299
struct quantile_llist_index * index
Definition: librtcore.h:2353
int value
Definition: genraster.py:61
struct quantile_llist_element * head
Definition: librtcore.h:2348
Here is the caller graph for this function: