Esempio n. 1
0
/* private */
void
MinimumDiameter::computeWidthConvex(const Geometry *geom)
{
	//System.out.println("Input = " + geom);
	CoordinateSequence* pts=NULL;
	if (typeid(*geom)==typeid(Polygon))
		pts=((Polygon*)geom)->getExteriorRing()->getCoordinates();
	else
		pts=geom->getCoordinates();

	// special cases for lines or points or degenerate rings
	if (pts->getSize()==0) {
		minWidth=0.0;
		minWidthPt=NULL;
		minBaseSeg=NULL;
	} else if (pts->getSize()==1) {
		minWidth = 0.0;
		minWidthPt=new Coordinate(pts->getAt(0));
		minBaseSeg->p0=pts->getAt(0);
		minBaseSeg->p1=pts->getAt(0);
	} else if (pts->getSize()==2 || pts->getSize()==3) {
		minWidth = 0.0;
		minWidthPt=new Coordinate(pts->getAt(0));
		minBaseSeg->p0=pts->getAt(0);
		minBaseSeg->p1=pts->getAt(1);
	} else
		computeConvexRingMinDiameter(pts);
	delete pts; 
}
Esempio n. 2
0
/* private */
void
MinimumDiameter::computeWidthConvex(const Geometry *geom)
{
	//System.out.println("Input = " + geom);
	CoordinateSequence* pts=NULL;
	if (typeid(*geom)==typeid(Polygon))
	{
		const Polygon* p = dynamic_cast<const Polygon*>(geom);
		pts=p->getExteriorRing()->getCoordinates();
	}
	else
	{
		pts=geom->getCoordinates();
	}

	// special cases for lines or points or degenerate rings
	switch(pts->getSize())
	{
		case 0:
			minWidth=0.0;
			minWidthPt=NULL;
			minBaseSeg=NULL;
			break;
		case 1:
			minWidth = 0.0;
			minWidthPt=new Coordinate(pts->getAt(0));
			minBaseSeg->p0=pts->getAt(0);
			minBaseSeg->p1=pts->getAt(0);
			break;
		case 2:
		case 3:
			minWidth = 0.0;
			minWidthPt=new Coordinate(pts->getAt(0));
			minBaseSeg->p0=pts->getAt(0);
			minBaseSeg->p1=pts->getAt(1);
			break;
		default:
			computeConvexRingMinDiameter(pts);
	}
	delete pts; 
}