PostGIS 3.7.0dev-r@@SVN_REVISION@@
Loading...
Searching...
No Matches

◆ 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.
void lwgeom_free(LWGEOM *geom)
Definition lwgeom.c:1246
double lwgeom_length_spheroid(const LWGEOM *geom, const SPHEROID *s)
Calculate the geodetic length of a lwgeom on the unit 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)
Definition lwinline.h:199

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

Here is the call graph for this function: