double lwcurvepoly_perimeter_2d(const LWCURVEPOLY *poly) { double result=0.0; int i; for (i=0; i<poly->nrings; i++) result += lwgeom_length_2d(poly->rings[i]); return result; }
double lwcompound_length_2d(const LWCOMPOUND *comp) { int i; double length = 0.0; if ( lwgeom_is_empty((LWGEOM*)comp) ) return 0.0; for (i = 0; i < comp->ngeoms; i++) { length += lwgeom_length_2d(comp->geoms[i]); } return length; }
double lwgeom_length_2d(const LWGEOM *geom) { int type = geom->type; if ( type == LINETYPE ) return lwline_length_2d((LWLINE*)geom); else if ( type == CIRCSTRINGTYPE ) return lwcircstring_length_2d((LWCIRCSTRING*)geom); else if ( type == COMPOUNDTYPE ) return lwcompound_length_2d((LWCOMPOUND*)geom); else if ( lwgeom_is_collection(geom) ) { double length = 0.0; int i; LWCOLLECTION *col = (LWCOLLECTION*)geom; for ( i = 0; i < col->ngeoms; i++ ) length += lwgeom_length_2d(col->geoms[i]); return length; } else return 0.0; }