33 #include <utils/builtins.h>
57 if (PG_ARGISNULL(0)) PG_RETURN_NULL();
58 pgraster = (
rt_pgraster *) PG_DETOAST_DATUM(PG_GETARG_DATUM(0));
63 PG_FREE_IF_COPY(pgraster, 0);
64 elog(ERROR,
"RASTER_asWKB: Cannot deserialize raster");
69 outasin = PG_GETARG_BOOL(1);
75 PG_FREE_IF_COPY(pgraster, 0);
76 elog(ERROR,
"RASTER_asWKB: Cannot allocate and generate WKB data");
81 result_size = wkb_size + VARHDRSZ;
82 result = (
char *)palloc(result_size);
83 SET_VARSIZE(result, result_size);
84 memcpy(VARDATA(result), wkb, VARSIZE(result) - VARHDRSZ);
89 PG_FREE_IF_COPY(pgraster, 0);
91 PG_RETURN_POINTER(result);
109 if (PG_ARGISNULL(0)) PG_RETURN_NULL();
110 pgraster = (
rt_pgraster *) PG_DETOAST_DATUM(PG_GETARG_DATUM(0));
114 PG_FREE_IF_COPY(pgraster, 0);
115 elog(ERROR,
"RASTER_asHexWKB: Cannot deserialize raster");
119 if (!PG_ARGISNULL(1))
120 outasin = PG_GETARG_BOOL(1);
125 PG_FREE_IF_COPY(pgraster, 0);
126 elog(ERROR,
"RASTER_asHexWKB: Cannot allocate and generate Hex WKB data");
132 PG_FREE_IF_COPY(pgraster, 0);
134 result = cstring_to_text(hexwkb);
136 PG_RETURN_TEXT_P(result);
154 bytea_data = (bytea *) PG_GETARG_BYTEA_P(0);
156 data_len = VARSIZE(bytea_data) - VARHDRSZ;
159 PG_FREE_IF_COPY(bytea_data, 0);
169 PG_RETURN_POINTER(result);
178 text *hexwkb_text = PG_GETARG_TEXT_P(0);
189 PG_FREE_IF_COPY(hexwkb_text, 0);
199 PG_RETURN_POINTER(result);
rt_raster rt_raster_from_wkb(const uint8_t *wkb, uint32_t wkbsize)
Construct an rt_raster from a binary WKB representation.
char * rt_raster_to_hexwkb(rt_raster raster, int outasin, uint32_t *hexwkbsize)
Return this raster in HEXWKB form (null-terminated hex)
void rt_raster_destroy(rt_raster raster)
Release memory associated to a raster.
void * rt_raster_serialize(rt_raster raster)
Return this raster in serialized form.
uint8_t * rt_raster_to_wkb(rt_raster raster, int outasin, uint32_t *wkbsize)
Return this raster in WKB form.
rt_raster rt_raster_from_hexwkb(const char *hexwkb, uint32_t hexwkbsize)
Construct an rt_raster from a text HEXWKB representation.
rt_raster rt_raster_deserialize(void *serialized, int header_only)
Return a raster from a serialized form.
raster
Be careful!! Zeros function's input parameter can be a (height x width) array, not (width x height): ...
char * text_to_cstring(const text *textptr)
Datum RASTER_fromWKB(PG_FUNCTION_ARGS)
PG_FUNCTION_INFO_V1(RASTER_asWKB)
Output is WKB.
Datum RASTER_fromHexWKB(PG_FUNCTION_ARGS)
Datum RASTER_asHexWKB(PG_FUNCTION_ARGS)
Datum RASTER_asWKB(PG_FUNCTION_ARGS)
#define POSTGIS_RT_DEBUG(level, msg)