PostGIS  2.1.10dev-r@@SVN_REVISION@@
Datum RASTER_getPixelWidth ( PG_FUNCTION_ARGS  )

Definition at line 2057 of file rt_pg.c.

References rtrowdump::raster, rt_raster_deserialize(), rt_raster_destroy(), rt_raster_get_x_scale(), rt_raster_get_y_skew(), and TRUE.

2058 {
2059  rt_pgraster *pgraster;
2060  rt_raster raster;
2061  double xscale;
2062  double yskew;
2063  double pwidth;
2064 
2065  if (PG_ARGISNULL(0)) PG_RETURN_NULL();
2066  pgraster = (rt_pgraster *)PG_DETOAST_DATUM_SLICE(PG_GETARG_DATUM(0), 0, sizeof(struct rt_raster_serialized_t));
2067 
2068  raster = rt_raster_deserialize(pgraster, TRUE);
2069  if (!raster) {
2070  PG_FREE_IF_COPY(pgraster, 0);
2071  elog(ERROR, "RASTER_getPixelWidth: Could not deserialize raster");
2072  PG_RETURN_NULL();
2073  }
2074 
2075  xscale = rt_raster_get_x_scale(raster);
2076  yskew = rt_raster_get_y_skew(raster);
2077  pwidth = sqrt(xscale*xscale + yskew*yskew);
2078 
2079  rt_raster_destroy(raster);
2080  PG_FREE_IF_COPY(pgraster, 0);
2081 
2082  PG_RETURN_FLOAT8(pwidth);
2083 }
void rt_raster_destroy(rt_raster raster)
Release memory associated to a raster.
Definition: rt_api.c:5387
double rt_raster_get_y_skew(rt_raster raster)
Get skew about the Y axis.
Definition: rt_api.c:5495
tuple raster
Be careful!! Zeros function's input parameter can be a (height x width) array, not (width x height): ...
Definition: rtrowdump.py:123
double rt_raster_get_x_scale(rt_raster raster)
Get scale X in projection units.
Definition: rt_api.c:5455
Struct definitions.
Definition: rt_api.h:2175
rt_raster rt_raster_deserialize(void *serialized, int header_only)
Return a raster from a serialized form.
Definition: rt_api.c:8350
#define TRUE
Definition: dbfopen.c:170

Here is the call graph for this function: