PostGIS  2.1.10dev-r@@SVN_REVISION@@
Datum geography_send ( PG_FUNCTION_ARGS  )

Definition at line 673 of file geography_inout.c.

References lwgeom_free(), lwgeom_from_gserialized(), lwgeom_to_wkb(), result, and WKB_EXTENDED.

674 {
675  LWGEOM *lwgeom = NULL;
676  GSERIALIZED *g = NULL;
677  size_t size_result;
678  uint8_t *wkb;
679  bytea *result;
680 
681  g = (GSERIALIZED*)PG_DETOAST_DATUM(PG_GETARG_DATUM(0));
682  lwgeom = lwgeom_from_gserialized(g);
683  wkb = lwgeom_to_wkb(lwgeom, WKB_EXTENDED, &size_result);
684  lwgeom_free(lwgeom);
685 
686  result = palloc(size_result + VARHDRSZ);
687  SET_VARSIZE(result, size_result + VARHDRSZ);
688  memcpy(VARDATA(result), wkb, size_result);
689  pfree(wkb);
690 
691  PG_RETURN_POINTER(result);
692 }
LWGEOM * lwgeom_from_gserialized(const GSERIALIZED *g)
Allocate a new LWGEOM from a GSERIALIZED.
void lwgeom_free(LWGEOM *geom)
Definition: lwgeom.c:1006
char ** result
Definition: liblwgeom.h:218
uint8_t * lwgeom_to_wkb(const LWGEOM *geom, uint8_t variant, size_t *size_out)
Convert LWGEOM to a char* in WKB format.
Definition: lwout_wkb.c:692
#define WKB_EXTENDED
Definition: liblwgeom.h:1769

Here is the call graph for this function: