PostGIS  3.7.0dev-r@@SVN_REVISION@@

◆ rt_band_set_nodata()

rt_errorstate rt_band_set_nodata ( rt_band  band,
double  val,
int *  converted 
)

Set nodata value.

Parameters
band: the band to set nodata value to
val: the nodata value
converted: (optional) if non-zero, value was truncated/clamped/converted
Returns
ES_NONE or ES_ERROR
Parameters
band: the band to set nodata value to
val: the nodata value
converted: if non-zero, value was truncated/clamped/converted
Returns
ES_NONE or ES_ERROR

Definition at line 884 of file rt_band.c.

884  {
885  rt_pixtype pixtype = PT_END;
886  int32_t checkvalint = 0;
887  uint32_t checkvaluint = 0;
888  float checkvalfloat = 0;
889  double checkvaldouble = 0;
890 
891  assert(NULL != band);
892 
893  if (converted != NULL)
894  *converted = 0;
895 
896  pixtype = band->pixtype;
897 
898  RASTER_DEBUGF(3, "rt_band_set_nodata: setting nodata value %g with band type %s", val, rt_pixtype_name(pixtype));
899 
900  /* return -1 on out of range */
901  switch (pixtype) {
902  case PT_1BB: {
903  band->nodataval = rt_util_clamp_to_1BB(val);
904  checkvalint = band->nodataval;
905  break;
906  }
907  case PT_2BUI: {
908  band->nodataval = rt_util_clamp_to_2BUI(val);
909  checkvalint = band->nodataval;
910  break;
911  }
912  case PT_4BUI: {
913  band->nodataval = rt_util_clamp_to_4BUI(val);
914  checkvalint = band->nodataval;
915  break;
916  }
917  case PT_8BSI: {
918  band->nodataval = rt_util_clamp_to_8BSI(val);
919  checkvalint = band->nodataval;
920  break;
921  }
922  case PT_8BUI: {
923  band->nodataval = rt_util_clamp_to_8BUI(val);
924  checkvalint = band->nodataval;
925  break;
926  }
927  case PT_16BSI: {
928  band->nodataval = rt_util_clamp_to_16BSI(val);
929  checkvalint = band->nodataval;
930  break;
931  }
932  case PT_16BUI: {
933  band->nodataval = rt_util_clamp_to_16BUI(val);
934  checkvalint = band->nodataval;
935  break;
936  }
937  case PT_32BSI: {
938  band->nodataval = rt_util_clamp_to_32BSI(val);
939  checkvalint = band->nodataval;
940  break;
941  }
942  case PT_32BUI: {
943  band->nodataval = rt_util_clamp_to_32BUI(val);
944  checkvaluint = band->nodataval;
945  break;
946  }
947  case PT_32BF: {
948  band->nodataval = rt_util_clamp_to_32F(val);
949  checkvalfloat = band->nodataval;
950  break;
951  }
952  case PT_64BF: {
953  band->nodataval = val;
954  checkvaldouble = band->nodataval;
955  break;
956  }
957  default: {
958  rterror("rt_band_set_nodata: Unknown pixeltype %d", pixtype);
959  band->hasnodata = 0;
960  return ES_ERROR;
961  }
962  }
963 
964  RASTER_DEBUGF(3, "rt_band_set_nodata: band->hasnodata = %d", band->hasnodata);
965  RASTER_DEBUGF(3, "rt_band_set_nodata: band->nodataval = %f", band->nodataval);
966  /* the nodata value was just set, so this band has NODATA */
967  band->hasnodata = 1;
968 
969  /* also set isnodata flag to false */
970  band->isnodata = 0;
971 
973  val,
974  checkvalint, checkvaluint,
975  checkvalfloat, checkvaldouble,
976  pixtype
977  ) && converted != NULL) {
978  *converted = 1;
979  }
980 
981  return ES_NONE;
982 }
void rterror(const char *fmt,...) __attribute__((format(printf
Wrappers used for reporting errors and info.
#define RASTER_DEBUGF(level, msg,...)
Definition: librtcore.h:306
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
rt_pixtype
Definition: librtcore.h:187
@ PT_32BUI
Definition: librtcore.h:196
@ PT_2BUI
Definition: librtcore.h:189
@ PT_32BSI
Definition: librtcore.h:195
@ PT_END
Definition: librtcore.h:199
@ 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
int rt_util_dbl_trunc_warning(double initialvalue, int32_t checkvalint, uint32_t checkvaluint, float checkvalfloat, double checkvaldouble, rt_pixtype pixtype)
Definition: rt_util.c:681
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
const char * rt_pixtype_name(rt_pixtype pixtype)
Definition: rt_pixel.c:110
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
band
Definition: ovdump.py:58

References ovdump::band, ES_ERROR, ES_NONE, PT_16BSI, PT_16BUI, PT_1BB, PT_2BUI, PT_32BF, PT_32BSI, PT_32BUI, PT_4BUI, PT_64BF, PT_8BSI, PT_8BUI, PT_END, RASTER_DEBUGF, rt_pixtype_name(), 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(), rt_util_dbl_trunc_warning(), and rterror().

Referenced by RASTER_setBandNoDataValue(), rt_band_new_inline(), rt_band_new_offline(), test_band_metadata(), test_band_pixtype_16BSI(), test_band_pixtype_16BUI(), test_band_pixtype_1BB(), test_band_pixtype_2BUI(), test_band_pixtype_32BF(), test_band_pixtype_32BSI(), test_band_pixtype_32BUI(), test_band_pixtype_4BUI(), test_band_pixtype_64BF(), test_band_pixtype_8BSI(), test_band_pixtype_8BUI(), test_band_reclass(), test_band_stats(), test_band_value_count(), test_raster_colormap(), test_raster_from_band(), test_raster_fully_within_distance(), test_raster_geos_contains(), test_raster_geos_contains_properly(), test_raster_geos_covered_by(), test_raster_geos_covers(), test_raster_geos_overlaps(), test_raster_geos_touches(), test_raster_intersects(), and test_raster_within_distance().

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