PostGIS  3.0.6dev-r@@SVN_REVISION@@

◆ LWGEOM_length_ellipsoid_linestring()

Datum LWGEOM_length_ellipsoid_linestring ( PG_FUNCTION_ARGS  )

Definition at line 359 of file lwgeom_spheroid.c.

360 {
361  GSERIALIZED *geom = PG_GETARG_GSERIALIZED_P(0);
362  LWGEOM *lwgeom = lwgeom_from_gserialized(geom);
363  SPHEROID *sphere = (SPHEROID *) PG_GETARG_POINTER(1);
364  double length = 0.0;
365 
366  /* EMPTY things have no length */
367  if ( lwgeom_is_empty(lwgeom) )
368  {
369  lwgeom_free(lwgeom);
370  PG_RETURN_FLOAT8(0.0);
371  }
372 
373  length = lwgeom_length_spheroid(lwgeom, sphere);
374  lwgeom_free(lwgeom);
375  PG_FREE_IF_COPY(geom, 0);
376 
377  /* Something went wrong... */
378  if ( length < 0.0 )
379  {
380  elog(ERROR, "lwgeom_length_spheroid returned length < 0.0");
381  PG_RETURN_NULL();
382  }
383 
384  /* Clean up */
385  PG_RETURN_FLOAT8(length);
386 }
LWGEOM * lwgeom_from_gserialized(const GSERIALIZED *g)
Allocate a new LWGEOM from a GSERIALIZED.
Definition: gserialized.c:239
void lwgeom_free(LWGEOM *geom)
Definition: lwgeom.c:1138
double lwgeom_length_spheroid(const LWGEOM *geom, const SPHEROID *s)
Calculate the geodetic length of a lwgeom on the unit sphere.
Definition: lwgeodetic.c:3297
static int lwgeom_is_empty(const LWGEOM *geom)
Return true or false depending on whether a geometry is an "empty" geometry (no vertices members)
Definition: lwinline.h:193

References lwgeom_free(), lwgeom_from_gserialized(), lwgeom_is_empty(), and lwgeom_length_spheroid().

Here is the call graph for this function: