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

◆ lwgeom_length()

double lwgeom_length ( const LWGEOM geom)

Definition at line 2038 of file lwgeom.c.

2039{
2040 int type = geom->type;
2041 if ( type == LINETYPE )
2042 return lwline_length((LWLINE*)geom);
2043 else if ( type == CIRCSTRINGTYPE )
2044 return lwcircstring_length((LWCIRCSTRING*)geom);
2045 else if ( type == COMPOUNDTYPE )
2046 return lwcompound_length((LWCOMPOUND*)geom);
2047 else if ( lwgeom_is_collection(geom) )
2048 {
2049 double length = 0.0;
2050 uint32_t i;
2051 LWCOLLECTION *col = (LWCOLLECTION*)geom;
2052 for ( i = 0; i < col->ngeoms; i++ )
2053 length += lwgeom_length(col->geoms[i]);
2054 return length;
2055 }
2056 else
2057 return 0.0;
2058}
#define COMPOUNDTYPE
Definition liblwgeom.h:110
#define LINETYPE
Definition liblwgeom.h:103
#define CIRCSTRINGTYPE
Definition liblwgeom.h:109
double lwcompound_length(const LWCOMPOUND *comp)
Definition lwcompound.c:112
double lwline_length(const LWLINE *line)
Definition lwline.c:513
double lwcircstring_length(const LWCIRCSTRING *circ)
int lwgeom_is_collection(const LWGEOM *geom)
Determine whether a LWGEOM contains sub-geometries or not This basically just checks that the struct ...
Definition lwgeom.c:1097
double lwgeom_length(const LWGEOM *geom)
Definition lwgeom.c:2038
uint32_t ngeoms
Definition liblwgeom.h:580
LWGEOM ** geoms
Definition liblwgeom.h:575
uint8_t type
Definition liblwgeom.h:462

References CIRCSTRINGTYPE, COMPOUNDTYPE, LWCOLLECTION::geoms, LINETYPE, lwcircstring_length(), lwcompound_length(), lwgeom_is_collection(), lwgeom_length(), lwline_length(), LWCOLLECTION::ngeoms, and LWGEOM::type.

Referenced by gserialized_distance_nd(), lwcurvepoly_perimeter(), lwgeom_length(), LWGEOM_length_linestring(), and test_geography_substring().

Here is the call graph for this function:
Here is the caller graph for this function: