PostGIS  2.4.9dev-r@@SVN_REVISION@@

◆ LWGEOMFromEWKB()

Datum LWGEOMFromEWKB ( PG_FUNCTION_ARGS  )

Definition at line 369 of file lwgeom_inout.c.

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

Referenced by LWGEOM_from_bytea(), and LWGEOM_to_text().

370 {
371  bytea *bytea_wkb = (bytea*)PG_GETARG_BYTEA_P(0);
372  int32 srid = 0;
373  GSERIALIZED *geom;
374  LWGEOM *lwgeom;
375  uint8_t *wkb = (uint8_t*)VARDATA(bytea_wkb);
376 
377  lwgeom = lwgeom_from_wkb(wkb, VARSIZE(bytea_wkb)-VARHDRSZ, LW_PARSER_CHECK_ALL);
378 
379  if ( ( PG_NARGS()>1) && ( ! PG_ARGISNULL(1) ))
380  {
381  srid = PG_GETARG_INT32(1);
382  lwgeom_set_srid(lwgeom, srid);
383  }
384 
385  if ( lwgeom_needs_bbox(lwgeom) )
386  lwgeom_add_bbox(lwgeom);
387 
388  geom = geometry_serialize(lwgeom);
389  lwgeom_free(lwgeom);
390  PG_FREE_IF_COPY(bytea_wkb, 0);
391  PG_RETURN_POINTER(geom);
392 }
unsigned int int32
Definition: shpopen.c:273
void lwgeom_free(LWGEOM *geom)
Definition: lwgeom.c:1099
GSERIALIZED * geometry_serialize(LWGEOM *lwgeom)
void lwgeom_add_bbox(LWGEOM *lwgeom)
Compute a bbox if not already computed.
Definition: lwgeom.c:648
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:2014
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:772
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:1152
Here is the call graph for this function:
Here is the caller graph for this function: