PostGIS  2.2.8dev-r@@SVN_REVISION@@

◆ LWGEOM_recv()

Datum LWGEOM_recv ( PG_FUNCTION_ARGS  )

Definition at line 734 of file lwgeom_inout.c.

References geometry_serialize(), LW_PARSER_CHECK_ALL, lwgeom_add_bbox(), lwgeom_free(), lwgeom_from_wkb(), lwgeom_needs_bbox(), LWGEOM_send(), PG_FUNCTION_INFO_V1(), and postgis_valid_typmod().

Referenced by parse_WKT_lwgeom().

735 {
736  StringInfo buf = (StringInfo) PG_GETARG_POINTER(0);
737  int32 geom_typmod = -1;
738  GSERIALIZED *geom;
739  LWGEOM *lwgeom;
740 
741  if ( (PG_NARGS()>2) && (!PG_ARGISNULL(2)) ) {
742  geom_typmod = PG_GETARG_INT32(2);
743  }
744 
745  lwgeom = lwgeom_from_wkb((uint8_t*)buf->data, buf->len, LW_PARSER_CHECK_ALL);
746 
747  if ( lwgeom_needs_bbox(lwgeom) )
748  lwgeom_add_bbox(lwgeom);
749 
750  /* Set cursor to the end of buffer (so the backend is happy) */
751  buf->cursor = buf->len;
752 
753  geom = geometry_serialize(lwgeom);
754  lwgeom_free(lwgeom);
755 
756  if ( geom_typmod >= 0 )
757  {
758  geom = postgis_valid_typmod(geom, geom_typmod);
759  POSTGIS_DEBUG(3, "typmod and geometry were consistent");
760  }
761  else
762  {
763  POSTGIS_DEBUG(3, "typmod was -1");
764  }
765 
766 
767  PG_RETURN_POINTER(geom);
768 }
unsigned int int32
Definition: shpopen.c:273
GSERIALIZED * postgis_valid_typmod(GSERIALIZED *gser, int32_t typmod)
Check the consistency of the metadata we want to enforce in the typmod: srid, type and dimensionality...
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
#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: