PostGIS  2.2.8dev-r@@SVN_REVISION@@

◆ RASTER_getPixelWidth()

Datum RASTER_getPixelWidth ( PG_FUNCTION_ARGS  )

Definition at line 366 of file rtpg_raster_properties.c.

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

Referenced by RASTER_getYUpperLeft().

367 {
368  rt_pgraster *pgraster;
370  double xscale;
371  double yskew;
372  double pwidth;
373 
374  if (PG_ARGISNULL(0)) PG_RETURN_NULL();
375  pgraster = (rt_pgraster *)PG_DETOAST_DATUM_SLICE(PG_GETARG_DATUM(0), 0, sizeof(struct rt_raster_serialized_t));
376 
377  raster = rt_raster_deserialize(pgraster, TRUE);
378  if (!raster) {
379  PG_FREE_IF_COPY(pgraster, 0);
380  elog(ERROR, "RASTER_getPixelWidth: Could not deserialize raster");
381  PG_RETURN_NULL();
382  }
383 
384  xscale = rt_raster_get_x_scale(raster);
385  yskew = rt_raster_get_y_skew(raster);
386  pwidth = sqrt(xscale*xscale + yskew*yskew);
387 
388  rt_raster_destroy(raster);
389  PG_FREE_IF_COPY(pgraster, 0);
390 
391  PG_RETURN_FLOAT8(pwidth);
392 }
double rt_raster_get_y_skew(rt_raster raster)
Get skew about the Y axis.
Definition: rt_raster.c:190
raster
Be careful!! Zeros function's input parameter can be a (height x width) array, not (width x height): ...
Definition: rtrowdump.py:121
double rt_raster_get_x_scale(rt_raster raster)
Get scale X in projection units.
Definition: rt_raster.c:150
void rt_raster_destroy(rt_raster raster)
Release memory associated to a raster.
Definition: rt_raster.c:82
Struct definitions.
Definition: librtcore.h:2213
#define TRUE
Definition: dbfopen.c:169
rt_raster rt_raster_deserialize(void *serialized, int header_only)
Return a raster from a serialized form.
Definition: rt_serialize.c:717
Here is the call graph for this function:
Here is the caller graph for this function: