PostGIS  3.0.6dev-r@@SVN_REVISION@@

◆ RASTER_out()

Datum RASTER_out ( PG_FUNCTION_ARGS  )

Definition at line 73 of file rtpg_inout.c.

74 {
75  rt_pgraster *pgraster = NULL;
76  rt_raster raster = NULL;
77  uint32_t hexwkbsize = 0;
78  char *hexwkb = NULL;
79 
80  POSTGIS_RT_DEBUG(3, "Starting");
81 
82  if (PG_ARGISNULL(0)) PG_RETURN_NULL();
83  pgraster = (rt_pgraster *) PG_DETOAST_DATUM(PG_GETARG_DATUM(0));
84 
85  raster = rt_raster_deserialize(pgraster, FALSE);
86  if (!raster) {
87  PG_FREE_IF_COPY(pgraster, 0);
88  elog(ERROR, "RASTER_out: Cannot deserialize raster");
89  PG_RETURN_NULL();
90  }
91 
92  hexwkb = rt_raster_to_hexwkb(raster, FALSE, &hexwkbsize);
93  if (!hexwkb) {
95  PG_FREE_IF_COPY(pgraster, 0);
96  elog(ERROR, "RASTER_out: Cannot HEX-WKBize raster");
97  PG_RETURN_NULL();
98  }
99 
100  /* Free the raster objects used */
102  PG_FREE_IF_COPY(pgraster, 0);
103 
104  PG_RETURN_CSTRING(hexwkb);
105 }
#define FALSE
Definition: dbfopen.c:168
char * rt_raster_to_hexwkb(rt_raster raster, int outasin, uint32_t *hexwkbsize)
Return this raster in HEXWKB form (null-terminated hex)
Definition: rt_wkb.c:679
void rt_raster_destroy(rt_raster raster)
Release memory associated to a raster.
Definition: rt_raster.c:82
rt_raster rt_raster_deserialize(void *serialized, int header_only)
Return a raster from a serialized form.
Definition: rt_serialize.c:725
raster
Be careful!! Zeros function's input parameter can be a (height x width) array, not (width x height): ...
Definition: rtrowdump.py:121
#define POSTGIS_RT_DEBUG(level, msg)
Definition: rtpostgis.h:61
Struct definitions.
Definition: librtcore.h:2251

References FALSE, POSTGIS_RT_DEBUG, rtrowdump::raster, rt_raster_deserialize(), rt_raster_destroy(), and rt_raster_to_hexwkb().

Here is the call graph for this function: