PostGIS  3.0.6dev-r@@SVN_REVISION@@

◆ LWGEOMFromEWKB()

Datum LWGEOMFromEWKB ( PG_FUNCTION_ARGS  )

Definition at line 376 of file lwgeom_inout.c.

377 {
378  bytea *bytea_wkb = PG_GETARG_BYTEA_P(0);
379  GSERIALIZED *geom;
380  LWGEOM *lwgeom;
381  uint8_t *wkb = (uint8_t*)VARDATA(bytea_wkb);
382 
383  lwgeom = lwgeom_from_wkb(wkb, VARSIZE_ANY_EXHDR(bytea_wkb), LW_PARSER_CHECK_ALL);
384  if (!lwgeom)
385  lwpgerror("Unable to parse WKB");
386 
387  if ((PG_NARGS() > 1) && (!PG_ARGISNULL(1)))
388  {
389  int32 srid = PG_GETARG_INT32(1);
390  lwgeom_set_srid(lwgeom, srid);
391  }
392 
393  if ( lwgeom_needs_bbox(lwgeom) )
394  lwgeom_add_bbox(lwgeom);
395 
396  geom = geometry_serialize(lwgeom);
397  lwgeom_free(lwgeom);
398  PG_FREE_IF_COPY(bytea_wkb, 0);
399  PG_RETURN_POINTER(geom);
400 }
#define LW_PARSER_CHECK_ALL
Definition: liblwgeom.h:2061
void lwgeom_set_srid(LWGEOM *geom, int32_t srid)
Set the SRID on an LWGEOM For collections, only the parent gets an SRID, all the children get SRID_UN...
Definition: lwgeom.c:1530
void lwgeom_free(LWGEOM *geom)
Definition: lwgeom.c:1138
int lwgeom_needs_bbox(const LWGEOM *geom)
Check whether or not a lwgeom is big enough to warrant a bounding box.
Definition: lwgeom.c:1191
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:825
void lwgeom_add_bbox(LWGEOM *lwgeom)
Compute a bbox if not already computed.
Definition: lwgeom.c:677
GSERIALIZED * geometry_serialize(LWGEOM *lwgeom)
unsigned int int32
Definition: shpopen.c:273

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().

Here is the call graph for this function:
Here is the caller graph for this function: