877 int oldtorastnumbands = 0;
878 int newtorastnumbands = 0;
879 int newbandindex = 0;
882 if (PG_ARGISNULL(0)) PG_RETURN_NULL();
883 pgto = (
rt_pgraster *)PG_DETOAST_DATUM(PG_GETARG_DATUM(0));
887 PG_FREE_IF_COPY(pgto, 0);
888 elog(ERROR,
"RASTER_copyBand: Could not deserialize first raster");
893 if (!PG_ARGISNULL(1)) {
894 pgfrom = (
rt_pgraster *)PG_DETOAST_DATUM(PG_GETARG_DATUM(1));
899 PG_FREE_IF_COPY(pgfrom, 1);
900 PG_FREE_IF_COPY(pgto, 0);
901 elog(ERROR,
"RASTER_copyBand: Could not deserialize second raster");
910 fromband = PG_GETARG_INT32(2);
913 toindex = oldtorastnumbands + 1;
915 toindex = PG_GETARG_INT32(3);
920 fromband - 1, toindex - 1
924 if (newtorastnumbands == oldtorastnumbands || newbandindex == -1) {
925 elog(NOTICE,
"RASTER_copyBand: Could not add band to raster. "
926 "Returning original raster."
931 PG_FREE_IF_COPY(pgfrom, 1);
937 PG_FREE_IF_COPY(pgto, 0);
938 if (!pgrtn) PG_RETURN_NULL();
940 SET_VARSIZE(pgrtn, pgrtn->
size);
941 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)
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.