PostGIS  3.0.6dev-r@@SVN_REVISION@@

◆ RASTER_minPossibleValue()

Datum RASTER_minPossibleValue ( PG_FUNCTION_ARGS  )

Definition at line 97 of file rtpg_utility.c.

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

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

Here is the call graph for this function: