PostGIS  2.4.9dev-r@@SVN_REVISION@@

◆ RASTER_out()

Datum RASTER_out ( PG_FUNCTION_ARGS  )

Definition at line 72 of file rtpg_inout.c.

References FALSE, PG_FUNCTION_INFO_V1(), POSTGIS_RT_DEBUG, rtrowdump::raster, RASTER_to_bytea(), rt_raster_deserialize(), rt_raster_destroy(), and rt_raster_to_hexwkb().

Referenced by RASTER_in().

73 {
74  rt_pgraster *pgraster = NULL;
75  rt_raster raster = NULL;
76  uint32_t hexwkbsize = 0;
77  char *hexwkb = NULL;
78 
79  POSTGIS_RT_DEBUG(3, "Starting");
80 
81  if (PG_ARGISNULL(0)) PG_RETURN_NULL();
82  pgraster = (rt_pgraster *) PG_DETOAST_DATUM(PG_GETARG_DATUM(0));
83 
84  raster = rt_raster_deserialize(pgraster, FALSE);
85  if (!raster) {
86  PG_FREE_IF_COPY(pgraster, 0);
87  elog(ERROR, "RASTER_out: Could not deserialize raster");
88  PG_RETURN_NULL();
89  }
90 
91  hexwkb = rt_raster_to_hexwkb(raster, FALSE, &hexwkbsize);
92  if (!hexwkb) {
93  rt_raster_destroy(raster);
94  PG_FREE_IF_COPY(pgraster, 0);
95  elog(ERROR, "RASTER_out: Could not HEX-WKBize raster");
96  PG_RETURN_NULL();
97  }
98 
99  /* Free the raster objects used */
100  rt_raster_destroy(raster);
101  PG_FREE_IF_COPY(pgraster, 0);
102 
103  PG_RETURN_CSTRING(hexwkb);
104 }
raster
Be careful!! Zeros function's input parameter can be a (height x width) array, not (width x height): ...
Definition: rtrowdump.py:121
unsigned int uint32_t
Definition: uthash.h:78
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:669
void rt_raster_destroy(rt_raster raster)
Release memory associated to a raster.
Definition: rt_raster.c:82
#define FALSE
Definition: dbfopen.c:168
Struct definitions.
Definition: librtcore.h:2201
#define POSTGIS_RT_DEBUG(level, msg)
Definition: rtpostgis.h:61
rt_raster rt_raster_deserialize(void *serialized, int header_only)
Return a raster from a serialized form.
Definition: rt_serialize.c:717
Here is the call graph for this function:
Here is the caller graph for this function: