コード例 #1
0
ファイル: lwgeom.c プロジェクト: abuhamid/bd_geonode
double lwgeom_perimeter_2d(const LWGEOM *geom)
{
	int type = geom->type;
	if ( type == POLYGONTYPE )
		return lwpoly_perimeter_2d((LWPOLY*)geom);
	else if ( type == CURVEPOLYTYPE )
		return lwcurvepoly_perimeter_2d((LWCURVEPOLY*)geom);
	else if ( type == TRIANGLETYPE )
		return lwtriangle_perimeter_2d((LWTRIANGLE*)geom);
	else if ( type == POLYHEDRALSURFACETYPE || type == TINTYPE )
	{
		return tgeom_perimeter(tgeom_from_lwgeom(geom));		
	}
	else if ( lwgeom_is_collection(geom) )
	{
		double perimeter = 0.0;
		int i;
		LWCOLLECTION *col = (LWCOLLECTION*)geom;
		for ( i = 0; i < col->ngeoms; i++ )
			perimeter += lwgeom_perimeter_2d(col->geoms[i]);
		return perimeter;
	}
	else
		return 0.0;
}
コード例 #2
0
ファイル: libtgeom.c プロジェクト: bnordgren/postgis
/*
 * Return a TSERIALIZED pointer from an LWGEOM
 */
TSERIALIZED*
tserialized_from_lwgeom(LWGEOM *lwgeom)
{
	assert(lwgeom);

	return tgeom_serialize(tgeom_from_lwgeom(lwgeom));
}
コード例 #3
0
ファイル: libtgeom.c プロジェクト: bnordgren/postgis
/*
 * Indicate if an given LWGEOM is or not a solid
 */
int
lwgeom_is_solid(LWGEOM *lwgeom)
{
	int solid=0;
	TGEOM *tgeom;

	assert(lwgeom);

	/* Obvious case who could'nt be solid */
	if (lwgeom->type != POLYHEDRALSURFACETYPE && lwgeom->type != TINTYPE) return 0;
	if (!FLAGS_GET_Z(lwgeom->flags)) return 0;

	/* Use TGEOM convert to know */
	tgeom = tgeom_from_lwgeom(lwgeom);
	solid = FLAGS_GET_SOLID(tgeom->flags);
	tgeom_free(tgeom);

	return solid;
}