private void DoMinimumBoundingCircleTest(String wkt, String expectedWKT, Coordinate expectedCentre, double expectedRadius) { MinimumBoundingCircle mbc = new MinimumBoundingCircle(reader.Read(wkt)); Coordinate[] exPts = mbc.GetExtremalPoints(); IGeometry actual = geometryFactory.CreateMultiPoint(exPts); double actualRadius = mbc.GetRadius(); Coordinate actualCentre = mbc.GetCentre(); Console.WriteLine(" Centre = " + actualCentre + " Radius = " + actualRadius); IGeometry expected = reader.Read(expectedWKT); bool isEqual = actual.Equals(expected); // need this hack because apparently equals does not work for MULTIPOINT EMPTY if (actual.IsEmpty && expected.IsEmpty) isEqual = true; if (!isEqual) { Console.WriteLine("Actual = " + actual + ", Expected = " + expected); } Assert.IsTrue(isEqual); if (expectedCentre != null) { Assert.IsTrue(expectedCentre.Distance(actualCentre) < TOLERANCE); } if (expectedRadius >= 0) { Assert.IsTrue(Math.Abs(expectedRadius - actualRadius) < TOLERANCE); } }
private void Run(int nPts) { Coordinate[] randPts = CreateRandomPoints(nPts); IGeometry mp = _geomFact.CreateMultiPoint(randPts); MinimumBoundingCircle mbc = new MinimumBoundingCircle(mp); Coordinate centre = mbc.GetCentre(); double radius = mbc.GetRadius(); Console.WriteLine("Testing " + nPts + " random points. Radius = " + radius); checkWithinCircle(randPts, centre, radius, 0.0001); }