PostGIS  2.5.7dev-r@@SVN_REVISION@@

◆ RASTER_minPossibleValue()

Datum RASTER_minPossibleValue ( PG_FUNCTION_ARGS  )

Definition at line 93 of file rtpg_utility.c.

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 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: