913 int oldtorastnumbands = 0;
914 int newtorastnumbands = 0;
915 int newbandindex = 0;
918 if (PG_ARGISNULL(0)) PG_RETURN_NULL();
919 pgto = (
rt_pgraster *)PG_DETOAST_DATUM(PG_GETARG_DATUM(0));
923 PG_FREE_IF_COPY(pgto, 0);
924 elog(ERROR,
"RASTER_copyBand: Could not deserialize first raster");
929 if (!PG_ARGISNULL(1)) {
930 pgfrom = (
rt_pgraster *)PG_DETOAST_DATUM(PG_GETARG_DATUM(1));
935 PG_FREE_IF_COPY(pgfrom, 1);
936 PG_FREE_IF_COPY(pgto, 0);
937 elog(ERROR,
"RASTER_copyBand: Could not deserialize second raster");
946 fromband = PG_GETARG_INT32(2);
949 toindex = oldtorastnumbands + 1;
951 toindex = PG_GETARG_INT32(3);
956 fromband - 1, toindex - 1
960 if (newtorastnumbands == oldtorastnumbands || newbandindex == -1) {
961 elog(NOTICE,
"RASTER_copyBand: Could not add band to raster. " 962 "Returning original raster." 967 PG_FREE_IF_COPY(pgfrom, 1);
973 PG_FREE_IF_COPY(pgto, 0);
974 if (!pgrtn) PG_RETURN_NULL();
976 SET_VARSIZE(pgrtn, pgrtn->
size);
977 PG_RETURN_POINTER(pgrtn);
void * rt_raster_serialize(rt_raster raster)
Return this raster in serialized form.
int 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.
void rt_raster_destroy(rt_raster raster)
Release memory associated to a raster.
rt_raster rt_raster_deserialize(void *serialized, int header_only)
Return a raster from a serialized form.