624{
627 double length;
630
631
632 g = PG_GETARG_GSERIALIZED_P(0);
634
635
637 {
639 PG_RETURN_FLOAT8(0.0);
640 }
641
642
643 use_spheroid = PG_GETARG_BOOL(1);
644
645
647
648
649 if ( ! use_spheroid )
650 s.a =
s.b =
s.radius;
651
652
654
655
656 if ( length < 0.0 )
657 {
658 elog(ERROR, "lwgeom_length_spheroid returned length < 0.0");
659 PG_RETURN_NULL();
660 }
661
662
664
665 PG_FREE_IF_COPY(g, 0);
666 PG_RETURN_FLOAT8(length);
667}
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.
void lwgeom_free(LWGEOM *geom)
double lwgeom_length_spheroid(const LWGEOM *geom, const SPHEROID *s)
Calculate the geodetic length of a lwgeom on the unit sphere.
#define LW_TRUE
Return types for functions with status returns.
static int lwgeom_is_empty(const LWGEOM *geom)
Return true or false depending on whether a geometry is an "empty" geometry (no vertices members)