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

◆ lwgeom_length()

double lwgeom_length ( const LWGEOM geom)

Definition at line 2066 of file lwgeom.c.

2067{
2068 int type = geom->type;
2069 if ( type == LINETYPE )
2070 return lwline_length((LWLINE*)geom);
2071 else if ( type == CIRCSTRINGTYPE )
2072 return lwcircstring_length((LWCIRCSTRING*)geom);
2073 else if ( type == COMPOUNDTYPE )
2074 return lwcompound_length((LWCOMPOUND*)geom);
2075 else if ( lwgeom_is_collection(geom) )
2076 {
2077 double length = 0.0;
2078 uint32_t i;
2079 LWCOLLECTION *col = (LWCOLLECTION*)geom;
2080 for ( i = 0; i < col->ngeoms; i++ )
2081 length += lwgeom_length(col->geoms[i]);
2082 return length;
2083 }
2084 else
2085 return 0.0;
2086}
#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:523
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:1125
double lwgeom_length(const LWGEOM *geom)
Definition lwgeom.c:2066
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: