PostGIS  2.5.7dev-r@@SVN_REVISION@@

◆ RASTER_setBandIsNoData()

Datum RASTER_setBandIsNoData ( PG_FUNCTION_ARGS  )

Definition at line 852 of file rtpg_band_properties.c.

853 {
854  rt_pgraster *pgraster = NULL;
855  rt_pgraster *pgrtn = NULL;
856  rt_raster raster = NULL;
857  rt_band band = NULL;
858  int32_t bandindex;
859 
860  if (PG_ARGISNULL(0))
861  PG_RETURN_NULL();
862  pgraster = (rt_pgraster *) PG_DETOAST_DATUM(PG_GETARG_DATUM(0));
863 
864  raster = rt_raster_deserialize(pgraster, FALSE);
865  if (!raster) {
866  PG_FREE_IF_COPY(pgraster, 0);
867  elog(ERROR, "RASTER_setBandIsNoData: Could not deserialize raster");
868  PG_RETURN_NULL();
869  }
870 
871  /* Check index is not NULL or smaller than 1 */
872  if (PG_ARGISNULL(1))
873  bandindex = -1;
874  else
875  bandindex = PG_GETARG_INT32(1);
876 
877  if (bandindex < 1)
878  elog(NOTICE, "Invalid band index (must use 1-based). Isnodata flag not set. Returning original raster");
879  else {
880  /* Fetch requested band */
881  band = rt_raster_get_band(raster, bandindex - 1);
882 
883  if (!band)
884  elog(NOTICE, "Could not find raster band of index %d. Isnodata flag not set. Returning original raster", bandindex);
885  else {
887  elog(NOTICE, "Band of index %d has no NODATA so cannot be NODATA. Returning original raster", bandindex);
888  }
889  /* Set the band's nodata value */
890  else {
892  }
893  }
894  }
895 
896  /* Serialize raster again */
897  pgrtn = rt_raster_serialize(raster);
899  PG_FREE_IF_COPY(pgraster, 0);
900  if (!pgrtn) PG_RETURN_NULL();
901 
902  SET_VARSIZE(pgrtn, pgrtn->size);
903  PG_RETURN_POINTER(pgrtn);
904 }
#define FALSE
Definition: dbfopen.c:168
rt_errorstate rt_band_set_isnodata_flag(rt_band band, int flag)
Set isnodata flag value.
Definition: rt_band.c:695
int rt_band_get_hasnodata_flag(rt_band band)
Get hasnodata flag value.
Definition: rt_band.c:674
void rt_raster_destroy(rt_raster raster)
Release memory associated to a raster.
Definition: rt_raster.c:82
void * rt_raster_serialize(rt_raster raster)
Return this raster in serialized form.
Definition: rt_serialize.c:521
rt_raster rt_raster_deserialize(void *serialized, int header_only)
Return a raster from a serialized form.
Definition: rt_serialize.c:725
rt_band rt_raster_get_band(rt_raster raster, int bandNum)
Return Nth band, or NULL if unavailable.
Definition: rt_raster.c:381
band
Definition: ovdump.py:57
raster
Be careful!! Zeros function's input parameter can be a (height x width) array, not (width x height): ...
Definition: rtrowdump.py:121
Struct definitions.
Definition: librtcore.h:2250

References ovdump::band, FALSE, rtrowdump::raster, rt_band_get_hasnodata_flag(), rt_band_set_isnodata_flag(), rt_raster_deserialize(), rt_raster_destroy(), rt_raster_get_band(), rt_raster_serialize(), and rt_raster_serialized_t::size.

Here is the call graph for this function: