PostGIS 3.7.0dev-r@@SVN_REVISION@@
Loading...
Searching...
No Matches

◆ 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:82
rt_pixtype
Definition librtcore.h:188
@ PT_32BUI
Definition librtcore.h:197
@ PT_2BUI
Definition librtcore.h:190
@ PT_END
Definition librtcore.h:201
@ PT_4BUI
Definition librtcore.h:191
@ PT_1BB
Definition librtcore.h:189
@ PT_16BUI
Definition librtcore.h:195
@ PT_8BUI
Definition librtcore.h:193
double rt_pixtype_get_min_value(rt_pixtype pixtype)
Return minimum value possible for pixel type.
Definition rt_pixel.c:156

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

Here is the call graph for this function: