576{
579 double length;
583
584
585 g = PG_GETARG_GSERIALIZED_P(0);
586
587
590 {
591 PG_RETURN_FLOAT8(0.0);
592 }
593
595
596
598 {
600 PG_RETURN_FLOAT8(0.0);
601 }
602
603
604 use_spheroid = PG_GETARG_BOOL(1);
605
606
608
609
610 if ( ! use_spheroid )
611 s.a =
s.b =
s.radius;
612
613
615
616
617 if ( length < 0.0 )
618 {
619 elog(ERROR, "lwgeom_length_spheroid returned length < 0.0");
620 PG_RETURN_NULL();
621 }
622
623
625
626 PG_FREE_IF_COPY(g, 0);
627 PG_RETURN_FLOAT8(length);
628}
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.
uint32_t gserialized_get_type(const GSERIALIZED *g)
Extract the geometry type from the serialized form (it hides in the anonymous data area,...
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)