PostGIS 3.0.6dev-r@@SVN_REVISION@@
Loading...
Searching...
No Matches

◆ LWGEOM_recv()

Datum LWGEOM_recv ( PG_FUNCTION_ARGS  )

Definition at line 758 of file lwgeom_inout.c.

759{
760 StringInfo buf = (StringInfo) PG_GETARG_POINTER(0);
761 int32 geom_typmod = -1;
762 GSERIALIZED *geom;
763 LWGEOM *lwgeom;
764
765 if ( (PG_NARGS()>2) && (!PG_ARGISNULL(2)) ) {
766 geom_typmod = PG_GETARG_INT32(2);
767 }
768
769 lwgeom = lwgeom_from_wkb((uint8_t*)buf->data, buf->len, LW_PARSER_CHECK_ALL);
770 if ( !lwgeom )
771 {
772 ereport(ERROR,(errmsg("recv error - invalid geometry")));
773 PG_RETURN_NULL();
774 }
775
776 if ( lwgeom_needs_bbox(lwgeom) )
777 lwgeom_add_bbox(lwgeom);
778
779 /* Set cursor to the end of buffer (so the backend is happy) */
780 buf->cursor = buf->len;
781
782 geom = geometry_serialize(lwgeom);
783 lwgeom_free(lwgeom);
784
785 if ( geom_typmod >= 0 )
786 {
787 geom = postgis_valid_typmod(geom, geom_typmod);
788 POSTGIS_DEBUG(3, "typmod and geometry were consistent");
789 }
790 else
791 {
792 POSTGIS_DEBUG(3, "typmod was -1");
793 }
794
795
796 PG_RETURN_POINTER(geom);
797}
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...
#define LW_PARSER_CHECK_ALL
Definition liblwgeom.h:2061
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:833
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 postgis_valid_typmod().

Here is the call graph for this function: