PostGIS  2.5.0beta1dev-r@@SVN_REVISION@@

◆ RASTER_out()

Datum RASTER_out ( PG_FUNCTION_ARGS  )

Definition at line 73 of file rtpg_inout.c.

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

Referenced by RASTER_in().

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) {
94  rt_raster_destroy(raster);
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 */
101  rt_raster_destroy(raster);
102  PG_FREE_IF_COPY(pgraster, 0);
103 
104  PG_RETURN_CSTRING(hexwkb);
105 }
raster
Be careful!! Zeros function's input parameter can be a (height x width) array, not (width x height): ...
Definition: rtrowdump.py:121
unsigned int uint32_t
Definition: uthash.h:78
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:669
void rt_raster_destroy(rt_raster raster)
Release memory associated to a raster.
Definition: rt_raster.c:82
#define FALSE
Definition: dbfopen.c:168
Struct definitions.
Definition: librtcore.h:2250
#define POSTGIS_RT_DEBUG(level, msg)
Definition: rtpostgis.h:61
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: