PostGIS  2.5.0dev-r@@SVN_REVISION@@

◆ LWGEOMFromEWKB()

Datum LWGEOMFromEWKB ( PG_FUNCTION_ARGS  )

Definition at line 370 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().

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