193 {
194 Oid etype;
195 Datum *e;
196 bool *nulls;
197 int16 typlen;
198 bool typbyval;
199 char typalign;
200 int n = 0;
201
202 HeapTupleHeader tup;
203 bool isnull;
204 Datum tupv;
205
206 int i;
207 int j;
209
210 if (arg == NULL || array == NULL) {
211 elog(ERROR, "rtpg_nmapalgebra_rastbandarg_process: NULL values not permitted for parameters");
212 return 0;
213 }
214
215 etype = ARR_ELEMTYPE(array);
216 get_typlenbyvalalign(etype, &typlen, &typbyval, &typalign);
217
218 deconstruct_array(
219 array,
220 etype,
221 typlen, typbyval, typalign,
222 &e, &nulls, &n
223 );
224
225 if (!n) {
226 elog(ERROR, "rtpg_nmapalgebra_rastbandarg_process: Invalid argument for rastbandarg");
227 return 0;
228 }
229
230
239 if (
244 arg->
nband == NULL ||
247 ) {
248 elog(ERROR, "rtpg_nmapalgebra_rastbandarg_process: Could not allocate memory for processing rastbandarg");
249 return 0;
250 }
251
252 *allnull = 0;
253 *allempty = 0;
254 *noband = 0;
255
256
257 for (i = 0; i < n; i++) {
258 if (nulls[i]) {
260 continue;
261 }
262
264
270
271
272 tup = (HeapTupleHeader) DatumGetPointer(e[i]);
273 if (NULL == tup) {
274 elog(ERROR, "rtpg_nmapalgebra_rastbandarg_process: Invalid argument for rastbandarg at index %d", i);
275 return 0;
276 }
277
278
280 tupv = GetAttributeByName(tup, "rast", &isnull);
281 if (isnull) {
282 elog(NOTICE, "First argument (nband) of rastbandarg at index %d is NULL. Assuming NULL raster", i);
285
286 (*allnull)++;
287 (*allempty)++;
288 (*noband)++;
289
290 continue;
291 }
292
294
295
296 for (j = 0; j < i; j++) {
301 break;
302 }
303 }
304
308 if (arg->
raster[i] == NULL) {
309 elog(ERROR, "rtpg_nmapalgebra_rastbandarg_process: Could not deserialize raster at index %d", i);
310 return 0;
311 }
312 }
313
314
317 (*allempty)++;
318 (*noband)++;
319
320 continue;
321 }
322
323
325 tupv = GetAttributeByName(tup, "nband", &isnull);
326 if (isnull) {
328 elog(NOTICE, "First argument (nband) of rastbandarg at index %d is NULL. Assuming nband = %d", i, nband);
329 }
330 else
331 nband = DatumGetInt32(tupv);
332
333 if (nband < 1) {
334 elog(ERROR, "rtpg_nmapalgebra_rastbandarg_process: Band number provided for rastbandarg at index %d must be greater than zero (1-based)", i);
335 return 0;
336 }
337
341 (*noband)++;
343 }
344 }
345
353 if (
358 arg->
nband == NULL ||
360 ) {
361 elog(ERROR, "rtpg_nmapalgebra_rastbandarg_process: Could not reallocate memory for processed rastbandarg");
362 return 0;
363 }
364 }
365
367
368 return 1;
369}
int rt_raster_has_band(rt_raster raster, int nband)
Return TRUE if the raster has a band of this number.
rt_raster rt_raster_deserialize(void *serialized, int header_only)
Return a raster from a serialized form.
int rt_raster_is_empty(rt_raster raster)
Return TRUE if the raster is empty.
#define POSTGIS_RT_DEBUG(level, msg)
#define POSTGIS_RT_DEBUGF(level, msg,...)