502{
506 double area;
509
510
511 g = PG_GETARG_GSERIALIZED_P(0);
512
513
514 use_spheroid = PG_GETARG_BOOL(1);
515
516
518
520
521
523 {
525 PG_RETURN_FLOAT8(0.0);
526 }
527
529 gbox = *(lwgeom->
bbox);
530 else
532
533#ifndef PROJ_GEODESIC
534
535 if ( use_spheroid )
536 {
537
540
541 if ( gbox.
zmax > 0.0 && gbox.
zmin < 0.0 )
543 }
544#endif
545
546
547 if ( ! use_spheroid )
548 s.a =
s.b =
s.radius;
549
550
551 if ( use_spheroid )
553 else
555
556
558 PG_FREE_IF_COPY(g, 0);
559
560
561 if ( area < 0.0 )
562 {
563 elog(ERROR, "lwgeom_area_spher(oid) returned area < 0.0");
564 PG_RETURN_NULL();
565 }
566
567 PG_RETURN_FLOAT8(area);
568}
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)
int lwgeom_calculate_gbox_geodetic(const LWGEOM *geom, GBOX *gbox)
Calculate the geodetic bounding box for an LWGEOM.
double lwgeom_area_spheroid(const LWGEOM *lwgeom, const SPHEROID *spheroid)
Calculate the geodetic area of a lwgeom on the spheroid.
#define LW_TRUE
Return types for functions with status returns.
double lwgeom_area_sphere(const LWGEOM *lwgeom, const SPHEROID *spheroid)
Calculate the geodetic area of a lwgeom on the sphere.
static int lwgeom_is_empty(const LWGEOM *geom)
Return true or false depending on whether a geometry is an "empty" geometry (no vertices members)