PostGIS  2.2.8dev-r@@SVN_REVISION@@

◆ LWGEOMFromEWKB()

Datum LWGEOMFromEWKB ( PG_FUNCTION_ARGS  )

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

346 {
347  bytea *bytea_wkb = (bytea*)PG_GETARG_BYTEA_P(0);
348  int32 srid = 0;
349  GSERIALIZED *geom;
350  LWGEOM *lwgeom;
351  uint8_t *wkb = (uint8_t*)VARDATA(bytea_wkb);
352 
353  lwgeom = lwgeom_from_wkb(wkb, VARSIZE(bytea_wkb)-VARHDRSZ, LW_PARSER_CHECK_ALL);
354 
355  if ( ( PG_NARGS()>1) && ( ! PG_ARGISNULL(1) ))
356  {
357  srid = PG_GETARG_INT32(1);
358  lwgeom_set_srid(lwgeom, srid);
359  }
360 
361  if ( lwgeom_needs_bbox(lwgeom) )
362  lwgeom_add_bbox(lwgeom);
363 
364  geom = geometry_serialize(lwgeom);
365  lwgeom_free(lwgeom);
366  PG_FREE_IF_COPY(bytea_wkb, 0);
367  PG_RETURN_POINTER(geom);
368 }
unsigned int int32
Definition: shpopen.c:273
void lwgeom_free(LWGEOM *geom)
Definition: lwgeom.c:1050
GSERIALIZED * geometry_serialize(LWGEOM *lwgeom)
void lwgeom_add_bbox(LWGEOM *lwgeom)
Compute a bbox if not already computed.
Definition: lwgeom.c:599
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:1870
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:754
int lwgeom_needs_bbox(const LWGEOM *geom)
Check whether or not a lwgeom is big enough to warrant a bounding box.
Definition: lwgeom.c:1103
Here is the call graph for this function:
Here is the caller graph for this function: