768{
773 double pixvalue = 0;
774 int32_t bandindex = 0;
777 bool skipset =
FALSE;
778
779 if (PG_ARGISNULL(0))
780 PG_RETURN_NULL();
781
782
783 if (PG_ARGISNULL(1))
784 bandindex = -1;
785 else
786 bandindex = PG_GETARG_INT32(1);
787
788 if (bandindex < 1) {
789 elog(NOTICE, "Invalid band index (must use 1-based). Value not set. Returning original raster");
791 }
792
793
794 if (PG_ARGISNULL(2)) {
795 elog(NOTICE, "X coordinate can not be NULL when setting pixel value. Value not set. Returning original raster");
797 }
798 else
799 x = PG_GETARG_INT32(2);
800
801 if (PG_ARGISNULL(3)) {
802 elog(NOTICE, "Y coordinate can not be NULL when setting pixel value. Value not set. Returning original raster");
804 }
805 else
806 y = PG_GETARG_INT32(3);
807
809
810
811 pgraster = (
rt_pgraster *) PG_DETOAST_DATUM_COPY(PG_GETARG_DATUM(0));
812
814 if (!raster) {
815 PG_FREE_IF_COPY(pgraster, 0);
816 elog(ERROR, "RASTER_setPixelValue: Could not deserialize raster");
817 PG_RETURN_NULL();
818 }
819
820 if (!skipset) {
821
823 if (!band) {
824 elog(NOTICE, "Could not find raster band of index %d when setting "
825 "pixel value. Value not set. Returning original raster",
826 bandindex);
827 PG_RETURN_POINTER(pgraster);
828 }
829 else {
830
831 if (PG_ARGISNULL(4)) {
833 elog(NOTICE, "Raster do not have a nodata value defined. "
834 "Set band nodata value first. Nodata value not set. "
835 "Returning original raster");
836 PG_RETURN_POINTER(pgraster);
837 }
838 else {
841 }
842 }
843 else {
844 pixvalue = PG_GETARG_FLOAT8(4);
846 }
847 }
848 }
849
852 PG_FREE_IF_COPY(pgraster, 0);
853 if (!pgrtn)
854 PG_RETURN_NULL();
855
856 SET_VARSIZE(pgrtn, pgrtn->
size);
857 PG_RETURN_POINTER(pgrtn);
858}
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_errorstate rt_band_set_pixel(rt_band band, int x, int y, double val, int *converted)
Set single pixel's value.
rt_errorstate rt_band_get_nodata(rt_band band, double *nodata)
Get NODATA value.
void * rt_raster_serialize(rt_raster raster)
Return this raster in serialized form.
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): ...
#define POSTGIS_RT_DEBUGF(level, msg,...)