PostGIS  2.4.9dev-r@@SVN_REVISION@@

◆ RASTER_minPossibleValue()

Datum RASTER_minPossibleValue ( PG_FUNCTION_ARGS  )

Definition at line 93 of file rtpg_utility.c.

References PG_FUNCTION_INFO_V1(), PT_16BUI, PT_1BB, PT_2BUI, PT_32BUI, PT_4BUI, PT_8BUI, PT_END, RASTER_memsize(), rt_pixtype_get_min_value(), and rt_pixtype_index_from_name().

Referenced by RASTER_gdal_version().

94 {
95  text *pixeltypetext = NULL;
96  char *pixeltypechar = NULL;
97  rt_pixtype pixtype = PT_END;
98  double pixsize = 0;
99 
100  if (PG_ARGISNULL(0))
101  PG_RETURN_NULL();
102 
103  pixeltypetext = PG_GETARG_TEXT_P(0);
104  pixeltypechar = text_to_cstring(pixeltypetext);
105 
106  pixtype = rt_pixtype_index_from_name(pixeltypechar);
107  if (pixtype == PT_END) {
108  elog(ERROR, "RASTER_minPossibleValue: Invalid pixel type: %s", pixeltypechar);
109  PG_RETURN_NULL();
110  }
111 
112  pixsize = rt_pixtype_get_min_value(pixtype);
113 
114  /*
115  correct pixsize of unsigned pixel types
116  example: for PT_8BUI, the value is CHAR_MIN but if char is signed,
117  the value returned is -127 instead of 0.
118  */
119  switch (pixtype) {
120  case PT_1BB:
121  case PT_2BUI:
122  case PT_4BUI:
123  case PT_8BUI:
124  case PT_16BUI:
125  case PT_32BUI:
126  pixsize = 0;
127  break;
128  default:
129  break;
130  }
131 
132  PG_RETURN_FLOAT8(pixsize);
133 }
rt_pixtype
Definition: librtcore.h:185
rt_pixtype rt_pixtype_index_from_name(const char *pixname)
Definition: rt_pixel.c:80
double rt_pixtype_get_min_value(rt_pixtype pixtype)
Return minimum value possible for pixel type.
Definition: rt_pixel.c:148
Here is the call graph for this function:
Here is the caller graph for this function: