474{
477 uint8_t *twkb;
478 size_t twkb_size;
480 bytea *result;
481 srs_precision sp;
482
483
484
485 if ( PG_ARGISNULL(0) ) PG_RETURN_NULL();
486
487 geom = PG_GETARG_GSERIALIZED_P(0);
488
489
491
492
493 if ( PG_NARGS() > 1 && ! PG_ARGISNULL(1) )
494 sp.precision_xy = PG_GETARG_INT32(1);
495
496
497 if ( PG_NARGS() > 2 && ! PG_ARGISNULL(2) )
498 sp.precision_z = PG_GETARG_INT32(2);
499
500
501 if ( PG_NARGS() > 3 && ! PG_ARGISNULL(3) )
502 sp.precision_m = PG_GETARG_INT32(3);
503
504
506
507
508 if ( PG_NARGS() > 4 && ! PG_ARGISNULL(4) && PG_GETARG_BOOL(4) )
510
511
512 if ( PG_NARGS() > 5 && ! PG_ARGISNULL(5) && PG_GETARG_BOOL(5) )
514
515
518
519
520 result = palloc(twkb_size + VARHDRSZ);
521 memcpy(VARDATA(result), twkb, twkb_size);
522 SET_VARSIZE(result, twkb_size + VARHDRSZ);
523
524 PG_RETURN_BYTEA_P(result);
525}
int32_t gserialized_get_srid(const GSERIALIZED *g)
Extract the SRID from the serialized form (it is packed into three bytes so this is a handy function)...
LWGEOM * lwgeom_from_gserialized(const GSERIALIZED *g)
Allocate a new LWGEOM from a GSERIALIZED.
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)
#define TWKB_DEFAULT_PRECISION