477 if ( PG_ARGISNULL(0) ) PG_RETURN_NULL();
479 geom = PG_GETARG_GSERIALIZED_P(0);
485 if ( PG_NARGS() > 1 && ! PG_ARGISNULL(1) )
486 sp.precision_xy = PG_GETARG_INT32(1);
489 if ( PG_NARGS() > 2 && ! PG_ARGISNULL(2) )
490 sp.precision_z = PG_GETARG_INT32(2);
493 if ( PG_NARGS() > 3 && ! PG_ARGISNULL(3) )
494 sp.precision_m = PG_GETARG_INT32(3);
500 if ( PG_NARGS() > 4 && ! PG_ARGISNULL(4) && PG_GETARG_BOOL(4) )
504 if ( PG_NARGS() > 5 && ! PG_ARGISNULL(5) && PG_GETARG_BOOL(5) )
509 twkb =
lwgeom_to_twkb(lwgeom, variant, sp.precision_xy, sp.precision_z, sp.precision_m, &twkb_size);
512 result = palloc(twkb_size + VARHDRSZ);
513 memcpy(VARDATA(result), twkb, twkb_size);
514 SET_VARSIZE(result, twkb_size + VARHDRSZ);
516 PG_RETURN_BYTEA_P(result);
LWGEOM * lwgeom_from_gserialized(const GSERIALIZED *g)
Allocate a new LWGEOM from a GSERIALIZED.
#define TWKB_DEFAULT_PRECISION
uint8_t * lwgeom_to_twkb(const LWGEOM *geom, uint8_t variant, int8_t precision_xy, int8_t precision_z, int8_t precision_m, size_t *twkb_size)
int32_t gserialized_get_srid(const GSERIALIZED *s)
Extract the SRID from the serialized form (it is packed into three bytes so this is a handy function)...