PostGIS  2.5.0dev-r@@SVN_REVISION@@
Datum LWGEOMFromTWKB ( PG_FUNCTION_ARGS  )

Definition at line 399 of file lwgeom_inout.c.

References geometry_serialize(), LW_PARSER_CHECK_ALL, lwgeom_add_bbox(), lwgeom_free(), lwgeom_from_twkb(), and lwgeom_needs_bbox().

400 {
401  bytea *bytea_twkb = (bytea*)PG_GETARG_BYTEA_P(0);
402  GSERIALIZED *geom;
403  LWGEOM *lwgeom;
404  uint8_t *twkb = (uint8_t*)VARDATA(bytea_twkb);
405 
406  lwgeom = lwgeom_from_twkb(twkb, VARSIZE(bytea_twkb)-VARHDRSZ, LW_PARSER_CHECK_ALL);
407 
408  if ( lwgeom_needs_bbox(lwgeom) )
409  lwgeom_add_bbox(lwgeom);
410 
411  geom = geometry_serialize(lwgeom);
412  lwgeom_free(lwgeom);
413  PG_FREE_IF_COPY(bytea_twkb, 0);
414  PG_RETURN_POINTER(geom);
415 }
void lwgeom_free(LWGEOM *geom)
Definition: lwgeom.c:1137
LWGEOM * lwgeom_from_twkb(const uint8_t *twkb, size_t twkb_size, char check)
WKB inputs must have a declared size, to prevent malformed WKB from reading off the end of the memory...
Definition: lwin_twkb.c:656
GSERIALIZED * geometry_serialize(LWGEOM *lwgeom)
void lwgeom_add_bbox(LWGEOM *lwgeom)
Compute a bbox if not already computed.
Definition: lwgeom.c:679
#define LW_PARSER_CHECK_ALL
Definition: liblwgeom.h:1999
unsigned char uint8_t
Definition: uthash.h:79
int lwgeom_needs_bbox(const LWGEOM *geom)
Check whether or not a lwgeom is big enough to warrant a bounding box.
Definition: lwgeom.c:1190

Here is the call graph for this function: