913{
918 int32_t bandindex = 1;
919 const char *outdbpathchar = NULL;
920 int32_t outdbindex = 1;
921 bool forceset =
FALSE;
923
924 int hasnodata;
925 double nodataval = 0.;
926
927 if (PG_ARGISNULL(0))
928 PG_RETURN_NULL();
929 pgraster = (
rt_pgraster *) PG_DETOAST_DATUM(PG_GETARG_DATUM(0));
930
932 if (!raster) {
933 PG_FREE_IF_COPY(pgraster, 0);
934 elog(ERROR, "RASTER_setBandPath: Cannot deserialize raster");
935 PG_RETURN_NULL();
936 }
937
938
939 if (!PG_ARGISNULL(1))
940 bandindex = PG_GETARG_INT32(1);
941
942 if (bandindex < 1)
943 elog(NOTICE, "Invalid band index (must use 1-based). Returning original raster");
944 else {
945
947
948 if (!band)
949 elog(NOTICE, "Cannot find raster band of index %d. Returning original raster", bandindex);
951 elog(NOTICE, "Band of index %d is not out-db. Returning original raster", bandindex);
952 }
953 else {
954
955 if (!PG_ARGISNULL(2))
957 else
959
960
961 if (!PG_ARGISNULL(3))
962 outdbindex = PG_GETARG_INT32(3);
963
964
965 if (!PG_ARGISNULL(4))
966 forceset = PG_GETARG_BOOL(4);
967
969 if (hasnodata)
971
975 hasnodata,
976 nodataval,
977 outdbindex,
978 outdbpathchar,
979 forceset
980 );
981
983 elog(NOTICE, "Cannot change path of band. Returning original raster");
984 else
985
987 }
988 }
989
990
993 PG_FREE_IF_COPY(pgraster, 0);
994 if (!pgrtn) PG_RETURN_NULL();
995
996 SET_VARSIZE(pgrtn, pgrtn->
size);
997 PG_RETURN_POINTER(pgrtn);
998}
int rt_band_get_hasnodata_flag(rt_band band)
Get hasnodata flag value.
void rt_raster_destroy(rt_raster raster)
Release memory associated to a raster.
rt_band rt_raster_replace_band(rt_raster raster, rt_band band, int index)
Replace band at provided index with new band.
void rt_band_destroy(rt_band band)
Destroy a raster band.
uint16_t rt_raster_get_height(rt_raster raster)
rt_errorstate rt_band_get_nodata(rt_band band, double *nodata)
Get NODATA value.
const char * rt_band_get_ext_path(rt_band band)
Return band's external path (only valid when rt_band_is_offline returns non-zero).
rt_band rt_band_new_offline_from_path(uint16_t width, uint16_t height, int hasnodata, double nodataval, uint8_t bandNum, const char *path, int force)
Create an out-db rt_band from path.
uint16_t rt_raster_get_width(rt_raster raster)
void * rt_raster_serialize(rt_raster raster)
Return this raster in serialized form.
int rt_band_is_offline(rt_band band)
Return non-zero if the given band data is on the filesystem.
rt_raster rt_raster_deserialize(void *serialized, int header_only)
Return a raster from a serialized form.
rt_band rt_raster_get_band(rt_raster raster, int bandNum)
Return Nth band, or NULL if unavailable.
raster
Be careful!! Zeros function's input parameter can be a (height x width) array, not (width x height): ...
char * text_to_cstring(const text *textptr)