PostGIS 3.7.0dev-r@@SVN_REVISION@@
Loading...
Searching...
No Matches

◆ 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
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) {
124 rt_raster_destroy(raster);
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 */
131 rt_raster_destroy(raster);
132 PG_FREE_IF_COPY(pgraster, 0);
133
134 result = cstring_to_text(hexwkb);
135
136 PG_RETURN_TEXT_P(result);
137}
char result[OUT_DOUBLE_BUFFER_SIZE]
Definition cu_print.c:267
#define FALSE
Definition dbfopen.c:72
void rt_raster_destroy(rt_raster raster)
Release memory associated to a raster.
Definition rt_raster.c:86
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:693
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): ...
Definition rtrowdump.py:125
#define POSTGIS_RT_DEBUG(level, msg)
Definition rtpostgis.h:65
Struct definitions.
Definition librtcore.h:2452

References FALSE, POSTGIS_RT_DEBUG, result, rt_raster_deserialize(), rt_raster_destroy(), and rt_raster_to_hexwkb().

Here is the call graph for this function: