564{
567 double length;
571
572
573 g = PG_GETARG_GSERIALIZED_P(0);
574
575
578 {
579 PG_RETURN_FLOAT8(0.0);
580 }
581
583
584
586 {
588 PG_RETURN_FLOAT8(0.0);
589 }
590
591
592 use_spheroid = PG_GETARG_BOOL(1);
593
594
596
597
598 if ( ! use_spheroid )
599 s.a =
s.b =
s.radius;
600
601
603
604
605 if ( length < 0.0 )
606 {
607 elog(ERROR, "lwgeom_length_spheroid returned length < 0.0");
608 PG_RETURN_NULL();
609 }
610
611
613
614 PG_FREE_IF_COPY(g, 0);
615 PG_RETURN_FLOAT8(length);
616}
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)