PostGIS  2.5.7dev-r@@SVN_REVISION@@

◆ RASTER_asHexWKB()

Datum RASTER_asHexWKB ( PG_FUNCTION_ARGS  )

Definition at line 98 of file rtpg_wkb.c.

99 {
100  rt_pgraster *pgraster = NULL;
101  rt_raster raster = NULL;
102  int outasin = FALSE;
103  uint32_t hexwkbsize = 0;
104  char *hexwkb = NULL;
105  text *result = NULL;
106 
107  POSTGIS_RT_DEBUG(3, "Starting");
108 
109  if (PG_ARGISNULL(0)) PG_RETURN_NULL();
110  pgraster = (rt_pgraster *) PG_DETOAST_DATUM(PG_GETARG_DATUM(0));
111 
112  raster = rt_raster_deserialize(pgraster, FALSE);
113  if (!raster) {
114  PG_FREE_IF_COPY(pgraster, 0);
115  elog(ERROR, "RASTER_asHexWKB: Cannot deserialize raster");
116  PG_RETURN_NULL();
117  }
118 
119  if (!PG_ARGISNULL(1))
120  outasin = PG_GETARG_BOOL(1);
121 
122  hexwkb = rt_raster_to_hexwkb(raster, outasin, &hexwkbsize);
123  if (!hexwkb) {
125  PG_FREE_IF_COPY(pgraster, 0);
126  elog(ERROR, "RASTER_asHexWKB: Cannot allocate and generate Hex WKB data");
127  PG_RETURN_NULL();
128  }
129 
130  /* Free the raster objects used */
132  PG_FREE_IF_COPY(pgraster, 0);
133 
134  result = cstring_to_text(hexwkb);
135 
136  PG_RETURN_TEXT_P(result);
137 }
#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:2250
unsigned int uint32_t
Definition: uthash.h:78

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: