354 bool appendband =
FALSE;
372 if (!PG_ARGISNULL(0)) {
373 pgraster = (
rt_pgraster *) PG_DETOAST_DATUM(PG_GETARG_DATUM(0));
378 PG_FREE_IF_COPY(pgraster, 0);
379 elog(ERROR,
"RASTER_addBandRasterArray: Could not deserialize destination raster");
391 PG_RETURN_POINTER(pgraster);
398 if (!PG_ARGISNULL(2))
399 srcnband = PG_GETARG_INT32(2);
401 elog(NOTICE,
"Invalid band index for source rasters (must be 1-based). Returning original raster");
404 PG_RETURN_POINTER(pgraster);
412 if (!PG_ARGISNULL(3)) {
413 dstnband = PG_GETARG_INT32(3);
417 elog(NOTICE,
"Invalid band index for destination raster (must be 1-based). Returning original raster");
420 PG_RETURN_POINTER(pgraster);
433 if (dstnumbands < 1) {
438 dstnband = dstnumbands + 1;
439 else if (dstnband > dstnumbands) {
440 elog(NOTICE,
"Band index provided for destination raster is greater than the number of bands in the raster. Bands will be appended");
442 dstnband = dstnumbands + 1;
450 array = PG_GETARG_ARRAYTYPE_P(1);
451 etype = ARR_ELEMTYPE(array);
452 get_typlenbyvalalign(etype, &typlen, &typbyval, &typalign);
454 deconstruct_array(array, etype, typlen, typbyval, typalign, &e,
463 for (i = 0; i < n; i++) {
464 if (nulls[i])
continue;
474 if (pgraster != NULL)
475 PG_FREE_IF_COPY(pgraster, 0);
476 elog(ERROR,
"RASTER_addBandRasterArray: Could not deserialize source raster at index %d", i + 1);
484 if (srcnband > srcnumbands - 1) {
485 elog(NOTICE,
"Invalid band index for source raster at index %d. Returning original raster", i + 1);
491 PG_RETURN_POINTER(pgraster);
508 if (pgraster != NULL)
509 PG_FREE_IF_COPY(pgraster, 0);
510 elog(ERROR,
"RASTER_addBandRasterArray: Could not create raster from source raster at index %d", i + 1);
523 elog(NOTICE,
"Could not add band from source raster at index %d to destination raster. Returning original raster", i + 1);
527 if (pgraster != NULL)
528 PG_RETURN_POINTER(pgraster);
541 if (pgraster != NULL)
542 PG_FREE_IF_COPY(pgraster, 0);
546 SET_VARSIZE(pgrtn, pgrtn->
size);
547 PG_RETURN_POINTER(pgrtn);
void rt_raster_destroy(rt_raster raster)
Release memory associated to a raster.
void * rt_raster_serialize(rt_raster raster)
Return this raster in serialized form.
uint16_t rt_raster_get_num_bands(rt_raster raster)
rt_raster rt_raster_from_band(rt_raster raster, uint32_t *bandNums, int count)
Construct a new rt_raster from an existing rt_raster and an array of band numbers.
int rt_raster_copy_band(rt_raster torast, rt_raster fromrast, int fromindex, int toindex)
Copy one band from one raster to another.
rt_raster rt_raster_deserialize(void *serialized, int header_only)
Return a raster from a serialized form.
raster
Be careful!! Zeros function's input parameter can be a (height x width) array, not (width x height): ...
#define POSTGIS_RT_DEBUG(level, msg)
#define POSTGIS_RT_DEBUGF(level, msg,...)