Exemple #1
0
double lwcompound_length_2d(const LWCOMPOUND *comp)
{
	double length = 0.0;
	LWLINE *line;
	if ( lwgeom_is_empty((LWGEOM*)comp) )
		return 0.0;
	line = lwcompound_stroke(comp, 32);
	length = lwline_length_2d(line);
	lwline_free(line);
	return length;
}
Exemple #2
0
double lwcircstring_length_2d(const LWCIRCSTRING *circ)
{
	double length = 0.0;
	LWLINE *line;
	if ( lwcircstring_is_empty(circ) )
		return 0.0;
	line = lwcircstring_segmentize(circ, 32);
	length = lwline_length_2d(line);
	lwline_free(line);
	return length;
}
Exemple #3
0
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;
}