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

Definition at line 333 of file lwgeom_inout.c.

References geometry_serialize(), LW_PARSER_CHECK_ALL, lwgeom_add_bbox(), lwgeom_free(), lwgeom_from_wkb(), lwgeom_needs_bbox(), and lwgeom_set_srid().

Referenced by LWGEOM_from_bytea().

334 {
335  bytea *bytea_wkb = (bytea*)PG_GETARG_BYTEA_P(0);
336  int32 srid = 0;
337  GSERIALIZED *geom;
338  LWGEOM *lwgeom;
339  uint8_t *wkb = (uint8_t*)VARDATA(bytea_wkb);
340 
341  lwgeom = lwgeom_from_wkb(wkb, VARSIZE(bytea_wkb)-VARHDRSZ, LW_PARSER_CHECK_ALL);
342 
343  if ( ( PG_NARGS()>1) && ( ! PG_ARGISNULL(1) ))
344  {
345  srid = PG_GETARG_INT32(1);
346  lwgeom_set_srid(lwgeom, srid);
347  }
348 
349  if ( lwgeom_needs_bbox(lwgeom) )
350  lwgeom_add_bbox(lwgeom);
351 
352  geom = geometry_serialize(lwgeom);
353  lwgeom_free(lwgeom);
354  PG_FREE_IF_COPY(bytea_wkb, 0);
355  PG_RETURN_POINTER(geom);
356 }
void lwgeom_free(LWGEOM *geom)
Definition: lwgeom.c:1006
LWGEOM * geom
GSERIALIZED * geometry_serialize(LWGEOM *lwgeom)
void lwgeom_add_bbox(LWGEOM *lwgeom)
Compute a bbox if not already computed.
Definition: lwgeom.c:555
void lwgeom_set_srid(LWGEOM *geom, int srid)
Set the SRID on an LWGEOM For collections, only the parent gets an SRID, all the children get SRID_UN...
#define LW_PARSER_CHECK_ALL
Definition: liblwgeom.h:1707
LWGEOM * lwgeom_from_wkb(const uint8_t *wkb, const size_t wkb_size, const char check)
WKB inputs must have a declared size, to prevent malformed WKB from reading off the end of the memory...
Definition: lwin_wkb.c:728
int lwgeom_needs_bbox(const LWGEOM *geom)
Check whether or not a lwgeom is big enough to warrant a bounding box.
Definition: lwgeom.c:1059

Here is the call graph for this function:

Here is the caller graph for this function: