PostGIS  3.4.0dev-r@@SVN_REVISION@@

◆ rt_pixtype_compare_clamped_values()

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

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

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 202 of file rt_pixel.c.

206  {
207  assert(isequal != NULL);
208  *isequal = 0;
209 
210  switch (pixtype) {
211  case PT_1BB:
212  if (rt_util_clamp_to_1BB(val) == rt_util_clamp_to_1BB(refval))
213  *isequal = 1;
214  break;
215  case PT_2BUI:
216  if (rt_util_clamp_to_2BUI(val) == rt_util_clamp_to_2BUI(refval))
217  *isequal = 1;
218  break;
219  case PT_4BUI:
220  if (rt_util_clamp_to_4BUI(val) == rt_util_clamp_to_4BUI(refval))
221  *isequal = 1;
222  break;
223  case PT_8BSI:
224  if (rt_util_clamp_to_8BSI(val) == rt_util_clamp_to_8BSI(refval))
225  *isequal = 1;
226  break;
227  case PT_8BUI:
228  if (rt_util_clamp_to_8BUI(val) == rt_util_clamp_to_8BUI(refval))
229  *isequal = 1;
230  break;
231  case PT_16BSI:
233  *isequal = 1;
234  break;
235  case PT_16BUI:
237  *isequal = 1;
238  break;
239  case PT_32BSI:
241  *isequal = 1;
242  break;
243  case PT_32BUI:
245  *isequal = 1;
246  break;
247  case PT_32BF:
249  *isequal = 1;
250  break;
251  case PT_64BF:
252  if (FLT_EQ(val, refval))
253  *isequal = 1;
254  break;
255  default:
256  rterror("rt_pixtype_compare_clamped_values: Unknown pixeltype %d", pixtype);
257  return ES_ERROR;
258  }
259 
260  return ES_NONE;
261 }
void rterror(const char *fmt,...)
Wrappers used for reporting errors and info.
Definition: rt_context.c:219
int8_t rt_util_clamp_to_8BSI(double value)
Definition: rt_util.c:50
uint8_t rt_util_clamp_to_1BB(double value)
Definition: rt_util.c:35
int32_t rt_util_clamp_to_32BSI(double value)
Definition: rt_util.c:70
@ PT_32BUI
Definition: librtcore.h:196
@ PT_2BUI
Definition: librtcore.h:189
@ PT_32BSI
Definition: librtcore.h:195
@ PT_4BUI
Definition: librtcore.h:190
@ PT_32BF
Definition: librtcore.h:197
@ PT_1BB
Definition: librtcore.h:188
@ PT_16BUI
Definition: librtcore.h:194
@ PT_8BSI
Definition: librtcore.h:191
@ PT_16BSI
Definition: librtcore.h:193
@ PT_64BF
Definition: librtcore.h:198
@ PT_8BUI
Definition: librtcore.h:192
#define FLT_EQ(x, y)
Definition: librtcore.h:2387
uint8_t rt_util_clamp_to_2BUI(double value)
Definition: rt_util.c:40
uint8_t rt_util_clamp_to_8BUI(double value)
Definition: rt_util.c:55
@ ES_NONE
Definition: librtcore.h:182
@ ES_ERROR
Definition: librtcore.h:183
int16_t rt_util_clamp_to_16BSI(double value)
Definition: rt_util.c:60
uint8_t rt_util_clamp_to_4BUI(double value)
Definition: rt_util.c:45
uint16_t rt_util_clamp_to_16BUI(double value)
Definition: rt_util.c:65
uint32_t rt_util_clamp_to_32BUI(double value)
Definition: rt_util.c:75
float rt_util_clamp_to_32F(double value)
Definition: rt_util.c:80

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().

Here is the call graph for this function:
Here is the caller graph for this function: