170 int32_t bandnum = PG_GETARG_INT32(1);
174 bool exclude_nodata_value = PG_GETARG_BOOL(3);
177 double pixvalue = 0.0;
183 elog(NOTICE,
"Invalid band index (must use 1-based). Returning NULL");
187 gser = (
GSERIALIZED*)PG_DETOAST_DATUM(PG_GETARG_DATUM(2));
189 elog(ERROR,
"Attempting to get the value of a pixel with a non-point geometry");
195 elog(ERROR,
"RASTER_getPixelValue: Could not deserialize raster");
200 elog(ERROR,
"Raster and geometry do not have the same SRID");
204 if (PG_NARGS() > 4) {
205 text *resample_text = PG_GETARG_TEXT_P(4);
212 elog(ERROR,
"Could not find raster band of index %d when getting pixel "
213 "value. Returning NULL", bandnum);
226 elog(ERROR,
"Could not convert world coordinate to raster coordinate");
242 if (err !=
ES_NONE || (exclude_nodata_value && isnodata)) {
245 PG_RETURN_FLOAT8(pixvalue);
int32_t gserialized_get_srid(const GSERIALIZED *g)
Extract the SRID from the serialized form (it is packed into three bytes so this is a handy function)...
LWGEOM * lwgeom_from_gserialized(const GSERIALIZED *g)
Allocate a new LWGEOM from a GSERIALIZED.
int gserialized_is_empty(const GSERIALIZED *g)
Check if a GSERIALIZED is empty without deserializing first.
uint32_t gserialized_get_type(const GSERIALIZED *g)
Extract the geometry type from the serialized form (it hides in the anonymous data area,...
void lwgeom_free(LWGEOM *geom)
double lwpoint_get_x(const LWPOINT *point)
#define POINTTYPE
LWTYPE numbers, used internally by PostGIS.
double lwpoint_get_y(const LWPOINT *point)
int32_t rt_raster_get_srid(rt_raster raster)
Get raster's SRID.
void rt_raster_destroy(rt_raster raster)
Release memory associated to a raster.
rt_errorstate rt_raster_geopoint_to_rasterpoint(rt_raster raster, double xw, double yw, double *xr, double *yr, double *igt)
Convert an xw,yw map point to a xr,yr raster point.
rt_errorstate
Enum definitions.
rt_errorstate rt_band_get_pixel_resample(rt_band band, double xr, double yr, rt_resample_type resample, double *r_value, int *r_nodata)
Retrieve a point value from the raster using a world coordinate and selected resampling method.
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.
static LWPOINT * lwgeom_as_lwpoint(const LWGEOM *lwgeom)
raster
Be careful!! Zeros function's input parameter can be a (height x width) array, not (width x height): ...
static rt_resample_type resample_text_to_type(text *txt)