PostGIS  2.4.9dev-r@@SVN_REVISION@@

◆ rt_pixtype_compare_clamped_values()

rt_errorstate rt_pixtype_compare_clamped_values ( rt_pixtype  pixtype,
double  val,
double  refval,
int *  isequal 
)

Returns 1 if clamped values are equal, 0 if not equal, -1 if error.

Test to see if two values are equal when clamped.

Parameters
pixtype: the pixel type to clamp the provided values
val: value to compare to reference value
refval: reference value to be compared with
isequal: non-zero if clamped values are equal, 0 otherwise
Returns
ES_NONE on success, ES_ERROR on error

Definition at line 200 of file rt_pixel.c.

References ES_ERROR, ES_NONE, FLT_EQ, PT_16BSI, PT_16BUI, PT_1BB, PT_2BUI, PT_32BF, PT_32BSI, PT_32BUI, PT_4BUI, PT_64BF, PT_8BSI, PT_8BUI, rt_util_clamp_to_16BSI(), rt_util_clamp_to_16BUI(), rt_util_clamp_to_1BB(), rt_util_clamp_to_2BUI(), rt_util_clamp_to_32BSI(), rt_util_clamp_to_32BUI(), rt_util_clamp_to_32F(), rt_util_clamp_to_4BUI(), rt_util_clamp_to_8BSI(), rt_util_clamp_to_8BUI(), and rterror().

Referenced by rt_band_clamped_value_is_nodata(), rt_band_get_pixel_of_value(), and test_pixtype_compare_clamped_values().

204  {
205  assert(isequal != NULL);
206  *isequal = 0;
207 
208  switch (pixtype) {
209  case PT_1BB:
210  if (rt_util_clamp_to_1BB(val) == rt_util_clamp_to_1BB(refval))
211  *isequal = 1;
212  break;
213  case PT_2BUI:
214  if (rt_util_clamp_to_2BUI(val) == rt_util_clamp_to_2BUI(refval))
215  *isequal = 1;
216  break;
217  case PT_4BUI:
218  if (rt_util_clamp_to_4BUI(val) == rt_util_clamp_to_4BUI(refval))
219  *isequal = 1;
220  break;
221  case PT_8BSI:
222  if (rt_util_clamp_to_8BSI(val) == rt_util_clamp_to_8BSI(refval))
223  *isequal = 1;
224  break;
225  case PT_8BUI:
226  if (rt_util_clamp_to_8BUI(val) == rt_util_clamp_to_8BUI(refval))
227  *isequal = 1;
228  break;
229  case PT_16BSI:
231  *isequal = 1;
232  break;
233  case PT_16BUI:
235  *isequal = 1;
236  break;
237  case PT_32BSI:
239  *isequal = 1;
240  break;
241  case PT_32BUI:
243  *isequal = 1;
244  break;
245  case PT_32BF:
247  *isequal = 1;
248  break;
249  case PT_64BF:
250  if (FLT_EQ(val, refval))
251  *isequal = 1;
252  break;
253  default:
254  rterror("rt_pixtype_compare_clamped_values: Unknown pixeltype %d", pixtype);
255  return ES_ERROR;
256  }
257 
258  return ES_NONE;
259 }
int32_t rt_util_clamp_to_32BSI(double value)
Definition: rt_util.c:69
uint32_t rt_util_clamp_to_32BUI(double value)
Definition: rt_util.c:74
#define FLT_EQ(x, y)
Definition: librtcore.h:2185
void rterror(const char *fmt,...)
Wrappers used for reporting errors and info.
Definition: rt_context.c:199
uint16_t rt_util_clamp_to_16BUI(double value)
Definition: rt_util.c:64
int8_t rt_util_clamp_to_8BSI(double value)
Definition: rt_util.c:49
uint8_t rt_util_clamp_to_4BUI(double value)
Definition: rt_util.c:44
uint8_t rt_util_clamp_to_8BUI(double value)
Definition: rt_util.c:54
uint8_t rt_util_clamp_to_1BB(double value)
Definition: rt_util.c:34
uint8_t rt_util_clamp_to_2BUI(double value)
Definition: rt_util.c:39
float rt_util_clamp_to_32F(double value)
Definition: rt_util.c:79
int16_t rt_util_clamp_to_16BSI(double value)
Definition: rt_util.c:59
Here is the call graph for this function:
Here is the caller graph for this function: