490 bool use_spheroid = PG_GETARG_BOOL(3);
491 LWGEOM *lwgeom1, *lwgeom2;
500 if ( ! use_spheroid )
502 sphere->
a = sphere->
b = sphere->
radius;
508 elog(ERROR,
"geometry_distance_spheroid: Only point/line/polygon supported.\n");
515 elog(ERROR,
"geometry_distance_spheroid: Only point/line/polygon supported.\n");
529 PG_RETURN_FLOAT8(distance);
uint32_t gserialized_get_type(const GSERIALIZED *s)
Extract the geometry type from the serialized form (it hides in the anonymous data area...
void spheroid_init(SPHEROID *s, double a, double b)
Initialize a spheroid object for use in geodetic functions.
LWGEOM * lwgeom_from_gserialized(const GSERIALIZED *g)
Allocate a new LWGEOM from a GSERIALIZED.
void error_if_srid_mismatch(int srid1, int srid2)
#define LW_TRUE
Return types for functions with status returns.
Datum distance(PG_FUNCTION_ARGS)
void lwgeom_set_geodetic(LWGEOM *geom, int value)
Set the FLAGS geodetic bit on geometry an all sub-geometries and pointlists.
#define POINTTYPE
LWTYPE numbers, used internally by PostGIS.
double lwgeom_distance_spheroid(const LWGEOM *lwgeom1, const LWGEOM *lwgeom2, const SPHEROID *spheroid, double tolerance)
Calculate the geodetic distance from lwgeom1 to lwgeom2 on the spheroid.
int32_t gserialized_get_srid(const GSERIALIZED *s)
Extract the SRID from the serialized form (it is packed into three bytes so this is a handy function)...