PostGIS  2.1.10dev-r@@SVN_REVISION@@
rt_raster rt_raster_from_hexwkb ( const char *  hexwkb,
uint32_t  hexwkbsize 
)

Construct an rt_raster from a text HEXWKB representation.

Parameters
hexwkb: an hex-encoded stream
hexwkbsize: size (in bytes) of the hexwkb stream
Returns
an rt_raster or NULL on error (out of memory or malformed WKB).

Definition at line 7799 of file rt_api.c.

References parse_hex(), RASTER_DEBUGF, rt_raster_from_wkb(), rtalloc(), rtdealloc(), and rterror().

Referenced by RASTER_in(), and test_raster_wkb().

7799  {
7800  rt_raster ret = NULL;
7801  uint8_t* wkb = NULL;
7802  uint32_t wkbsize = 0;
7803  uint32_t i = 0;
7804 
7805  assert(NULL != hexwkb);
7806 
7807  RASTER_DEBUGF(3, "input wkb: %s", hexwkb);
7808  RASTER_DEBUGF(3, "input wkbsize: %d", hexwkbsize);
7809 
7810  if (hexwkbsize % 2) {
7811  rterror("rt_raster_from_hexwkb: Raster HEXWKB input must have an even number of characters");
7812  return NULL;
7813  }
7814  wkbsize = hexwkbsize / 2;
7815 
7816  wkb = rtalloc(wkbsize);
7817  if (!wkb) {
7818  rterror("rt_raster_from_hexwkb: Out of memory allocating memory for decoding HEXWKB");
7819  return NULL;
7820  }
7821 
7822  /* parse full hex */
7823  for (i = 0; i < wkbsize; ++i) {
7824  wkb[i] = parse_hex((char*) & (hexwkb[i * 2]));
7825  }
7826 
7827  ret = rt_raster_from_wkb(wkb, wkbsize);
7828  rtdealloc(wkb); /* as long as rt_raster_from_wkb copies memory */
7829 
7830  return ret;
7831 }
void rtdealloc(void *mem)
Definition: rt_api.c:882
#define RASTER_DEBUGF(level, msg,...)
Definition: rt_api.h:285
void * rtalloc(size_t size)
Raster core memory management functions.
Definition: rt_api.c:867
void rterror(const char *fmt,...)
Raster core error and info handlers.
Definition: rt_api.c:895
uint8_t parse_hex(char *str)
Convert a single hex digit into the corresponding char.
Definition: lwgeom_api.c:604
rt_raster rt_raster_from_wkb(const uint8_t *wkb, uint32_t wkbsize)
Construct an rt_raster from a binary WKB representation.
Definition: rt_api.c:7669

Here is the call graph for this function:

Here is the caller graph for this function: