50 char *hexwkb = PG_GETARG_CSTRING(0);
65 PG_RETURN_POINTER(result);
81 if (PG_ARGISNULL(0)) PG_RETURN_NULL();
82 pgraster = (
rt_pgraster *) PG_DETOAST_DATUM(PG_GETARG_DATUM(0));
86 PG_FREE_IF_COPY(pgraster, 0);
87 elog(ERROR,
"RASTER_out: Could not deserialize raster");
94 PG_FREE_IF_COPY(pgraster, 0);
95 elog(ERROR,
"RASTER_out: Could not HEX-WKBize raster");
101 PG_FREE_IF_COPY(pgraster, 0);
103 PG_RETURN_CSTRING(hexwkb);
116 bytea *result = NULL;
119 if (PG_ARGISNULL(0)) PG_RETURN_NULL();
120 pgraster = (
rt_pgraster *) PG_DETOAST_DATUM(PG_GETARG_DATUM(0));
125 PG_FREE_IF_COPY(pgraster, 0);
126 elog(ERROR,
"RASTER_to_bytea: Could not deserialize raster");
134 PG_FREE_IF_COPY(pgraster, 0);
135 elog(ERROR,
"RASTER_to_bytea: Could not allocate and generate WKB data");
140 result_size = wkb_size + VARHDRSZ;
141 result = (bytea *)palloc(result_size);
142 SET_VARSIZE(result, result_size);
143 memcpy(VARDATA(result), wkb, VARSIZE(result) - VARHDRSZ);
148 PG_FREE_IF_COPY(pgraster, 0);
150 PG_RETURN_POINTER(result);
167 if (PG_ARGISNULL(0)) PG_RETURN_NULL();
168 pgraster = (
rt_pgraster *) PG_DETOAST_DATUM(PG_GETARG_DATUM(0));
173 PG_FREE_IF_COPY(pgraster, 0);
174 elog(ERROR,
"RASTER_to_binary: Could not deserialize raster");
178 if (!PG_ARGISNULL(1))
179 outasin = PG_GETARG_BOOL(1);
185 PG_FREE_IF_COPY(pgraster, 0);
186 elog(ERROR,
"RASTER_to_binary: Could not allocate and generate WKB data");
191 result_size = wkb_size + VARHDRSZ;
192 result = (
char *)palloc(result_size);
193 SET_VARSIZE(result, result_size);
194 memcpy(VARDATA(result), wkb, VARSIZE(result) - VARHDRSZ);
199 PG_FREE_IF_COPY(pgraster, 0);
201 PG_RETURN_POINTER(result);
209 pgraster = (
rt_pgraster *) PG_DETOAST_DATUM(PG_GETARG_DATUM(0));
212 PG_FREE_IF_COPY(pgraster, 0);
213 elog(ERROR,
"RASTER_noop: Could not deserialize raster");
221 SET_VARSIZE(result, raster->
size);
222 PG_RETURN_POINTER(result);
Datum RASTER_to_bytea(PG_FUNCTION_ARGS)
void * rt_raster_serialize(rt_raster raster)
Return this raster in serialized form.
raster
Be careful!! Zeros function's input parameter can be a (height x width) array, not (width x height): ...
Datum RASTER_in(PG_FUNCTION_ARGS)
uint8_t * rt_raster_to_wkb(rt_raster raster, int outasin, uint32_t *wkbsize)
Return this raster in WKB form.
PG_FUNCTION_INFO_V1(RASTER_in)
Input is a string with hex chars in it.
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.
Datum RASTER_noop(PG_FUNCTION_ARGS)
rt_raster rt_raster_from_hexwkb(const char *hexwkb, uint32_t hexwkbsize)
Construct an rt_raster from a text HEXWKB representation.
Datum RASTER_to_binary(PG_FUNCTION_ARGS)
#define POSTGIS_RT_DEBUG(level, msg)
rt_raster rt_raster_deserialize(void *serialized, int header_only)
Return a raster from a serialized form.
Datum RASTER_out(PG_FUNCTION_ARGS)